electro fashion ldr with micro bit - designhotline

1
LIGHT SENSOR micro:bit It is possible to use an LDR (Light Dependent Resistor) as an analogue input. Using the code shown the LED matrix will change from 0 displayed if it is light to X as soon as it goes dark. The resister combined with the LDR creates a potential divider, this creates the trigger to change the metric display. You can change the analogue value from 0 to 1045. for the LDR. Try experimenting with the values to see what happens with higher and lower values. How would you change the code to make the LED switch on if it is light and off if it is dark? To make the if-do-else command you need to click on the gear icon in the top left corner and drag the else command over as shown Drag the set item command to the forever loop and then create a New variable from the dropdown option and type Light 1: 2: OUT +

Upload: others

Post on 23-Feb-2022

1 views

Category:

Documents


0 download

TRANSCRIPT

LIG

HT

SEN

SOR

micro:bitIt is possible to use an LDR (Light Dependent Resistor) as an analogue input. Using the code shown the LED matrix will change from 0 displayed if it is light to X as soon as it goes dark. The resister combined with the LDR creates a potential divider, this creates the trigger to change the metric display. You can change the analogue value from 0 to 1045. for the LDR. Try experimenting with the values to see what happens with higher and lower values. How would you change the code to make the LED switch on if it is light and off if it is dark?

To make the if-do-else command you need to click on the gear icon in the top left corner and drag the else command over as shown

Drag the set item command to the forever loop and then create a New variable from the dropdown option and type Light

1:

2:

OUT

+