Points will be given only to the clearest well done answers and make sure your a
ID: 3548892 • Letter: P
Question
Points will be given only to the clearest well done answers and make sure your answers are correct, i don't care who will solve them firstly unless your answers were perfectly done.
(take your time in solving them)
good luck to all.
Answer the following programming questions,
Explanation / Answer
Only solution to Question 1:
Compiled on WinAVR-20100110
OS used Windows 8
#include<avr/io.h>
#include<util/delay.h>
unsigned char getdata(unsigned char chno)
{
ADMUX=0X60; //right align the ADC result
ADMUX|=chno; //select the ADC channel
ADCSRA|=0X40; //start ADC convertion
_delay_ms(1); //give some time delay to complete the ADC convertion
return ADCH;
}
int main(void)
{
PORTB=0x00;
DDRB=0xFF;
ADCSRA=0X87; //ADC enable, ADC interrupt enable, set prescaller to 128
unsigned int value;
while(1)
{
value=getdata(0x05); //ADC5
if(value > 76 && value < 179)
{
PORTB=0x0F;
}
else
{
PORTB=0xF0;
}
_delay_ms(500);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.