Skip to main content

1.2

by Tech Camp

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.
    • 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 the space marked a1

    • And the Green side into the space marked b1

    • Plug the motors in as before.

  3. The green and red LEDs are both outputs
    • The green and red LEDs are both outputs

    • An output is the name for anything that can be controlled by the Crumble 'brains' of your robot

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

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

    • The output is a1 (a one) NOT aL!

  4. In the previous step, we used a new function called pinMode
    • In the previous step, we used a new function called pinMode

    • Before we can use a pin, we need to say what type of thing we are going to use it for.

    • The pinMode functions has two inputs:

    • The pin you want to use - in this case, a1

    • What you want to use it for - for the moment, we'll just be using OUTPUT.

    • Don't forget the semicolon ( ; ) after you use the function!

  5. We also used another new function, digitalWrite()
    • We also used another new function, digitalWrite()

    • This function allows us to set any output HIGH or LOW. It takes 2 inputs:

    • The output to change - this can be a1, b1, c1 or d1. Look carefully at the circuit board and you will see them marked next to the connectors!

    • What you want to change it to - this can be HIGH (on) or LOW (off)

    • Don't forget - this line does something so you must have a semicolon ( ; ) after it!

    • Try changing the code so the green LED turns on instead. The green LED should be connected to b1!

  6. We can use lots of digitalWrites to turn things off and on whenever we like!
    • We can use lots of digitalWrites to turn things off and on whenever we like!

    • Using digitalWrite and delay functions, write some code in the setup that:

    • Turns on the green LED

    • Waits 1 second

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

    • Waits 1 second

    • Turns off the red LED

  7. Load up your program that crosses the planet, picks up the astronaut, turns and drives back.
    • Load up your program that crosses the planet, picks up the astronaut, turns and drives back.

    • Add some digitalWrite lines 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

    • 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