Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AungWinnHtut/29daafffd512d911e83cb7690d3b00ba to your computer and use it in GitHub Desktop.
Save AungWinnHtut/29daafffd512d911e83cb7690d3b00ba to your computer and use it in GitHub Desktop.
Arduino
#include <SoftwareSerial.h>
SoftwareSerial WinHtutBT(7, 6);
int i = 0;
void setup() {
Serial.begin(9600);
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
WinHtutBT.begin(9600);
}
void loop() {
if (WinHtutBT.available() > 0) {
i = WinHtutBT.read();
Serial.println(i);
if (i == '3') {
digitalWrite(2,HIGH);
digitalWrite(3,LOW);
digitalWrite(4,HIGH);
digitalWrite(5,LOW);
Serial.println("Forward");
}
if (i == '4') {
digitalWrite(3,HIGH);
digitalWrite(2,LOW);
digitalWrite(5,HIGH);
digitalWrite(4,LOW);
Serial.println("Backward");
}
if (i == '1') {
digitalWrite(2,HIGH);
digitalWrite(3,LOW);
digitalWrite(5,HIGH);
digitalWrite(4,HIGH);
Serial.println("left");
}
if (i == '7') {
digitalWrite(3,HIGH);
digitalWrite(2,HIGH);
digitalWrite(5,HIGH);
digitalWrite(4,HIGH);
Serial.println("stop");
}
if (i == '2') {
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(5,HIGH);
digitalWrite(4,LOW);
Serial.println("right");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment