Lesson 11 Vibration Sensor

Share for us

Introduction

In this lesson, we will use vibration sensors to feel vibrations.

Components

Programming Steps

Step 1

After creating a new project, click on the Simulation icon on the left side of the page to enter the Simulation page.

Step 2

Connect the buzzer module to P0 and vibration switch module to D1. Then connect the VCC and GND to 3.3V and GND respectively. The vibration sensor is used to sense the magnitude of the vibration force.

Step 3

Create a variable named vibVal by clicking Create variable under the Variables category.

Step 4

The reading of vibration sensor is assigned to the variable vibVal and then is printed on the Debug Monitor via print block.

Step 5

Set a judgment condition by if do block. If vibVal is equal to 0, let the buzzer sound. You can modify the buzzer’s note and beat yourself.

Step 6

Go to the Simulation page and click on the Run button. Long press the vibration switch module, and you will see that the vibration switch has litter effect. Now save your project, connect the Bluetooth and click Flash to compile and download the code.