Vous êtes sur la page 1sur 3

#include <avr/io.

h>

#include <avr/interrupt.h>

#include <util/delay.h>

void port_init(void)

DDRC=0X08; //DDRC register is used to initialize PortC as output port.

//Buzzer is connected to PIN 3 of PORTC

//Write suitable value to ensure only buzzer PIN 3 can be used.

PORTC=0X00; //PORTC register is used to turn on/off output device.

//Write suitable value to ensure buzzer is turned off at the start.

void motion_pin_config (void)

DDRA =0X0F; //set direction of the PORTA pins (PA3-PA0) as output

PORTA =0X00; //set initial value of the PORTA pins (PA3-PA0) to logic 0

DDRL =0X18; //Setting PL3 and PL4 pins as output for PWM generation

PORTL =0X18; //PL3 and PL4 pins are used for velocity control using PWM

}
void forward (void) //both wheels forward

PORTA=0X06; // Write sutiable value in PORTA to set direction of both wheels as


forward.

void stop (void)

PORTA=0X00; //Write suitable value in PORTA register to stop the robot.

void buzzer_on(void)

PORTC=0X08 ; //Write suitable value in PORTC to turn ON the buzzer

void buzzer_off(void)

PORTC=0X00; //Write suitable value in PORTC to turn off the buzzer

//Main Function
int main()

port_init();

motion_pin_config();

while(1)

forward();

_delay_ms(500);

stop();

buzzer_on();

_delay_ms(200);

buzzer_off();

//write your code here to moveto trace the straight line(in forward direction) using the
path traversed by the Firebird V for 5 seconds

// and then stop and turn ON Buzzer for 2 second.

//You can use _delay_ms() to generate the required delay

Vous aimerez peut-être aussi