Getting Started Guide
SCRATCH CODING KIT
Infrared (IR) Sensor Coding Experience
Just as you learned with the button sensor, you can see that the digital value is 'true' when the infrared sensor is
covered and the digital value is 'false' when it is off.
Now, let's see how to operate the motor using an infrared sensor instead of a button sensor. Plug the DC motor
into the 'Motore4' port on the main board.
Create a script like the one above. When you run the above script, you can see that the DC motor works when the
infrared sensor is covered. You've learned a total of four input sensors so far. Let's try to simplify the digital and
analog values for these sensors.
Coding a mini windmill with an infrared sensor
input sensor input signal Analog value Digital value
BUTTON SENSOR
When the sensor is pressed decrease TRUE
When the sensor is not pressed increase FALSE
CDS SENSOR
When sensor is covered increase FALSE
When not cover the sensor decrease TRUE
IR SENSOR
When sensor is covered decrease TRUE
When not cover the sensor increase FALSE
POTENTIOMERTER
Clockwise decrease TRUE
counterclockwise increase FALSE