Robot_2010.c
_USART1_Init();
// global enable interrupts
sei();
Move(MV_DOWN,0);
Move(MV_RIGHT,0);
_pwm_set(_pwm_test_data[4]);
while(1)
{
_sound_ena=1;
_delay_ms(500);
_sound_ena=0;
_delay_ms(500);
}
}
// The Timer0 interrupt is defined in "LaserCard.c"
TIMER0_INTERRUPT
// USART interrupt routine
//
// - TKH 2010
ISR(USART1_RX_vect)
{
unsigned char c;
c=UDR1;
}
// This function moves the robot finger
// dir, direction [1,2,3,4]
// steps, number of steps, drives to the edge if 0 or 255
//
//
void Move(unsigned char dir, unsigned char steps)
{
unsigned char rest=0xFF, active=PORTA, dir_mask=0;
if(dir==MV_UP)
{
rest &= ~0b01000000;
active |= 0b00100000;
dir_mask=0b00000001;
}
else if(dir==MV_DOWN)
{
rest &= ~0b01000000;
active &= ~0b00100000;
dir_mask=0b00000010;
}
else if(dir==MV_LEFT)
{
rest &= ~0b00000100;
active &= ~0b00000010;
dir_mask=0b00001000;
}
else if(dir==MV_RIGHT)
{
rest &= ~0b00000100;
active |= 0b00000010;
dir_mask=0b00000100;
}
Sivu 2