Forked from winhtut/Arduino Bluetooth code With Sir's apk
Created
November 2, 2017 00:09
-
-
Save AungWinnHtut/29daafffd512d911e83cb7690d3b00ba to your computer and use it in GitHub Desktop.
Arduino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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