Posted By

carmematas on 03/15/18


Tagged

arduino ir prcatiques


Versions (?)

Detector d'objectes per IR


 / Published in: C++
 

Codi per detectar amb una placa Arduino objectes amb un sensor IR

  1. #define LED 13
  2. #define BUTTONPIN 3
  3. boolean val;
  4.  
  5. void setup (){
  6. pinMode (LED, OUTPUT);
  7. pinMode (BUTTONPIN, INPUT);
  8. Serial.begin(9600);
  9. }
  10. void loop (){
  11. val = digitalRead(BUTTONPIN);// digital interface will be assigned a value of 3 to read val
  12. if (val == HIGH) digitalWrite (LED, HIGH);
  13. else digitalWrite(LED, LOW);
  14. Serial.println(val);
  15. }

Report this snippet  

You need to login to post a comment.