Advertisement
salmancreation

Task -1 Motion Detection

Jun 26th, 2018
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.27 KB | None | 0 0
  1. int pir = 7;
  2. int val=0;
  3. int led=13;
  4. // motion - task 1
  5. void setup() {
  6.   pinMode(pir, INPUT);
  7.   pinMode(led, OUTPUT);
  8.  
  9.   Serial.begin(9600);
  10. }
  11. void loop() {
  12. val = digitalRead(pir);
  13. if(val==HIGH) {
  14.   digitalWrite(led, HIGH);
  15. }
  16. else {
  17.   digitalWrite(led, LOW);
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement