const int AIA = 9; // (pwm) pin 9 connected to pin A-IA
const int AIB = 5; // (pwm) pin 5 connected to pin A-IB
const int BIA = 10; // (pwm) pin 10 connected to pin B-IA
const int BIB = 6; // (pwm) pin 6 connected to pin B-IB
int lampudepan = 11;
int lampubelakang = 12;
byte speed = 255; // change this (0-255) to control the speed of the motors
char command;
void setup() {
Serial.begin(9600);
pinMode(AIA, OUTPUT); // set pins to output
pinMode(AIB, OUTPUT);
pinMode(BIA, OUTPUT);
pinMode(BIB, OUTPUT);
pinMode(lampudepan, OUTPUT);
pinMode(lampubelakang, OUTPUT);
}
void loop() {
//void Forward()
//{
analogWrite(AIA, 0);
analogWrite(AIB, speed);
analogWrite(BIA, 0);
analogWrite(BIB, speed);
delay(1000);
analogWrite(AIA, 0);
analogWrite(AIB, 0);
analogWrite(BIA, 0);
analogWrite(BIB, 0);
delay(100);
//}
//void Back()
//{
analogWrite(AIA, speed);
analogWrite(AIB, 0);
analogWrite(BIA, speed);
analogWrite(BIB, 0);
delay(1000);
//belok kanan
analogWrite(AIA, 0);
analogWrite(AIB, 0);
analogWrite(BIA, speed);
analogWrite(BIB, 0);
delay(500);
analogWrite(AIA, 0);
analogWrite(AIB, 0);
analogWrite(BIA, 0);
analogWrite(BIB, 0);
delay(100);
digitalWrite(lampudepan,HIGH);
digitalWrite(lampubelakang,LOW);
delay(300);
digitalWrite(lampudepan,LOW);
digitalWrite(lampubelakang,HIGH);
delay(300);
digitalWrite(lampudepan,HIGH);
digitalWrite(lampubelakang,LOW);
delay(300);
digitalWrite(lampudepan,LOW);
digitalWrite(lampubelakang,HIGH);
delay(300);
digitalWrite(lampudepan,HIGH);
digitalWrite(lampubelakang,LOW);
delay(300);
digitalWrite(lampudepan,LOW);
digitalWrite(lampubelakang,HIGH);
delay(300);
digitalWrite(lampudepan,HIGH);
digitalWrite(lampubelakang,LOW);
delay(300);
digitalWrite(lampudepan,LOW);
digitalWrite(lampubelakang,HIGH);
delay(300);
digitalWrite(lampudepan,HIGH);
digitalWrite(lampubelakang,LOW);
delay(300);
digitalWrite(lampudepan,LOW);
digitalWrite(lampubelakang,HIGH);
delay(300);
digitalWrite(lampudepan,HIGH);
digitalWrite(lampubelakang,LOW);
delay(300);
digitalWrite(lampudepan,LOW);
digitalWrite(lampubelakang,HIGH);
delay(300);
//}
/*
//void Left()
//{
analogWrite(AIA, speed);
analogWrite(AIB, 0);
analogWrite(BIA, 0);
analogWrite(BIB, 0);
delay(500);
analogWrite(AIA, 0);
analogWrite(AIB, 0);
analogWrite(BIA, 0);
analogWrite(BIB, 0);
delay(100);
//}
//void Right()
//{
analogWrite(AIA, 0);
analogWrite(AIB, 0);
analogWrite(BIA, speed);
analogWrite(BIB, 0);
delay(500);
analogWrite(AIA, 0);
analogWrite(AIB, 0);
analogWrite(BIA, 0);
analogWrite(BIB, 0);
delay(100);
analogWrite(AIA, speed);
analogWrite(AIB, 0);
analogWrite(BIA, 0);
analogWrite(BIB, 0);
delay(500);
analogWrite(AIA, 0);
analogWrite(AIB, 0);
analogWrite(BIA, 0);
analogWrite(BIB, 0);
delay(100);
//}
//void Right()
//{
analogWrite(AIA, 0);
analogWrite(AIB, 0);
analogWrite(BIA, speed);
analogWrite(BIB, 0);
delay(500);
analogWrite(AIA, 0);
analogWrite(AIB, 0);
analogWrite(BIA, 0);
analogWrite(BIB, 0);
delay(100);
analogWrite(AIA, speed);
analogWrite(AIB, 0);
analogWrite(BIA, 0);
analogWrite(BIB, 0);
delay(500);
analogWrite(AIA, 0);
analogWrite(AIB, 0);
analogWrite(BIA, 0);
analogWrite(BIB, 0);
delay(100);
//}
//void Right()
//{
analogWrite(AIA, 0);
analogWrite(AIB, 0);
analogWrite(BIA, speed);
analogWrite(BIB, 0);
delay(500);
analogWrite(AIA, 0);
analogWrite(AIB, 0);
analogWrite(BIA, 0);
analogWrite(BIB, 0);
delay(100);
*/
}
Tidak ada komentar:
Posting Komentar