Curriculum
Course: Sound Sensor Clap LED Project
Login
Text lesson

mblockCoding

mBlockCoding

MBlock Coding for Sound Sensor Clap LED Project 👏💡


1. Variables

Create variable:

 
state
 

This stores the sound sensor reading.


2. Main Program

Start Block

 
When Arduino starts up
 

Add:

 
forever
 

3. Read Sound Sensor

Inside forever add:

 
set state to digital read pin D2
 

Explanation

Arduino continuously checks:
“Did the sensor detect clap sound?”


4. Add Condition

 
if state = LOW then
 

Explanation

When clap sound occurs:

  • sensor output becomes LOW

5. LED ON

Inside IF block:

 
set digital pin 8 HIGH
 

Explanation

LED turns ON when clap detected.


6. Else Condition

 
else
 

Inside:

 
set digital pin 8 LOW
 

Explanation

Without sound:
LED remains OFF.


Final MBlock Logic

 
When Arduino starts up

forever

set state to digital read pin D2

if state = LOW then

set digital pin 8 HIGH

else

set digital pin 8 LOW
×
×

Cart