Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #define F_CPU 16000000UL //frequency of microcontroller #include #define RS PC4 // pin defined for RS OF LCD #define En PC5 // pin defined for

#include #define F_CPU 16000000UL //frequency of microcontroller #include #define RS PC4 // pin defined for RS OF LCD #define En PC5 // pin defined for ENABLE OF LCD #include // Library for interupts

#define ADC_CHANNEL0 0 #define ADC_CHANNEL1 1 #define ADC_CHANNEL2 2 #define DISPLAY_ON 0x0F // LCD command for display

#define CLEAR_DISPLAY 0x01 // LCD command for clearing display #define HOME 0x02 // LCD command for going back to again initilization #define MODE_4BIT 0x28 // 4 BIT/DATA pins mode of LCD #define motor OCR0A

void LCD_sendCommand(unsigned char command);//command's fuction of LCD void LCD_sendData(unsigned char data); // function to be used to send data void LCD_initiallize(void); // lcd initializing function void LCD_printString(char * sptr); //printing strings void move_motor(int adc_value); void init_timer0();

void init_timer0(void) //timer 0 function { OCR0A = motor; DDRD=(1

void init_adc(void) { DDRC = 0x00; // port C as an input DDRC = (1

unsigned int adc_Read(unsigned char channel) { unsigned char ADC_lo; unsigned char ADC_hi; unsigned int result; ADMUX &= ~(0x07); // clear previous selection of channel ADMUX |= channel; // Select the new channel // Delay needed for the stabilization of the ADC input voltage _delay_us(10); //wait for ADC to finish any ongoing operation while((ADCSRA & (1

result = (ADC_hi>6); return result; }

void move_motor(int adc_value) { motor=((float)adc_value*255)/1023; }

int main(void) { LCD_initiallize(); // LCD initialized char str1[]="LCD Initialized!"; char* ch1=str1; LCD_printString(ch1); _delay_ms(500); LCD_sendCommand(CLEAR_DISPLAY); LCD_sendCommand(0xC0); init_timer0(); //timer0 configured as fast pwm mode; init_adc(); int adc_value; while(1) { adc_value = adc_Read(0); _delay_ms(20); move_motor(adc_value); OCR0A = motor; } return 0; }

void LCD_sendCommand(unsigned char command) { PORTB &= ~(1> 4); // write the 4 MSBs of command /* send a pulse on the En pin */ PORTB |= (1> 4); // write the 4 MSBs of data /* send a pulse on the En pin */ PORTB |= (1

i have this code and this code is not reading and writing the adc value for the motor driver values plz make it correct and show the motor rpm or the speed with the clock wise direction text on to the lcd

image text in transcribed

here the circuit diagram plz correct the code its so important to me plz correct the code

DC MOTOR DRIVER- Proteus Professional - Schematic Capture File Edit View Tool Design Graph Debug Ly Template System Hely + +999 22 XD Schematic Cape Ave e TERMS DEFAULT NPUT OUTPUT Law CROUND SUS +3.210\08

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions

Question

3. Explain the relationship of research and theory.

Answered: 1 week ago