Skip to main content

Introduction

Our robot isn't very useful if it can't tell us how its mission is going. Let's learn about outputs and use some LEDs so it can talk back to us!

  1. All robots have some way of telling the user what they are doing This is called feedback - it is very important as it is very hard to understand what your robot is doing without it!
    • All robots have some way of telling the user what they are doing

    • This is called feedback - it is very important as it is very hard to understand what your robot is doing without it!

    • Take a washing machine for example - they always have lights on the front to tell you what is going on.

    • What about a robot hoover - they have feedback to say when they've finished, or when they need recharging

  2. Let's add some LEDs to our robot so we can get some feedback about the mission. Add the LED module to your robot like the picture.
    • Let's add some LEDs to our robot so we can get some feedback about the mission.

    • Add the LED module to your robot like the picture.

    • Plug the Red side into P1

    • And the Green side into P0

  3. The green and red LEDs are both outputs An output is the name for anything that can be controlled by your robot
    • The green and red LEDs are both outputs

    • An output is the name for anything that can be controlled by your robot

    • Outputs can be set to either ON or OFF - there is no in between! In electronics, we call on 1, and off 0.

    • To control outputs on the micro:bit, we use a digital write block - drag one in from the pins menu (you will have to click the advanced tab to find it).

    • Copy the program in the picture and upload it to your robot. The green LED should light up!

  4. We can use the digital write block to set any of the connections (P0, P1, P2, P8, P12) to 1 or 0 (on or off). You can change the connection and whether it is 0 or 1 by clicking them, just like the other blocks.
    • We can use the digital write block to set any of the connections (P0, P1, P2, P8, P12) to 1 or 0 (on or off).

    • You can change the connection and whether it is 0 or 1 by clicking them, just like the other blocks.

    • Try changing the program so the red LED turns on!

  5. We can use lots of digital write blocks to turn things on (and off) whenever we like!
    • We can use lots of digital write blocks to turn things on (and off) whenever we like!

    • Make a program that:

    • Turns on the green LED

    • Pauses for 1 second

    • Turns off the green LED, and turns on the red LED

    • Pauses for 1 second

    • Turns off the red LED

  6. The micro:bit also has an LED screen built into it, which is great for giving feedback as it can show lots of different things.
    • The micro:bit also has an LED screen built into it, which is great for giving feedback as it can show lots of different things.

    • Have a look in the Basic menu for some blocks that can control the screen -you can display text, numbers, icons and even custom designs!

    • Try out some of the blocks to see what they can do.

    • We won't use the screen much in these tutorials, however feel free to use it whenever you like to improve your programs, or add extra features to make things better!

  7. Load up your program that crosses the planet, picks up the astronaut, turns and drives back. Add some digital write blocks to turn on the red LED before the astronaut is picked up, then the green one after they are picked up and when the robot is driving back.
    • Load up your program that crosses the planet, picks up the astronaut, turns and drives back.

    • Add some digital write blocks to turn on the red LED before the astronaut is picked up, then the green one after they are picked up and when the robot is driving back.

    • Let's use the screen as well - show a Sad Face before you pickup the astronaut, and a Happy Face when you have picked them up!

    • Now your robot is giving some real feedback, so you can see from your base when it has picked up the astronaut!

Finish Line

Tech Camp

Member since: 10/03/2012

119 Guides authored

Team

Tech Camp Staff Member of Tech Camp Staff

6 Members

140 Guides authored