STEP1: Connect push-button module to pin P0 of the expansion board; connect servo to P1.
1. Drag “set pin P9 servo to…degree” block in “actuator” module. Change P9 to P0. Set pin P0 to control servo’ s value.
2. Set: if the button is pressed, the servo rotates for 100 degree and the LED display “o”. Otherwise, the servo rotates for 0 degree and the LED display “×”. Here we need to use “if…then…else” statement.
3. Run the program
STEP1: Connect the servo to pin P1; connect the motion sensor to pin P0.
1. Read the digital pin P0 to get the digital signal data of the motion sensor.
2. When the motion sensor detected that there is people passing by, the servo rotates for 100 degrees; otherwise, it rotates 0 degree. We need “if…then…else” statement here.
3. Run the program: