Advertisement
ocorbo

Untitled

Apr 9th, 2020
557
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <SoftwareSerial.h>
  2.  
  3. SoftwareSerial BT(2,3); //RX,TX
  4.  
  5. int buttonRead1;
  6. int buttonRead2;
  7. int buttonPin1 = 11 ;
  8. int buttonPin2 = 12 ;
  9.  
  10. void setup()
  11.  
  12. {
  13.  pinMode(buttonPin1, INPUT_PULLUP);
  14.  pinMode(buttonPin2, INPUT_PULLUP);
  15.  Serial.begin(9600);
  16.  BT.begin(9600);
  17.  
  18. }
  19.  
  20. void loop()
  21.  
  22. {
  23.   buttonRead1 = digitalRead(buttonPin1);
  24.   buttonRead2 = digitalRead(buttonPin2);
  25.  
  26.    if(buttonRead1 == 0)
  27.   {
  28.     BT.write('a');
  29.   }
  30.  
  31.     if(buttonRead2 == 0)
  32.   {
  33.     BT.write('b');
  34.   }
  35.  
  36.    /* if(buttonRead1 == 1 && buttonRead2 == 1)
  37.   {
  38.     Serial.write('w');
  39.     delay(10);
  40.   }*/
  41.  
  42. Serial.print(buttonRead1);
  43. Serial.println(buttonRead2);
  44.  
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement