Write a ATmega16 code to send the temperature range from -4 to +4 to portB.
Alright the code is quite simple, just a reminder for a misconception we have been learning throughout out programming (me at least) that char only saves character or string type data, but here in embedded its just a container with size much smaller than a int container.
#include<avr/io.h>
int main(void)
{
DDRB = 0*FF;
unsigned char temp[]={-4,-3,-2,-1,0,+1,+2,+3,+4};
\\form a array of temp
unsigned char x;
for(x=0;x<9;x++)
{
PORTB = temp[x];
}
return 0;
}
#include<avr/io.h>
int main(void)
{
DDRB = 0*FF;
unsigned char temp[]={-4,-3,-2,-1,0,+1,+2,+3,+4};
\\form a array of temp
unsigned char x;
for(x=0;x<9;x++)
{
PORTB = temp[x];
}
return 0;
}
Comments
Post a Comment