About this project
This project introduces the BBC micro:bit's camera functionality, allowing users to take a timed photo using the device.
What you'll need
1 x BBC micro:bit
1 x Micro USB
1 x Computer or tablet
2 x AAA Batteries & Battery Holder
Project walkthrough
- Go to the BBC micro:bit website, click 'create code' and begin a new Microsoft Block Editor project.
- Under the left-hand commands menu, click 'Input' and find the 'On button [A] pressed do...' tile.
- We want to tell the device to take a photograph when the 'A' button is pressed. However, we also want to add in a five second delay to allow us to set up the shot. To enable the camera, select 'Devices' from the left-hand menu, and drag in the tile 'Tell camera to [take photo]. Attach to your 'On button [A] pressed do...' tile, and change [take photo] to [launch photo mode].
- To set up a countdown timer, drag in a 'set [item] to tile, and rename [item] to [counter].
- Attach a number tile from the 'Maths' menu, and set it to [5].
- Now we need to tell the timer to start counting down when the A button is pressed. This is a slightly different process to the last time we created a countdown timer (see Project Two). First you'll need to bring in a tile entitled 'for [i] from 0 to [4] do...' and attach it to your code. This tile can be found in the loops menu.
- In this tile, the [i] simply represents the variable being referenced in the code - in this case, the countdown timer. Feel free to change the name to something that makes more sense to you, but don't use 'counter' as we've already used this as a variable in this code. I've used 'Countdown' in this demo. Also, change the [4] to a [5] to bring it in line with your five second countdown timer.
- Under 'do', drag in a 'show number' tile from the 'Basic' menu, and drag a 'counter' tile from the Variables menu into the input box.
- Now drag in a 'change [item] by [1]' tile, also from the Variables menu, change [item] to [counter] and change [1] to [-1], to instruct the timer to count backwards from 5.
- Finally, drag in another 'Tell camera to [take photo]' tile from the devices menu, and attach this at the bottom, as indicated here:
- Now hit 'Run' to test out your script on the emulator. When you push the 'A' button the counter should begin counting down from 5 to 0. At zero, the device should take a photo. Compile your script and transfer it to your BBC micro:bit device to test it out for real. You can access your photos from the BBC micro:bit drive when you attach the device to your computer.
Once students have mastered this project, what else can they do with the BBC micro:bit camera functionality? Encourage them to play around with different commands and techniques, and let us know how they get on in the comments section below...
Top Comments
It would help to specify the requirements for a smartphone here. The Micro:bit doesn't have an onboard camera.
It looks like this uses the Bluetooth and BLE capabilities of the micro:bit. I'm no expert, but there are dozens/hundreds? of profiles for doing different things, and one of them is for camera control…
Like Andy says. Please clarify the fact that the micro:bit does not come with any onboard peripherals like speakers, cameras, etc. It would also be a good thing to add instructions on how exactly to attach…