Skip to content

Instantly share code, notes, and snippets.

@techytushar
Created December 23, 2018 12:06
Show Gist options
  • Save techytushar/1291d62de685136fda3c9f552d03e31b to your computer and use it in GitHub Desktop.
Save techytushar/1291d62de685136fda3c9f552d03e31b to your computer and use it in GitHub Desktop.
Arduino Bluetooth
#include<SoftwareSerial.h>
SoftwareSerial BT(10,11);
String readData;
int led1=6;
int led2=7;
int val1=0;
int val2=0;
void setup(){
BT.begin(9600);
Serial.begin(9600);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
}
void loop(){
while(BT.available()){
delay(10);
char c=BT.read();
readData += c;
}
if(readData.length()>0){
Serial.println(readData);
if(readData=="motor"){
val1=digitalRead(led1);
if(val1==0){
digitalWrite(led1,HIGH);
val1=1;
}
else{
digitalWrite(led1,LOW);
val1=0;
}
delay(200);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment