In this lesson, we will use a temperature sensor and a buzzer to make a high temperature alarm device.
After creating a new project, click on the Simulation icon on the left side of the page to enter the Simulation page.
Connect the buzzer to P0 and temperature sensor to D7(the temperature sensor must be connected to D7) of the Ezblock Pi. Then connect the VCC and GND to 3.3V and GNDrespectively.
Click Create variable in the Variables category to create a variable called temVal.
The temperature value of DS18B20 is read and stored in the variable temVal. There are two units of temperature, which can be selected by clicking in the drop-down menu. Then use print block to display the temperature on the Debug Monitor.
After you click the run button, drag the slider to set the reading value of sensor. If the reading value is > 30, the buzzer will ring, indicating that the codes are correct. Now save your project, connect the Bluetooth and click Flash to compile and download the code.