micro:climate Kit Experiment Guide

Pages
Contributors: bboyho, D___Run___
Favorited Favorite 11

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

You will need the following parts:

  • 1x micro:bit Board (Not Included with Kit)
  • 1x Micro-B USB Cable (Not Included with Kit)
  • 1x weather:bit Carrier Board

Didn't get the kit? Have no fear! Here are the parts you will need to complete this experiment. You may not need everything though depending on what you have. Add it to your cart, read through the guide, and adjust the cart as necessary.

USB Micro-B Cable - 6"

USB Micro-B Cable - 6"

CAB-13244
$2.10
3

micro:bit Board

DEV-14208
10 Retired

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 extension.

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.