Last active
June 13, 2016 20:24
-
-
Save Milchreis/a0d0446c95a1fb362ccbf0ba354df872 to your computer and use it in GitHub Desktop.
Code for the arduino waterreminder project
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
#include <Sleep_n0m1.h> | |
// https://github.com/n0m1/Sleep_n0m1 | |
// Project: Waterminder | |
// Description: Reminder for drinking water :) | |
// Date: 2016-05-27 | |
// Author: Milchreis | |
// Set up the pin for connecting the buzzer | |
const int SOUND_PIN = 4; | |
// Set up the pin for blinking the led | |
const int LED_PIN = 7; | |
// Set up the time intervall for waiting in minutes | |
unsigned long sleepTimeInMins = 30; | |
Sleep sleep; | |
void setup() { | |
pinMode(SOUND_PIN, OUTPUT); | |
pinMode(LED_PIN, OUTPUT); | |
} | |
void loop() { | |
// configure here your melodie | |
beep(150, 65); | |
beep(150, 49); | |
beep(150, 65); | |
sleep.pwrDownMode(); | |
sleep.sleepDelay((unsigned long)sleepTimeInMins * 60 * 1000); | |
} | |
void beep(int delayms, int sound) { | |
digitalWrite(LED_PIN, HIGH); | |
tone(SOUND_PIN, sound, delayms); | |
// split the delay time to blink the led for one tone | |
delay(delayms/2); | |
digitalWrite(LED_PIN, LOW); | |
delay(delayms/2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment