Untitled

mail@pastecode.io avatar
unknown
plain_text
18 days ago
1.1 kB
1
Indexable
Never
void setup() {
  // put your setup code here, to run once:
  
  pinMode(6,  OUTPUT);
  pinMode(7,  OUTPUT);
  pinMode(8,  OUTPUT);
  pinMode(9,  OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  forward();
  delay(1000);
  backward();
  delay(1000);
  left();
  delay(1000);
  right();
  delay(1000);
}

void forward(){
  analogWrite(5, 150);
  digitalWrite(6, LOW);
  digitalWrite(7, HIGH);
  analogWrite(10, 150);
  digitalWrite(8, HIGH);
  digitalWrite(9, LOW);
}

void backward(){
  analogWrite(5, 150);
  digitalWrite(7, LOW);
  digitalWrite(6, HIGH);
  analogWrite(10, 150);
  digitalWrite(9, HIGH);
  digitalWrite(8, LOW);
}

void left(){
  analogWrite(5, 150);
  digitalWrite(6, LOW);
  digitalWrite(7, HIGH);
  analogWrite(10, 150);
  digitalWrite(9, HIGH);
  digitalWrite(8, LOW);
}

void right(){
  analogWrite(5, 150);
  digitalWrite(7, LOW);
  digitalWrite(6, HIGH);
  analogWrite(10, 150);
  digitalWrite(8, HIGH);
  digitalWrite(9, LOW);
}

void stp(){
  analogWrite(5, 0);
  analogWrite(10, 0);
}
Leave a Comment