micro:climate Kit Experiment Guide

Pages
Contributors: D___Run___
Favorited Favorite 1

Experiment 2: Reading the Light Level

Introduction

Light conditions are a huge part of the weather. The great thing is that the weather:bit doesn’t have a light sensor. No, we didn’t miss a typo! The weather:bit doesn’t have a light sensor. Why not? Because the micro:bit has one already! In this experiment you will measure the light around you and have the micro:bit “graph” it

Parts Needed

For this experiment you actually don’t need the weather:bit carrier board, so we left it out. But feel free to leave it attached to your micro:bit if you so choose.

  • 1x micro:bit board (Not included)
  • 1x micro-B USB cable (Not included)
micro:bit Board

DEV-14208
$14.95
5
USB Micro-B Cable - 6"

CAB-13244
$1.95
3

Suggested Reading

Hardware Hookup

Again, the hardware hookup here is minimal! Plug your micro:bit into your computer with the USB cable, and you are good to go!

micro:bit connected via USB

Running Your Script

Please open a browser window and navigate to makecode.microbit.org. This should open the MakeCode environment that you used to install the weather:bit package.

Code to Note

Code to Note Exp 2

Set lightVal To

We read the light level in the area using the light level block and store it in a variable called lightVal. This is the value that we can compare against the calibration value you captured at the beginning of your script.

Plot Bar Graph Of

This block is fun! It accepts two values: the value of what you want to graph and a maximum value of that variable. In this case we want to graph lightVal, and it has a maximum value of 255. This will create a “bar graph” of the light value on your micro:bit.

What You Should See

You should see the LED array light up as a graph based on how bright it is wherever you are. Turn out the lights or pass your hand over the array, and the graph should react. Pretty sweet! You now have a way to measure the light value as well as another way to display data with the micro:bit.

Exp2 Powered

Troubleshooting

  • odd light readings — Make sure you are not leaning over the micro:bit, your shadow will impact the sensor reading.

  • The arrows threshold is odd — Try resetting the micro:bit while you are not leaning over it or casting a shadow on it.