This site uses cookies to deliver our services and provide a basic level of website functionality. The four different types of cookies are: Strictly Necessary cookies, Functionality cookies, Performance cookies and Advertising cookies. By checking the box and clicking the button below, you are informing Rapid Electronics Ltd that you agree to the use of these cookies as detailed in our Privacy Policy.

Industry Schools FE/HE Site: Industry Site: Schools Site: FE/HE Site: Mobile
+44 (0)1206 751166

Bit Bot in use

BIT:BOT

The Bit:Bot Robot is a feature-packed little robot that is almost ready to go, requiring no soldering, no wires and nothing more than a screwdriver to complete it.

  • 2x motors
  • Super-smooth metal ball
  • front caster
  • 12x neopixel LEDs
  • 2x line following sensors
  • 2x analogue light sensors
  • Sounder for making beeps wherever you go!
  • Expansion connections for adding the Ultrasonic Distance Sensor

  More Details  


PROJECT IDEAS


Remote control

Here is a fun little project to control your Bit:Bot remotely using another micro:bit.

There are loads of ways of achieving this but this is a really simple one to get you started. Once you have mastered the basics, you can try adding reverse or perhaps use the addressable LEDs to greater effect!

What you will need:

  • A Bit:Bot fitted with a micro:bit and 3 AA batteries
  • A second micro:bit and battery box with 2 AAA batteries
  • A computer and access to the micro:bit webpage

This example uses the JavaScript block editor to create the program. Head over to microbit.org and click on Let’s Code. Then choose the JavaScript Blocks Editor.


Downloads

Download the .hex files for this Bit:Bot program below. You can open these files in the micro:bit Javascript Blocks Editor here.

microbit-bitBotTX.hex
This is the program for the micro:bit that you are using as a remote control

microbit-bitbotRx.hex
This is the program that runs on the micro:bit that is on your Bit:Bot

1

You are going to need to create two programs – one to run on the standalone micro:bit (which will act as your remote control) and one to run on the Bit:Bot. We'll do the program for the remote control first. This program is made up of 2 main parts:

2

Let's break the program down and look at what it is doing:

The micro:bit radio can be used to transmit on 256 different channels or groups – 0 to 255. This means that you can share data between many micro:bits in the same group, or in a classroom environment it can be useful to assign each student their own group number to use so that their projects do not interfere with one another. In this case, we are setting this micro:bit to operate on group 1 the moment the program starts.

3

Next we have a forever loop. This means that the instructions in the loop are executed continuously over and over until the power is turned off.

3

Next we have an if statement that checks to see if button A on the micro:bit has been pressed. If it has, the micro:bit will broadcast a packet that contains the string "A" and the number 1. It also switches on one of the LEDs at position 0, 0 of the display using the plot command. This is to show the user that the button on the remote has been pressed.

If the button is not pressed (else), the micro:bit broadcasts a similar packet, but with a 0 rather than a 1. It also switches off the LED at position 0, 0 using the unplot command.

4

This if statement is very similar to the one for the A button, but instead checks the B button and broadcasts a slightly different packet and uses an LED at location 4,0 to tell the user that the button has been pressed.

5

Now let's take a look at the program for the micro:bit that is on the Bit:Bot robot. This program is made up of 3 main parts.

You might have noticed that the program uses some bright green blocks that aren't in the normal command set. This is because Bit:Bot has its own library of commands. To access them, you need to add the library by clicking Add Package. In the search box, type BitBot and then click on the BitBot package to add it to the list of commands.

6

Firstly, the micro:bit on the robot needs to be set to the same group as the remote control.

This part of the program looks for an incoming signal sent from another micro:bit. It is looking for a packet of data made up of a string and a number value which will temporarily be stored in variables called name and value.

If the string received is "acc" (remember we used this to represent the accelerometer value) then the numerical value is stored in a variable called speed. We'll use this later to tell our robot how fast to go.

If the string received is "A", we know this is the data from button A being pressed which will be either 0 or 1. This value is stored in a variable called A.

If the string received is "B", we know this is the data from button A being pressed which will be either 0 or 1. This value is stored in a variable called B.

7

The forever loop part of the program is the part that makes the robot actually move and it also lights up some of the NeoPixel LEDs around the edge of the robot.

The first command in the forever loop is show leds. You need to use this command every time you want the LEDs to change state.

The first if statement is checking to see if the variable A is equal to 1 (i.e. button A is pressed). If A = 1 then the pixel at address 0 is set to green. Don't forget, it won't actually change colour until the program gets back to the show command.

The drive block controls the speed and direction of the left motor – a positive number makes it go forwards and a negative number makes it go backwards. If A does not equal 1, then the button is not pressed so the speed is set to zero so the wheel stops and the pixel is set to red.

8

The second if statement is almost identical to the first, but it looks to see if the B button is pressed and controls the right wheel rather than the left.



Light seeking

One of the sensors that the Bit:Bot robot has is a pair of light sensors. These can be found on the top of the robot on either side, just in front of the LEDs.

The light sensors return a value of between 0 (pitch black) and 1024 (daylight). The readings from these sensors can be used to make a robot that follows a bright light, the torch on a smartphone for example.


Downloads

Download the .hex files for this Bit:Bot program below. You can open these files in the micro:bit Javascript Blocks Editor here.

microbit-SimpleLightFollow.hex
This is the most basic light seeking program using just 2 blocks.

microbit-SimpleLightFollow2.hex
Slightly more advanced light following with threshold to trigger movement and sharper turns.

microbit-AdvancedLightFollow.hex
Try out this more advanced program which also uses the addressable LEDs as a bar graph to show the light level on each of the two sensors.

Here is a really simple example:

If the light is stronger on the right-hand sensor, the left-hand wheel turns faster which makes the robot turn right (towards the light). If the light is stronger on the left sensor, the right wheel turns faster and the robot turns to the left.

With the light in the middle and so equal on both sensors, the robot will drive straight. It’s not particularly agile, but it works. Let’s try making it more agile:

Firstly, we initialise a variable called threshold. You can play with the value of this to see what effect it has, but for now set it at 500.

In the forever loop, the first thing we do is check that the value of both sensors added together is greater than our threshold. If it isn't, the robot won't move at all.

If the light level is great enough, the robot then checks which light sensor has the greatest value and moves towards it.