Closing Down Sale - At least 50% off EVERYTHING !!!

Search

Cables and Connectors

LED's and Illumination

Motors and Drivers

Announcements

Esme's Electronics

Feature Teacher

Troy's Tutorials

The LAMP:Bit - Part 2

LEARN HOW TO CONTROL YOUR LAMP:BIT WITHOUT EVEN TOUCHING IT!

Now that you've learnt the basics from my last blog, we can get into some more technical stuff. This extension is really cool because it works just like the street lights or automatic car headlights do. When the sun goes down and it gets darker, the lights turn on, and when it’s light outside, the lights stay off. Keep reading to find out how you can make your LAMP:bit do the same!

For this, you’ll need the following: 

 

STEP 1:

A really cool thing you can do with theLAMP:bit is to make the light turn on or off depending on how much light there is on the phototransistor. When the room is dark, the lamp can turn on, and then turn off when the room is light. To do this, you need to start with a ‘forever’ code block, and add the "logic" block so it look like this:

 

STEP 2:

Then, drag a comparison code block from logic onto the area that says “true”. On the left side of the comparison code block, add the ‘read light level’ from the LAMP:bit code blocks. On the right, change the number to 512.

 

 

STEP 3:

We want the lamp to turn on when the room is dark and turn off when the room is light. To do this, add a ‘turn lamp light’ block in the first part and set it to ‘on’, then add another ‘turn lamp light’ block to the bottom part and set it to ‘off’.

 

 

STEP 4:

Now you're ready to code your micro:bit! Download it onto your device, then upload it onto your micro:bit. You can test this code by moving your hand over the top of the lamp. When your hand is over it, the light should turn on, and turn off when you move your hand again. 

 

*Expert Tip*
This might not work if you're in a room with the lights turned on. Try taking it outside into the natural light and testing it out there!

RELATED PRODUCTS

MICRO:BIT STARTER KIT

LAMP:BIT STREET LIGHT

 

READ NEXT:

The STOP:bit - Part 1

Leave a comment (all fields required)

Comments will be approved before showing up.

Search