Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<SoftwareSerial.h>
- int Rx = 2;
- int Tx = 3;
- SoftwareSerial bluetoothSerial(Tx, Rx); // define the bluetooth
- char c; // variable c to store data
- int led = 13;
- void setup() {
- bluetoothSerial.begin(9600); // speed of bluetooth
- Serial.begin(9600);
- pinMode(led, OUTPUT);
- digitalWrite(led, HIGH);
- Serial.println("LED ON");
- }
- void loop() {
- if (bluetoothSerial.available()) {
- c = bluetoothSerial.read();
- Serial.println("Bluetooth data avaliable");
- Serial.println(c);
- if (c == '1') {
- digitalWrite(led, HIGH);
- Serial.println("LED ON");
- }
- if (c == '0') {
- digitalWrite(led, LOW);
- Serial.println("LED OFF !!!!!!!");
- }
- }
- Serial.print(".");
- }
Add Comment
Please, Sign In to add comment