We want to make a small, portable device that can sense smoke or vapours that might affect people. We can use a smoke sensor and a buzzer for the device. We can also make the device more accessible to people who have disabilities such as deafness by showing lights. We’ll use a smoke detector module and an active buzzer module.
This is the smoke detector.
This is the passive buzzer module.
Warning: there are two buzzer modules in the kit. the passive buzzer is the one with NO sticker or writing on the round black circle.
First we will need a place to store what value the smoke sensor is detecting. To do this we will need a variable. Go to variables, and press make a variable, we will call ours “smokeLevel”. Place the “set [smokeLevel] to ( )” block into the forever loop.
Then, from pins drag out the “analog pin [P0]” block and change that to “P1”, then drag this into the “set [smokeLevel] to ( )” block.
Next we will need a conditional statement, to compare if our smokeLevel is too high, and IF it is, then we will sound an alarm, and flash some lights.
We will drag out the conditional “IF < > then else” block from Logic
Next we will need to compare our values and determine if the smokeLevel is too high. To do this, we will need a comparison block from logic, the “ < ( ) [“greater than >”] ( ) >” block. Place that inside the if block up the top. On the left side of our greater than block, we will drag out the rounded “smokeLevel” block, place it in.
Next we will need to make the alarm. Drag out from music the “play tone middle C for 1 beat” block, and place it inside the top half of the IF block. Then below it, place a show icon (from Basic) with some appropriate “danger” picture, like the cross.
In the other half, place another icon with a “safe” image.