Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Fixed this code to show the correct persantage of water in solil of 5 V ref voltage #include #include #define F _ CPU 8 0
Fixed this code to show the correct persantage of water in solil of V ref voltage #include #include #define FCPU UL #define BAUD #define MYUBRR FCPUBAUD void USARTInitunsigned int ubrr UBRRH unsigned charubrr ; UBRRL unsigned charubrr; UCSRB RXEN TXEN; UCSRC URSEL UCSZ UCSZ; void USARTTransmitunsigned char data while UCSRA & UDRE; UDR data; void ADCInit ADCSRA ADEN ADPS ADPS ADPS; uintt ADCReaduintt adcchannel ADMUX REFS adcchannel; ADCSRA ADSC; while ADCSRA & ADSC; return ADC; void LEDInit DDRD PD PD PD PD; Set PD PD PD PD as output void LEDControluintt moisturepercentage if moisturepercentage PORTD PD; LED connected to PD ON else if moisturepercentage PORTD PD; LED connected to PD ON else if moisturepercentage PORTD PD; LED connected to PD ON else PORTD PD; LED connected to PD ON int mainvoid USARTInitMYUBRR; ADCInit; LEDInit; uintt adcvalue; uintt moisturepercentage; while adcvalue ADCRead; Assuming the soil sensor is connected to PC moisturepercentage adcvalue ; Scale to moisture for V input USARTTransmitmoisturepercentage ; USARTTransmitmoisturepercentage ; USARTTransmitmoisturepercentage ; USARTTransmit; USARTTransmit ; LEDControlmoisturepercentage; Control LEDs based on moisture percentage delayms; Delay for stability
Fixed this code to show the correct persantage of water in solil of V ref voltage
#include
#include
#define FCPU UL
#define BAUD
#define MYUBRR FCPUBAUD
void USARTInitunsigned int ubrr
UBRRH unsigned charubrr ;
UBRRL unsigned charubrr;
UCSRB RXEN TXEN;
UCSRC URSEL UCSZ UCSZ;
void USARTTransmitunsigned char data
while UCSRA & UDRE;
UDR data;
void ADCInit
ADCSRA ADEN ADPS ADPS ADPS;
uintt ADCReaduintt adcchannel
ADMUX REFS adcchannel;
ADCSRA ADSC;
while ADCSRA & ADSC;
return ADC;
void LEDInit
DDRD PD PD PD PD; Set PD PD PD PD as output
void LEDControluintt moisturepercentage
if moisturepercentage
PORTD PD; LED connected to PD ON
else if moisturepercentage
PORTD PD; LED connected to PD ON
else if moisturepercentage
PORTD PD; LED connected to PD ON
else
PORTD PD; LED connected to PD ON
int mainvoid
USARTInitMYUBRR;
ADCInit;
LEDInit;
uintt adcvalue;
uintt moisturepercentage;
while
adcvalue ADCRead; Assuming the soil sensor is connected to PC
moisturepercentage adcvalue ; Scale to moisture for V input
USARTTransmitmoisturepercentage ;
USARTTransmitmoisturepercentage ;
USARTTransmitmoisturepercentage ;
USARTTransmit;
USARTTransmit
;
LEDControlmoisturepercentage; Control LEDs based on moisture percentage
delayms; Delay for stability
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started