- Electro-Fashion light sensor.
- 3 x clip wires, something like these.
Add Light Sensing To The BBC micro:bit:
The Electro-Fashion Light Sensing Board (shown below) is very simple. It has three connection points which can be connected to the BBC micro:bit with clip wires (or also with conductive thread if you prefer). The 'Out' pin of the Light Sensing board provides an 'analog' voltage that is proportional to the brightness of the light falling on the sensor. As the light level increases, the voltage also increases on the 'Out' pin. Typically this will swing (approximately) between 0.9V (dark) and 3V (light) due to varying light levels. Firstly, he Light Sensing board should be connected to the BBC micro:bit in the following way (also see diagram):Pin Assignments:
Light Sensing Board Connection | BBC micro:bit Connection |
---|---|
Out pin | P0 pin of the BBC micro:bit |
+ pin | 3V pin on the BBC micro:bit |
- pin | GND pin on the BBC micro:bit |
Add Light Sensing To The BBC micro:bit Code:
The code demonstrated in the video is very simple and can be seen below. It was created using the MakeCode Editor and is based around a 'forever' loop. The loop has a succession of 'else if' statements. Firstly, the value of the analog reading on P0 (connected to the light sensor) is checked and depending on it's value one of six display options is shown. This also repeats and varies the display as the light level alters, giving a kind of bar graph look. In addition, you can also use the Plot Bar Graph function in the Block Editor, see the diagram below.©Kitronik Ltd – You may print this page & link to it, but must not copy the page or part thereof without Kitronik's prior written consent.