Advertisement
gabbyshimoni

read2pb-and-print

Jan 29th, 2019
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. /*
  2.    29/01/2019
  3.    Written by: Gabby Shimoni
  4.    Description:
  5.    This program read two push buttons and print their state to serial monitor
  6. */
  7. #define pb1Pin 9
  8. #define pb2Pin 10
  9. int pb1Value = 0;
  10. int pb2Value = 0;
  11. void setup() {
  12.   Serial.begin(9600);
  13.   pinMode(pb1Pin,INPUT);
  14.   pinMode(pb2Pin,INPUT);
  15. }
  16.  
  17. void loop() {
  18.   pb1Value = digitalRead(pb1Pin);
  19.   pb2Value = digitalRead(pb2Pin);
  20.   Serial.print("pb1="); Serial.print(pb1Value);
  21.   Serial.print("pb2="); Serial.println(pb2Value);
  22.   delay(100);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement