Components and supplies
Arduino UNO
Project description
Code
Talkative Automation
arduino
Voice controlled automation with audio reply
1 2#include "SD.h" 3#define SD_ChipSelectPin 10 4#include "TMRpcm.h" 5#include "SPI.h" 6#include "LiquidCrystal.h" 7 8TMRpcm tmrpcm; 9LiquidCrystal lcd(7, 6, 5, 4, 3, 2); 10 11#define Light A0 12#define TV A1 13#define heater A2 14int temp=0,i=0; 15int led=A3; 16int blink=0; 17char str[40]; 18void setup() 19{ 20 lcd.begin(16,2); 21 Serial.begin(9600); 22 pinMode(led, OUTPUT); 23 pinMode(heater, OUTPUT); 24 pinMode(Light, OUTPUT); 25 pinMode(TV, OUTPUT); 26 digitalWrite(heater,HIGH); 27 28 lcd.setCursor(0,0); 29 lcd.print("Voice Controlled"); 30 lcd.setCursor(0,1); 31 lcd.print(" Automaton "); 32 delay(2000); 33 lcd.clear(); 34 lcd.setCursor(0,1); 35 lcd.print("System Ready"); 36 delay(500); 37 delay(1000); 38 lcd.clear(); 39 lcd.setCursor(0,0); 40lcd.print("Light TV Heater"); 41 lcd.setCursor(0,1); 42 lcd.print("OFF OFF OFF "); 43 tmrpcm.speakerPin=9; 44 if(!SD.begin(SD_ChipSelectPin)) 45{ 46 Serial.println("SD fail"); 47 return; 48} 49tmrpcm.setVolume(6); 50tmrpcm.play("ready.wav"); 51} 52void loop() 53{ 54 lcd.setCursor(0,0); 55 lcd.print("Light TV Heater"); 56 57 if(temp==1) 58 { 59 check(); 60 Serial.println(str); 61 temp=0; 62 i=0; 63 delay(1000); 64 } 65} 66 void serialEvent() 67 { 68 while(Serial.available()) 69 { 70 if(Serial.find("*")) 71 { 72 delay(5000); 73 while (Serial.available()) 74 { 75 char inChar=Serial.read(); 76 str[i++]=inChar; 77 if(inChar=='#') 78 { 79 temp=1; 80 return; 81 } 82 } 83 } 84 } 85 } 86void check() 87{ 88 if(!(strncmp(str,"TV on",5))) 89 { 90 digitalWrite(TV, HIGH); 91 lcd.setCursor(6,1); 92 lcd.print("ON "); 93 tmrpcm.play("tv_on.wav"); 94 delay(200); 95 } 96 97 else if(!(strncmp(str,"TV off",6))) 98 { 99 digitalWrite(TV, LOW); 100 lcd.setCursor(6,1); 101 lcd.print("OFF "); 102 tmrpcm.play("tv_off.wav"); 103 delay(200); 104 } 105 106 else if(!(strncmp(str,"heater on",9))) 107 { 108 digitalWrite(heater, LOW); 109 lcd.setCursor(11,1); 110 lcd.print("ON "); 111 tmrpcm.play("htr_on.wav"); 112 delay(200); 113 } 114 115 else if(!(strncmp(str,"heater off",10))) 116 { 117 digitalWrite(heater, HIGH); 118 lcd.setCursor(11,1); 119 lcd.print("OFF "); 120 tmrpcm.play("htr_off.wav"); 121 delay(200); 122 } 123 124 else if(!(strncmp(str,"light on",8))) 125 { 126 digitalWrite(Light, HIGH); 127 lcd.setCursor(0,1); 128 lcd.print("ON "); 129 tmrpcm.play("light_on.wav"); 130 delay(200); 131 } 132 133 else if(!(strncmp(str,"light off",9))) 134 { 135 digitalWrite(Light, LOW); 136 lcd.setCursor(0,1); 137 lcd.print("OFF "); 138 tmrpcm.play("light_of.wav"); 139 delay(200); 140 } 141 142 else if(!(strncmp(str,"all on",6))) 143 { 144 digitalWrite(Light, HIGH); 145 digitalWrite(heater, LOW); 146 digitalWrite(TV, HIGH); 147 lcd.setCursor(0,1); 148 lcd.print("ON ON ON "); 149 tmrpcm.play("all_on.wav"); 150 delay(200); 151 } 152 153 else if(!(strncmp(str,"all of",6))) 154 { 155 digitalWrite(Light, LOW); 156 digitalWrite(heater, HIGH); 157 digitalWrite(TV, LOW); 158 lcd.setCursor(0,1); 159 lcd.print("OFF OFF OFF "); 160 tmrpcm.play("all_off.wav"); 161 delay(200); 162 } 163 164 else if(!(strncmp(str,"all off",7))) 165 { 166 digitalWrite(Light, LOW); 167 digitalWrite(heater, HIGH); 168 digitalWrite(TV, LOW); 169 lcd.setCursor(0,1); 170 lcd.print("OFF OFF OFF "); 171 tmrpcm.play("all_off.wav"); 172 delay(200); 173 } 174} 175 176 177
Talkative Automation
arduino
Voice controlled automation with audio reply
1 2#include "SD.h" 3#define SD_ChipSelectPin 10 4#include "TMRpcm.h" 5#include 6 "SPI.h" 7#include "LiquidCrystal.h" 8 9TMRpcm tmrpcm; 10LiquidCrystal 11 lcd(7, 6, 5, 4, 3, 2); 12 13#define Light A0 14#define TV A1 15#define heater 16 A2 17int temp=0,i=0; 18int led=A3; 19int blink=0; 20char str[40]; 21void setup() 22{ 23 24 lcd.begin(16,2); 25 Serial.begin(9600); 26 pinMode(led, OUTPUT); 27 28 pinMode(heater, OUTPUT); 29 pinMode(Light, OUTPUT); 30 pinMode(TV, 31 OUTPUT); 32 digitalWrite(heater,HIGH); 33 34 lcd.setCursor(0,0); 35 36 lcd.print("Voice Controlled"); 37 lcd.setCursor(0,1); 38 lcd.print(" Automaton 39 "); 40 delay(2000); 41 lcd.clear(); 42 lcd.setCursor(0,1); 43 lcd.print("System 44 Ready"); 45 delay(500); 46 delay(1000); 47 lcd.clear(); 48 lcd.setCursor(0,0); 49lcd.print("Light 50 TV Heater"); 51 lcd.setCursor(0,1); 52 lcd.print("OFF OFF OFF "); 53 54 tmrpcm.speakerPin=9; 55 if(!SD.begin(SD_ChipSelectPin)) 56{ 57 Serial.println("SD 58 fail"); 59 return; 60} 61tmrpcm.setVolume(6); 62tmrpcm.play("ready.wav"); 63 64} 65void loop() 66{ 67 lcd.setCursor(0,0); 68 lcd.print("Light TV Heater"); 69 70 71 if(temp==1) 72 { 73 check(); 74 Serial.println(str); 75 temp=0; 76 77 i=0; 78 delay(1000); 79 } 80} 81 void serialEvent() 82 { 83 while(Serial.available()) 84 85 { 86 if(Serial.find("*")) 87 { 88 delay(5000); 89 while 90 (Serial.available()) 91 { 92 char inChar=Serial.read(); 93 str[i++]=inChar; 94 95 if(inChar=='#') 96 { 97 temp=1; 98 return; 99 } 100 101 } 102 } 103 } 104 } 105void check() 106{ 107 if(!(strncmp(str,"TV 108 on",5))) 109 { 110 digitalWrite(TV, HIGH); 111 lcd.setCursor(6,1); 112 113 lcd.print("ON "); 114 tmrpcm.play("tv_on.wav"); 115 delay(200); 116 117 } 118 119 else if(!(strncmp(str,"TV off",6))) 120 { 121 digitalWrite(TV, 122 LOW); 123 lcd.setCursor(6,1); 124 lcd.print("OFF "); 125 tmrpcm.play("tv_off.wav"); 126 127 delay(200); 128 } 129 130 else if(!(strncmp(str,"heater on",9))) 131 132 { 133 digitalWrite(heater, LOW); 134 lcd.setCursor(11,1); 135 lcd.print("ON 136 "); 137 tmrpcm.play("htr_on.wav"); 138 delay(200); 139 } 140 141 142 else if(!(strncmp(str,"heater off",10))) 143 { 144 digitalWrite(heater, 145 HIGH); 146 lcd.setCursor(11,1); 147 lcd.print("OFF "); 148 tmrpcm.play("htr_off.wav"); 149 150 delay(200); 151 } 152 153 else if(!(strncmp(str,"light on",8))) 154 155 { 156 digitalWrite(Light, HIGH); 157 lcd.setCursor(0,1); 158 lcd.print("ON 159 "); 160 tmrpcm.play("light_on.wav"); 161 delay(200); 162 } 163 164 165 else if(!(strncmp(str,"light off",9))) 166 { 167 digitalWrite(Light, 168 LOW); 169 lcd.setCursor(0,1); 170 lcd.print("OFF "); 171 tmrpcm.play("light_of.wav"); 172 173 delay(200); 174 } 175 176 else if(!(strncmp(str,"all on",6))) 177 178 { 179 digitalWrite(Light, HIGH); 180 digitalWrite(heater, LOW); 181 182 digitalWrite(TV, HIGH); 183 lcd.setCursor(0,1); 184 lcd.print("ON 185 ON ON "); 186 tmrpcm.play("all_on.wav"); 187 delay(200); 188 189 } 190 191 else if(!(strncmp(str,"all of",6))) 192 { 193 digitalWrite(Light, 194 LOW); 195 digitalWrite(heater, HIGH); 196 digitalWrite(TV, LOW); 197 lcd.setCursor(0,1); 198 199 lcd.print("OFF OFF OFF "); 200 tmrpcm.play("all_off.wav"); 201 202 delay(200); 203 } 204 205 else if(!(strncmp(str,"all off",7))) 206 207 { 208 digitalWrite(Light, LOW); 209 digitalWrite(heater, HIGH); 210 211 digitalWrite(TV, LOW); 212 lcd.setCursor(0,1); 213 lcd.print("OFF 214 OFF OFF "); 215 tmrpcm.play("all_off.wav"); 216 delay(200); 217 218 } 219} 220 221 222
Talkative Automation
arduino
Voice controlled automation with audio reply
1 2#include "SD.h" 3#define SD_ChipSelectPin 10 4#include "TMRpcm.h" 5#include "SPI.h" 6#include "LiquidCrystal.h" 7 8TMRpcm tmrpcm; 9LiquidCrystal lcd(7, 6, 5, 4, 3, 2); 10 11#define Light A0 12#define TV A1 13#define heater A2 14int temp=0,i=0; 15int led=A3; 16int blink=0; 17char str[40]; 18void setup() 19{ 20 lcd.begin(16,2); 21 Serial.begin(9600); 22 pinMode(led, OUTPUT); 23 pinMode(heater, OUTPUT); 24 pinMode(Light, OUTPUT); 25 pinMode(TV, OUTPUT); 26 digitalWrite(heater,HIGH); 27 28 lcd.setCursor(0,0); 29 lcd.print("Voice Controlled"); 30 lcd.setCursor(0,1); 31 lcd.print(" Automaton "); 32 delay(2000); 33 lcd.clear(); 34 lcd.setCursor(0,1); 35 lcd.print("System Ready"); 36 delay(500); 37 delay(1000); 38 lcd.clear(); 39 lcd.setCursor(0,0); 40lcd.print("Light TV Heater"); 41 lcd.setCursor(0,1); 42 lcd.print("OFF OFF OFF "); 43 tmrpcm.speakerPin=9; 44 if(!SD.begin(SD_ChipSelectPin)) 45{ 46 Serial.println("SD fail"); 47 return; 48} 49tmrpcm.setVolume(6); 50tmrpcm.play("ready.wav"); 51} 52void loop() 53{ 54 lcd.setCursor(0,0); 55 lcd.print("Light TV Heater"); 56 57 if(temp==1) 58 { 59 check(); 60 Serial.println(str); 61 temp=0; 62 i=0; 63 delay(1000); 64 } 65} 66 void serialEvent() 67 { 68 while(Serial.available()) 69 { 70 if(Serial.find("*")) 71 { 72 delay(5000); 73 while (Serial.available()) 74 { 75 char inChar=Serial.read(); 76 str[i++]=inChar; 77 if(inChar=='#') 78 { 79 temp=1; 80 return; 81 } 82 } 83 } 84 } 85 } 86void check() 87{ 88 if(!(strncmp(str,"TV on",5))) 89 { 90 digitalWrite(TV, HIGH); 91 lcd.setCursor(6,1); 92 lcd.print("ON "); 93 tmrpcm.play("tv_on.wav"); 94 delay(200); 95 } 96 97 else if(!(strncmp(str,"TV off",6))) 98 { 99 digitalWrite(TV, LOW); 100 lcd.setCursor(6,1); 101 lcd.print("OFF "); 102 tmrpcm.play("tv_off.wav"); 103 delay(200); 104 } 105 106 else if(!(strncmp(str,"heater on",9))) 107 { 108 digitalWrite(heater, LOW); 109 lcd.setCursor(11,1); 110 lcd.print("ON "); 111 tmrpcm.play("htr_on.wav"); 112 delay(200); 113 } 114 115 else if(!(strncmp(str,"heater off",10))) 116 { 117 digitalWrite(heater, HIGH); 118 lcd.setCursor(11,1); 119 lcd.print("OFF "); 120 tmrpcm.play("htr_off.wav"); 121 delay(200); 122 } 123 124 else if(!(strncmp(str,"light on",8))) 125 { 126 digitalWrite(Light, HIGH); 127 lcd.setCursor(0,1); 128 lcd.print("ON "); 129 tmrpcm.play("light_on.wav"); 130 delay(200); 131 } 132 133 else if(!(strncmp(str,"light off",9))) 134 { 135 digitalWrite(Light, LOW); 136 lcd.setCursor(0,1); 137 lcd.print("OFF "); 138 tmrpcm.play("light_of.wav"); 139 delay(200); 140 } 141 142 else if(!(strncmp(str,"all on",6))) 143 { 144 digitalWrite(Light, HIGH); 145 digitalWrite(heater, LOW); 146 digitalWrite(TV, HIGH); 147 lcd.setCursor(0,1); 148 lcd.print("ON ON ON "); 149 tmrpcm.play("all_on.wav"); 150 delay(200); 151 } 152 153 else if(!(strncmp(str,"all of",6))) 154 { 155 digitalWrite(Light, LOW); 156 digitalWrite(heater, HIGH); 157 digitalWrite(TV, LOW); 158 lcd.setCursor(0,1); 159 lcd.print("OFF OFF OFF "); 160 tmrpcm.play("all_off.wav"); 161 delay(200); 162 } 163 164 else if(!(strncmp(str,"all off",7))) 165 { 166 digitalWrite(Light, LOW); 167 digitalWrite(heater, HIGH); 168 digitalWrite(TV, LOW); 169 lcd.setCursor(0,1); 170 lcd.print("OFF OFF OFF "); 171 tmrpcm.play("all_off.wav"); 172 delay(200); 173 } 174} 175 176 177
Comments
Only logged in users can leave comments
Vishalsoniindia
4 Followers
•3 Projects
9
0
Talkative Automation || Audio from Arduino || HC-05 || Voice | Arduino Project Hub