Search

Cables & Connectors

Electronics Components

Motors & Controllers

On Sale items!

Get Professional Support

BBC Micro:bit

Robotics

On sale items!

Announcement


Check out our latest news to find out more about events, opportunities and partnerships.

Esmes' Electronics


Esmes' Electronics is a simple introduction to using the micro:bit written by a year 5 student.

Troys' tutorials


Learn with Troy by asking for support and, he will post a tutorial here to benefit all of our visitors. Free advice!

Feature teacher


Be inspired by some of our favorite teachers using our products.

Get professional support


Contact us now to request your own tutorial or learning resource.

This section doesn’t currently include any content. Add content to this section using the sidebar.

Image caption appears here

Add your deal, information or promotional text

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