Advertisement
Mechanizm

Untitled

Mar 20th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.10 KB | None | 0 0
  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 and
  6.   Leonardo, it is attached to digital pin 13. If you're unsure what
  7.   pin the on-board LED is connected to on your Arduino model, check
  8.   the documentation at http://www.arduino.cc
  9.  
  10.   This example code is in the public domain.
  11.  
  12.   modified 8 May 2014
  13.   by Scott Fitzgerald
  14.  */
  15. boolean sensor_value;
  16.  
  17. // the setup function runs once when you press reset or power the board
  18. void setup() {
  19.   // initialize digital pin 13 as an output.
  20.   pinMode(13, OUTPUT);
  21.   pinMode(12, INPUT);
  22.   Serial.begin(9600);
  23. }
  24.  
  25. // the loop function runs over and over again forever
  26. void loop() {
  27.  
  28.   for(int i = 0; i < 3; i++){
  29.   digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  30.   sensor_value = digitalRead(12);
  31.   Serial.println(sensor_value);
  32.   delay(500);              // wait for a second
  33.  
  34.   digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  35.   sensor_value = digitalRead(12);
  36.   Serial.println(sensor_value);
  37.   delay(250);              // wait for a second
  38.   }
  39.  
  40.   digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  41.   delay(250);              // wait for a second
  42.  
  43.   for(int i = 0; i < 3; i++){
  44.   digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  45.   delay(1000);              // wait for a second
  46.   digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  47.   delay(250);              // wait for a second
  48.   }
  49.  
  50.   digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  51.   delay(250);              // wait for a second
  52.  
  53.   for(int i = 0; i < 3; i++){
  54.   digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  55.   delay(500);              // wait for a second
  56.   digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  57.   delay(250);              // wait for a second
  58.   }
  59.  
  60.   digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  61.   delay(1000);              // wait for a second
  62.  
  63.  
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement