Yell at the Alarm
From Microduino Wiki
Language: | English • 中文 |
---|
ContentsObjectiveYou can DIY an alarm clock here. It can wake you up at 7:00 in the morning and the way to stop it is to shout at it. If you struggle to wake up, it's indeed a great experience to abreact mood by shouting at your noisy alarm clock. PrincipleEquipment
Hardware Buildup
Software DebuggingCode Description
#define buzzer_pin 6
int micPin = A2;
int micValue=0;
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);//Define the connection method of the OLED
void initTime() {
rtc.initClock();
//set a time to start with.
//day, weekday, month, century(1=1900, 0=2000), year(0-99)
rtc.setDate(11, 4, 6, 0, 15);
//hr, min, sec
rtc.setTime(13, 5, 0);
}
void updateAlarm() {
if(timeHH==7&&timeMM<5) {
if(micValue>500) {
isRoar=true;
}
if(isRoar) {
noTone(buzzer_pin);
} else {
tone(buzzer_pin,500); //Out the frequency in the port.
}
} else {
isRoar=false;
noTone(buzzer_pin);
}
} ProgramResultEvery morning at 7:00, the alarm goes on and will last five minutes, during which time you can also interrupt it by shouting at the clock. Video |