Please can you helkp me design the protues schematic and i have the code draft,post,2.2 – Designing the Trucks

Need help with assignments?

Our qualified writers can create original, plagiarism-free papers in any format you choose (APA, MLA, Harvard, Chicago, etc.)

Order from us for quality, customized work in due time of your choice.

Click Here To Order Now

Please can you helkp me design the protues schematic and i have the code
void UART_Init();
void ADC_Init();
unsigned int ADC_Read();
void Timer2_Init();
void UART_SendString(const char* str);
void DisplayTemperature(float temp);
void delay_ms(unsigned int ms);
void delay_us(unsigned int us);
int main() {
UART_Init();
ADC_Init();
Timer2_Init();

while(1) {
unsigned int adcValue = ADC_Read();
float temperature = (adcValue * 3.3 / 1023.0 – 0.5) * 100; // Convert ADC value to temperature
DisplayTemperature(temperature);
delay_ms(500); // 500 ms delay between readings
}
}
// Custom millisecond delay
void delay_ms(unsigned int ms) {
while (ms–) {
delay_us(1000); // Each ms is 1000 us
}
}
// Custom microsecond delay
void delay_us(unsigned int us) {
while (us–) {
// A simple loop that takes approximately 1 us to execute, adjust as necessary for your clock speed
asm(″nop″); asm(″nop″); asm(″nop″); asm(″nop″);
}
}
// Initialize UART1
void UART_Init() {
U1MODEbits.BRGH = 0; // Low-speed mode
U1BRG = (unsigned int)((FCY / (16 * BAUD_RATE)) – 1);
U1MODEbits.PDSEL = 0; // 8-bit data, no parity
U1MODEbits.STSEL = 0; // 1 Stop bit
U1STAbits.UTXEN = 1; // Enable transmit
U1MODEbits.UARTEN = 1; // Enable UART
}
// Initialize ADC for 10-bit manual sampling
void ADC_Init() {
AD1CON1bits.FORM = 2; // Signed integer output
AD1CON1bits.SSRC = 0; // Manual sampling
AD1CON2bits.VCFG = 0; // AVDD and AVSS as references
AD1CON3bits.ADCS = 4; // ADC clock (FCY / 625 kHz)
AD1CHS = 4; // Connect to AN4 (Port B Pin 4)
AD1CON1bits.ADON = 1; // Turn on ADC
}
// Read ADC value
unsigned int ADC_Read() {
AD1CON1bits.SAMP = 1; // Start sampling
delay_us(10); // Sampling time
AD1CON1bits.SAMP = 0; // Start conversion
while (!AD1CON1bits.DONE); // Wait for conversion to finish
return ADC1BUF0;
}
// Initialize Timer2 for 500 ms delay
void Timer2_Init() {
T2CON = 0x0030; // Set prescaler to 256
PR2 = (FCY / 256) * 0.5 – 1; // 500 ms delay
T2CONbits.TON = 1;
}
// Send a string via UART
void UART_SendString(const char* str) {
while(*str != ′′) {
while(U1STAbits.UTXBF); // Wait until buffer is free
U1TXREG = *str++;
}
}
// Display temperature and rotation direction
void DisplayTemperature(float temp) {
char buffer[50];
sprintf(buffer, ″Current Temperature is: %.1f Celsiusrn″, (double)temp); // Cast to (double) to avoid warning
UART_SendString(buffer);

if(temp ˂ TEMP_THRESHOLD) {
UART_SendString(″Clockwise Rotationrn″);
} else {
UART_SendString(″Counter Clockwise Rotationrn″);
}
}

Need help with assignments?

Our qualified writers can create original, plagiarism-free papers in any format you choose (APA, MLA, Harvard, Chicago, etc.)

Order from us for quality, customized work in due time of your choice.

Click Here To Order Now