mathiaspl20

IR Serial Read

Feb 27th, 2017
40
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Blink
  3. Turns on an LED on for one second, then off for one second, repeatedly.
  4.  
  5. Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
  6. it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
  7. the correct LED pin independent of which board is used.
  8. If you want to know what pin the on-board LED is connected to on your Arduino model, check
  9. the Technical Specs of your board at https://www.arduino.cc/en/Main/Products
  10.  
  11. This example code is in the public domain.
  12.  
  13. modified 8 May 2014
  14. by Scott Fitzgerald
  15.  
  16. modified 2 Sep 2016
  17. by Arturo Guadalupi
  18.  
  19. modified 8 Sep 2016
  20. by Colby Newman
  21. */
  22.  
  23.  
  24. // the setup function runs once when you press reset or power the board
  25. void setup() {
  26. Serial.begin(115200);
  27. // initialize digital pin LED_BUILTIN as an output.
  28. pinMode(16, OUTPUT);
  29. pinMode(5, INPUT);
  30. }
  31.  
  32. // the loop function runs over and over again forever
  33. void loop() {
  34. digitalWrite(16, HIGH); // turn the LED on (HIGH is the voltage level)
  35. delay(1000); // wait for a second
  36. int state= digitalRead(5);
  37. Serial.println(state);
  38. digitalWrite(16, LOW); // turn the LED off by making the voltage LOW
  39. delay(1000); // wait for a second
  40. int state1= digitalRead(5);
  41. Serial.println(state1);
  42. }
RAW Paste Data