Hello! For the Voice Activated Lamp project, I used the code Science Buddies gave me, but it only lights up my Grove Speech Recognizer (V3) LEDs, and my Arduino UNO board LEDs, it doesn't turn on or turn off my lamp. Do you have answers to my problem, or any tips? Thank you!
#include <SoftwareSerial.h>
#define SOFTSERIAL_RX_PIN 2
#define SOFTSERIAL_TX_PIN 3
SoftwareSerial softSerial(SOFTSERIAL_RX_PIN,SOFTSERIAL_TX_PIN);
int led = 13;
const char *voiceBuffer[] =
{
"Turn on the light",
"Turn off the light",
"Play music",
"Pause",
"Next",
"Previous",
"Up",
"Down",
"Turn on the TV",
"Turn off the TV",
"Increase temperature",
"Decrease temperature",
"What's the time",
"Open the door",
"Close the door",
"Left",
"Right",
"Stop",
"Start",
"Mode 1",
"Mode 2",
"Go",
};
void setup()
{
Serial.begin(9600);
softSerial.begin(9600);
softSerial.listen();
pinMode(led,OUTPUT);
digitalWrite(led,LOW);
}
void loop()
{
char cmd;
if(softSerial.available())
{
cmd = softSerial.read();
Serial.println(voiceBuffer[cmd - 1]);
if((voiceBuffer[cmd - 1]) == "Turn on the light"){
digitalWrite(led,HIGH);
}
else if((voiceBuffer[cmd - 1]) == "Turn off the light"){
digitalWrite(led,LOW);
}
}
}
[Administrator note: project url: https://www.sciencebuddies.org/science- ... olled-lamp ]
Voice Activated Lamp Science Project
Moderators: kgudger, bfinio, MadelineB, Moderators
-
violetalison
- Posts: 1
- Joined: Tue May 28, 2024 3:05 pm
- Occupation: Student
-
bfinio
- Expert
- Posts: 964
- Joined: Mon Aug 12, 2013 2:41 pm
- Occupation: Lead Staff Scientist, Science Buddies
- Project Question: Expert
- Project Due Date: n/a
- Project Status: Not applicable
Re: Voice Activated Lamp Science Project
Hi - are you using the IoT Relay to connect your Arduino to your lamp? If so, to test the relay, you can use the basic Arduino "blink" program (I think it's under File/Examples/Basics/Blink). By default this will blink the onboard LED on the Arduino on and off in one-second intervals. Change the pin number in the program to the pin you have connected to the IoT relay and upload it. Your lamp should blink on and off.
If that does not work, you may have the relay wired improperly. We can help troubleshoot if you upload pictures of your circuit. Please make sure the pictures are clear, well-lit, and in-focus so we can see the connections on the breadboard, to the Arduino, and to the IoT relay. You may need to take multiple pictures from different angles so we can see all the connections.
If that does not work, you may have the relay wired improperly. We can help troubleshoot if you upload pictures of your circuit. Please make sure the pictures are clear, well-lit, and in-focus so we can see the connections on the breadboard, to the Arduino, and to the IoT relay. You may need to take multiple pictures from different angles so we can see all the connections.

