Mobile_Controlled_Robot:
Code:
#include <avr/io.h>
#define key2 0xfd
#define key4 0xfb
#define key6 0xf9
#define key8 0xf7
#define key5 0xfa
#define left 0x01
#define right 0x02
#define forward 0x03
#define reverse 0x0c
#define stop 0x00
#define key PINA
#define direction PORTC
int main(void)
{
DDRA=0xf0;
DDRC=0xff;
while(1)
{
PORTA=0xff;
if(key==key2)
direction=forward;
else if(key==key4)
direction=left;
else if(key==key6)
direction=right;
else if(key==key8)
direction=reverse;
else if(key==key5)
direction= stop;
}
}
0 comments:
Post a Comment
if you have any doubt please let me know