A guide on how to get up and running quickly with the K8 robot from Insksmith

WHAT IS K8?

K8 is a two-wheeled programmable robot powered by the micro:bit. The electronic components within K8 are easy to use and designed for beginners.

WHAT IS INSIDE K8?

  • 2 x DC motors
  • 1 x Line follower made up of 3 infrared sensors
  • 1 x ultrasonic sensor (used for object detection)
  • 2 x Servo motors

PROGRAMMING K8

To program K8 we first need to open the MakeCode editor into your chosen web browser. Click on a new project, within the programming menu click on Advanced. Scroll to the bottom and click on Extensions, within the search bar at the top type K8 and click on the image of "K8".

K8 Extension

CONTROLLING THE MOTORS

Now that we have got up and running with MakeCode we can start programming!

  1. Click on Input, click and drag an on button A pressed to the coding area and drop it.
  2. Click on motion, click and drag drive straight speed 0 to the coding area and attach it within on button A pressed.
  3. Click on 0 and type 50.
Code to make K8 Drive in a straight line
  1. Click on Download to download the code file to the micro:bit. Once the light on the back of the micro:bit has stopped blinking unplug the micro:bit from the computer and attach it to K8.
Meet K8

urn the battery pack and controller board on, put K8 on the floor and press button A on the micro:bit. K8 should now start driving forward.

Let's see what else K8 can do.

Modify your code to look like this:

Making K8 Drive

LINE FOLLOWING

The infrared sensors point downwards and detect light and dark surfaces.

To make our track we will want to use black electrical tape on a white surface and make sure it is a closed-loop.

Closed Loop Track for K8 to drive around

CONFIGURING THE LIGHT SENSORS

  1. Turn K8 upside down so the sensors are pointing upwards.
Infrared (IR) sensors detecting light and dark
  1. Turn the dial clockwise until the red signal light on the IR (infrared) sensor turns on.
  2. Very gently turn the dial counter-clockwise until the red light turns back off, this makes sure the sensitivity of the sensor is maximised and the sensor can tell the difference between black and white.
  1. Repeat for the steps above for the other two sensors.
  2. Create the following program to test the sensors.
Code for testing IR sensors

Download the code to the micro:bit, once the light on the back of the micro:bit has stopped blinking unplug the micro:bit from the computer and connect it onto K8.

  1. Place K8 on a white surface, if the sensors are calibrated correctly the first, third and fifth column of LEDs on the micro:bit should light up.
Line 1, 3, and 5 indicate IR sensors 1, 2 and 3. (NOTE: my sensor 2 is faulty)
  1. If this doesn't work repeat steps one and two.
  2. Place a bit of black electrical tape on the white surface and slowly sweep K8 over the line. The columns of LEDs should turn off when the corresponding sensor sees the black tape.

TESTING THE TRACK

  1. Create a closed-loop track using black electrical tape on a white surface.
  2. Create the following code to test your track.
Code to make K8 drive around the track

OBJECT DETECTION

K8's eyes may look similar to ours with being two round holes, but they behave very differently. K8's eyes behave more like the way a bat or dolphin would detect objects within their habitat using echolocation. Echolocation is where properties of sound are used to bounce signals off of objects and judge how far away the objects are.

Copy the code below to test K8's sonar and make sure it is detecting objects correctly.

Test code for Sonar sensor

Place K8 in front of a wall, move K8 closer to the wall and further away from the wall. The LEDs on the micro:bit should be changing, this shows that the sonar sensor is working and K8 is detecting objects.

Here is some sample code to show K8 detecting and avoiding objects.

Code for object detection

USING RADIO

We are going to use the radio function on the micro:bits so we can introduce a second micro:bit to control K8.

Here is the example code for the controller:

This is the code for the micro:bit controlling K8

Here is the example code for K8:

This is the code that goes on the micro:bit plugged into K8

CONCLUSION

We have covered the basics of programming K8. You can now go and explore with K8 and MakeCode to see what else K8 can do!