#include
#include
#include
#define DDR_motor DDRD //DDR inilisiasi for Motor
#define PORT_motor PORTD //PORT inisialisasi Motor
#define en_ka 5 // Enable L298 for right motor
#define dirA_ka 2 // Direction A for right motor
#define dirB_ka 3 // Direction B for right motor
#define pwm_right OCR1A
void delay_ms(int ms)
{for (int i=0;i
void foward(unsigned int pwm)
{
PORT_motor |=(1<
PORT_motor &=~(1<
pwm_right=pwm; //pwm for right motor
}
void backward(unsigned int pwm)
{
PORT_motor |=(1<
PORT_motor &=~(1<
pwm_right=pwm; //pwm for right motor
}
int main (void) // excetion
{
DDR_motor=0xFF;
PORT_motor=0x00;
TCCR1A= (1<
(1<
(1<
TCCR1B= (0<
(0<
TCNT1=0x0000;
OCR1A=0;
OCR1B=0;
sei( );
while(1)
{
backward(1000);
delay_ms(5000);
foward(700);
delay_ms(3000);
}
}
source
No comments:
Post a Comment