Skip to content
International Shipping
Wish Lists Cart
0 items

#11 Clap On Off Magic Lamp Project With PicoBricks

18 Nov 2023
#11 Clap On Off Magic Lamp Project With PicoBricks
You have always wanted to turn the lamps on and off by clapping while lying in your bed. In this project, we will learn how to turn the lights on and off with clapping, and how it works. We used Raspberry Pi Kit in the project.
Most of us have seen lamps flashing magically or doors opening and closing with the sound of clapping in movies. There are set assistants who close these doors and turn off the lamps in the shootings. What if we did this automatically? There are sensors that convert the sound intensity change that we expect to occur in the environment into an electrical signal. These are called sound sensors.

 

Details and Algorithm

In this project, we will turn the LED module on the picobricks board on and off with the sound. In our project, which we will build using the PicoBricks sound level sensor, we will perform the on-off operations by making a clap sound. As in previous projects, in projects where sensors are used, before we start to write the codes, it will make your progress easier to see what values the sensor sends in the operations we want to do by just running the sensor, and then writing the codes of the project based on these values.

Components

1X PicoBricks
1X Sound Sensor
3X Jumper Cable

Wiring Diagram

You can code and run PicoBricks’ modules without wiring. If you are going to use the modules by separating them from the board, you should make the module connections with grove cables.

MicroBlocks Codes of the PicoBricks

You can access the Microblocks codes of the project by dragging the image to the Microblocks Run tab or click the button.

 

Microblocks Run Tab

MicroPython Codes of the PicoBricks

 


from machine import Pin #to access the hardware on the pico
sensor=Pin(1,Pin.IN) #initialize digital pin 1as an INPUTfor Sensor
led=Pin(7,Pin.OUT)#initialize digital pin 7as an OUTPUTforLEDwhile True:
    #When sensor value is '0', the relay will be '1'print(sensor.value())if sensor.value()==1:
        led.value(1)else:
        led.value(0)

Arduino C Codes of the PicoBricks

 


void setup() {
  // put your setup code here, to run once:
  pinMode(1,INPUT);
  pinMode(7,OUTPUT);
  //define the input and output pins
}
void loop() {
  // put your main code here, to run repeatedly:

  Serial.println(digitalRead(1));
  if(digitalRead(1)==1){
    digitalWrite(7,HIGH);
    delay(3000);
  }
  else{
    digitalWrite(7,LOW);
    delay(1000);
  }
}

GitHub Project Page
Prev Post
Next Post

Thanks for subscribing!

This email has been registered!

Shop the look
Choose Options

Edit Option

Have Questions?

Back In Stock Notification

Compare

Product SKUDescription Collection Availability Product Type Other Details

Terms & Conditions

What is Lorem Ipsum? Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Why do we use it? It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
this is just a warning
Login
Shopping Cart
0 items