Introduction: Smart Lamp
A Seeeduino Nano microcontroller based smart lamp. Clap, tap or blow on it: it switches on and off.
Supplies
Items you need:
- Seeedunino Nano board,
- 5V relay,
- Grove sound sensor,
- 12V home-made led-board,
- 12V power supply connector,
- a nice design ceramic tea light candle holder
Step 1:
Assembly of the circuit.
Step 2:
Upload the following code in Arduino IDE:
//Sound Lamp 1.0 VI 2021
//Grove - Sound sensor, relay, led lamp
const int Sound = A5;
const int D2 = 2;
long Value = 0;
bool LightOn;
void setup()
{
Serial.begin(115200);
pinMode(D2, OUTPUT); // initialize D2 pin as OUTPUT;
Serial.println("Grove - Sound Sensor Warning program starts...");
digitalWrite(D2, HIGH); // turn relay on
Serial.println("Relay in, light on");
delay(500);
digitalWrite(D2, LOW); // turn relay off
Serial.println("Relay off,light off");
}
void loop()
{
Value=analogRead(Sound);
Serial.println(Value);
if (Value<=500){
Serial.println("Halk");
}
else if (Value>500){
Serial.println("Hangos");
if (LightOn == false){
LightOn = true;
digitalWrite(D2, HIGH); // turn relay on
Serial.println("Relay on, light on");
Serial.println (LightOn);
delay(100);
}
else if (LightOn == true){
LightOn = false;
digitalWrite(D2, LOW); // turn relay off
Serial.println("Relay off,light off");
Serial.println (LightOn);
delay(100);
}
}
delay(100);
}
Remark: The sound value (variable: Value) have to be aligned to your environment (e.g. general noise at your place, how loud you normally clap your hand, etc.).
Step 3:
Cover the holes of the tea light candle holder with translucent adhesive foil.
Step 4:
Place the circuit in the lamp, use some adhesive to fix the parts, and connect it to the power supply (a 12V adapter is required).
Step 5:
If you clap now, the light is going to switch on. If you clap again it is goint to switch off again.
Have fun!





