How do I use the bitboard with a microbit?
If this is your first experience with the microbit, or you need a refresher on the basics, please see this set of instructions.
The bitboard allows many inputs and outputs to be easily connected to the microbit. This article will show you the basic setup of the bitboard as well as how to connect and do basic programming for some of the components included in the bitboard kit.
Connecting the microbit to the bitboard:
- Make sure the microbit is not plugged in.
- Gently press the microbit into the bitboard with the LED facing away from the center of the board.
- Connect your microbit as you did using the previous instructions.
- Once connected, the microbit will run the last program downloaded until you replace it with a new program.
Connecting a simple LED to the bitboard:
- Most components have one side that is colored white.
- The exceptions are the slide switch with two white sides and the potentiometer with no white sections. In addition, the RGB LED has more options on the non-white side.
Let's start with an LED.
- Pick one of the four LEDs included in your kit.
- Use alligator clips to connect the white side (either hole) to the ground (gnd) on either end of the bitboard.
- Make sure the alligator clips are going through the hole rather than across it.
- Connect the other side to pin 2.
- Open makecode.microbit.org and start a new project.
- Click on Advanced to reveal the pins options
- Click on Pins
- Drag the digital write pin block into your Forever command.
- Change the pin number to 2
- Change the value to 1
- Download your program (and connect your microbit)
- Your light should now be on.
Digital vs Analog
- Every pin on the bitboard can be used to digital read and write. That means it can get information and send information to the pin as a 0 or 1. Think on or off. In our LED example, the digital write value of 1 turned the light on.
- Analog read and write allows for a range of values. Only pins 0-4 and 10 can analog read, but all can analog write. That means you can send analog information to any pin but only receive it from pins 0-4 and 10.
Dimming the LED with programming
Let's use analog write to dim our LED
- Remove the Digital Write block from your forever code and replace it with the Analog Write block located in the Pins section of the Advanced code.
- Set the Pin value to 2 and the write value to any number between 0 and 1023. Remember to download your new code in order for the microbit to run it.
- Change the number and re-download. What makes the LED brighter and dimmer?
Dimming the LED with a Potentiometer
- Set the Analog write value to 1023 in your code and download it. This should return your LED to full brightness.
- Disconnect the alligator attached to pin 2 of the bitboard and instead connect it to one of the holes in the first row of contacts on the potentiometer.
- Take another alligator clip and attach one clip to a hole in the second row of holes on the potentiometer and the other clip to pin 2 of the bitboard.
- Rotate the potentiometer.
All the other components
Try connecting other components to the bitboard. The switches can be used to turn things on and off, and the piezo speaker can make sounds. We will get into the RGB LED and motors next session, but feel free to try to make them work if you want to.