Guest User

Untitled

a guest
May 26th, 2016
208
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <SoftwareSerial.h>
  2.  
  3. SoftwareSerial bluetooth(10, 11); // RX, TX
  4. int a1 = 6;
  5. int a2 = 5;
  6.  
  7. String receivedBluetoothString = "";
  8.  
  9. void setup() {
  10. bluetooth.begin(9600);
  11. pinMode(a1, OUTPUT);
  12. pinMode(a2, OUTPUT);
  13. }
  14.  
  15. void loop() {
  16. while (bluetooth.available() > 0) {
  17.  
  18. char receivedBluetoothChar = bluetooth.read();
  19. receivedBluetoothString += receivedBluetoothChar;
  20.  
  21. if (receivedBluetoothChar == '\n') {
  22.  
  23. if (receivedBluetoothString.toInt() == 887425) {
  24. digitalWrite(a1, HIGH);
  25. delay(500);
  26. digitalWrite(a1, LOW);
  27. } else if (receivedBluetoothString.toInt() == 887426) {
  28. digitalWrite(a1, HIGH);
  29. delay(1000);
  30. digitalWrite(a1, LOW);
  31. }
  32.  
  33. receivedBluetoothString = "";
  34. }
  35. }
  36. }
RAW Paste Data Copied