Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. int buttonPin = 8;
  2. int buttonState = 0;
  3.  
  4. void setup() {
  5.   pinMode(buttonPin, INPUT);
  6.   Serial.begin(38400); // Default communication rate of the Bluetooth module
  7. }
  8.  
  9. void loop() {
  10.  int buttonState = 0;
  11.  delay(100);
  12.  buttonState = digitalRead(buttonPin);
  13.  if (buttonState == HIGH) {
  14.    Serial.write('0'); // Sends '1' to serialout
  15.  }
  16.  else {
  17.    Serial.write('1');
  18.  }  
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement