Advertisement
skizziks_53

30-seconds-per-hour-timer_ver_1

Dec 21st, 2017
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.97 KB | None | 0 0
  1. /*
  2.    This is an Arduino Uno sketch that turns on pin #12
  3.    for 30 seconds, once (approximately) every hour.
  4.    It also blinks pin 13 once every second [for .1 seconds on]
  5.    to indicate that the program is actually running properly.
  6. */
  7.  
  8.  
  9. void setup() {
  10.   // put your setup code here, to run once:
  11.   pinMode(12, OUTPUT); // Pin #12 is for controlling the motor relay.
  12.   pinMode(13, OUTPUT); // Pin #13 is just for blinking the pin-13 LED.
  13. }
  14.  
  15. void loop() {
  16.   // 59.5 minute delay:
  17.   for (int x = 0; x < 119; x++) {
  18.     // 59 minutes / 30 seconds = 118, + 30 more seconds = 119
  19.     thirty_second_delay();
  20.   }
  21.   // turn pin 12 on:
  22.   digitalWrite(12, HIGH);
  23.   // 30 second delay:
  24.   thirty_second_delay();
  25.   // turn pin 12 off:
  26.   digitalWrite(12, LOW);
  27. }
  28.  
  29. void thirty_second_delay() {
  30.   for (int y = 0; y < 29; y++) {
  31.     one_second_delay();
  32.   }
  33. }
  34.  
  35. void one_second_delay() {
  36.   digitalWrite(13, HIGH);
  37.   delay(100);
  38.   digitalWrite(13, LOW);
  39.   delay(900);
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement