Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a114b8
commit ff5a050
Showing
1 changed file
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Pomodoro, with Arduino | ||
*/ | ||
|
||
// array of pins that control pomodoro progression | ||
int pomodoroPins[] = {3,4,5,6,7}; | ||
|
||
// pin that controls single 'break' pin | ||
int breakPin = 10; | ||
|
||
// delay between each interval LED of pomodoro (in microseconds) | ||
// note: 5 pins * 5 mins = 25 minute total pomodoro | ||
int pomodoroPinDelayTime = 5000; | ||
|
||
// delay between blink | ||
int pomodoroPinBlinkTime = 500; | ||
|
||
// sets up pins that are defined above | ||
void setup() | ||
{ | ||
int index; | ||
for(index = 0; index <= 5; index++) | ||
{ | ||
pinMode(pomodoroPins[index], OUTPUT); | ||
} | ||
pinMode(breakPin, OUTPUT); | ||
} | ||
|
||
// loops through pomodoro progression and updates LEDs | ||
void loop() | ||
{ | ||
// walk through pomodoro interval indicators | ||
int index; | ||
for(index = 0; index < 5; index++) | ||
{ | ||
blinkLight(pomodoroPins[index], pomodoroPinBlinkTime, pomodoroPinDelayTime); | ||
digitalWrite(pomodoroPins[index], HIGH); | ||
} | ||
|
||
// todo make a noise | ||
// todo wait for acknowledgement | ||
|
||
// break time | ||
blinkLight(breakPin, pomodoroPinBlinkTime, pomodoroPinDelayTime); | ||
digitalWrite(breakPin, HIGH); | ||
|
||
// todo make a noise | ||
// todo wait for acknowledgement | ||
|
||
// clear everything | ||
digitalWrite(breakPin, LOW); | ||
for(index = 0; index < 5; index++) | ||
{ | ||
digitalWrite(pomodoroPins[index], LOW); | ||
} | ||
} | ||
|
||
// convenience function to handle a blink of a passed in LED | ||
void blinkLight(int pin, int blinkLength, int totalBlinkLength) { | ||
int blinkTimer; | ||
for ( | ||
blinkTimer = 0; | ||
blinkTimer < totalBlinkLength; | ||
blinkTimer += (blinkLength * 2) | ||
) | ||
{ | ||
digitalWrite(pin, HIGH); | ||
delay(blinkLength); | ||
digitalWrite(pin, LOW); | ||
delay(blinkLength); | ||
} | ||
} |