Cool Timer with Voice synthesizer
This is a timer that can be setup without watching the device using just a push button. It can be useful for blind.
Components and supplies
1
Arduino Nano R3
1
Push Button
1
4 Digit Display
1
DF Robot Gravity Speech Synthesis Module SKU DFR0760
Tools and machines
1
Drill / Driver, Cordless
Project description
Code
Smart Timer
arduino
1/* 2 * Carlo Stramaglia 3 * https://www.youtube.com/c/CarloStramaglia 4 5 * This is a Smart Timer that 6 * once you set it up, will remind you every quarter 7 to check the food in the pan 8 * June 1st 2021 9 */ 10 11#include "DFRobot_SpeechSynthesis.h" 12#include 13 <TM1637.h> 14#include "OneButton.h" 15 16int minutes=00; 17int seconds=0; 18char 19 tmp[5]; 20 21DFRobot_SpeechSynthesis_I2C ss; 22 23// Display Pins configurations 24// 25 Pin 3 - > DIO 26// Pin 2 - > CLK 27TM1637 tm1637(2, 3); 28 29// Push Button 30 PIN definition 31#define PIN_INPUT A2 32 33OneButton button(PIN_INPUT, true); 34 35void 36 setup() { 37 Serial.begin(115200); 38 Serial.println("Smart Timer sketch. Carlo 39 Stramaglia https://www.youtube.com/c/CarloStramaglia"); 40 //Init speech synthesis 41 sensor 42 ss.begin(); 43 //Set voice volume to 7 44 ss.setVolume(7); 45 //Set 46 playback speed to 5 47 ss.setSpeed(5); 48 //Set speaker to female 49 ss.setSoundType(ss.MALE1); 50 51 //Set tone to 5 52 ss.setTone(5); 53 ss.setSpeechStyle(ss.SMOOTH); 54 ss.setEnglishPron(ss.WORD); 55 56 ss.setDigitalPron(ss.AUTOJUDGED); 57 ss.setLanguage(ss.ENGLISHL); 58 tm1637.init(); 59 60 tm1637.setBrightness(5); 61 button.attachClick(singleClick); 62 button.attachDoubleClick(doubleClick); 63 64 button.attachLongPressStart(longPressStart); 65 tm1637.clearScreen(); 66 tm1637.colonOn(); 67 68 tm1637.display("0000"); 69 tm1637.colonOn(); 70 delay(100); 71 72 73} 74 75void 76 loop() { 77 button.tick(); 78 delay (10); 79} 80 81void singleClick() 82{ 83 84 Serial.println("x1"); 85 minutes++; 86 Serial.println(minutes); 87 sprintf(tmp, 88 "%d", minutes); 89 ss.speak((tmp)); 90 delay (100); 91 ss.speak(F("minutes 92 set")); 93 if (minutes < 10) 94 tm1637.display(minutes,1,0,1); 95 else 96 97 tm1637.display(minutes); 98 Serial.println(tmp); 99 delay(100); 100} // 101 singleClick 102 103 104void doubleClick() 105{ 106 Serial.println("x2"); 107 108 if (minutes == 0) return; 109 ss.speak(F("Starting countdown")); 110 minutes--; 111 112 for (minutes ; minutes >= 0; minutes--) { 113 for (int seconds = 59; seconds 114 >= 0; seconds--) { 115 if (minutes < 10 && minutes >0) 116 tm1637.display(seconds 117 + minutes*100,1,0,1); 118 else if (minutes == 0 && seconds >=10) 119 120 tm1637.display(seconds + minutes*100,1,0,2); 121 else if 122 (minutes == 0 && seconds < 10) 123 tm1637.display(seconds + minutes*100,1,0,3); 124 125 else 126 tm1637.display(seconds + minutes*100); 127 128 tm1637.switchColon(); 129 if (seconds == 0) 130 { 131 132 sprintf(tmp,"%d", minutes); 133 ss.speak(tmp); 134 135 delay(100); 136 ss.speak(F("minutes left")); 137 } 138 139 delay(1000); 140 } 141 } 142 ss.speak(F("Time finished")); 143 144 delay (1000); 145 ss.speak(F("you can setup a new timer now")); 146 tm1637.colonOn(); 147 148 tm1637.display("0000"); 149 minutes = 0; 150 tm1637.colonOn(); 151 delay(100); 152 153 154} // doubleClick 155 156void longPressStart() 157{ 158 Serial.println("long 159 Press"); 160 minutes = 0; 161 ss.speak(F("Counter reset")); 162 tm1637.colonOn(); 163 164 tm1637.display("0000"); 165 tm1637.colonOn(); 166 delay(100); 167} // longPressStart 168
Downloadable files
Smart Timer
Smart Timer
Smart Timer
Smart Timer
Comments
Only logged in users can leave comments