Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- This is an Arduino Uno sketch that turns on pin #12
- for 30 seconds, once (approximately) every hour.
- It also blinks pin 13 once every second [for .1 seconds on]
- to indicate that the program is actually running properly.
- */
- void setup() {
- // put your setup code here, to run once:
- pinMode(12, OUTPUT); // Pin #12 is for controlling the motor relay.
- pinMode(13, OUTPUT); // Pin #13 is just for blinking the pin-13 LED.
- }
- void loop() {
- // 59.5 minute delay:
- for (int x = 0; x < 119; x++) {
- // 59 minutes / 30 seconds = 118, + 30 more seconds = 119
- thirty_second_delay();
- }
- // turn pin 12 on:
- digitalWrite(12, HIGH);
- // 30 second delay:
- thirty_second_delay();
- // turn pin 12 off:
- digitalWrite(12, LOW);
- }
- void thirty_second_delay() {
- for (int y = 0; y < 29; y++) {
- one_second_delay();
- }
- }
- void one_second_delay() {
- digitalWrite(13, HIGH);
- delay(100);
- digitalWrite(13, LOW);
- delay(900);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement