• Topic 2: Sensing (including selection and repetition)

    Robot Image
    This lab is broken down into 7 activities

    As in the previous lab, you do NOT need to do the mini challenges in each activity. All other parts should be undertaken unless specifically detailed in the description for that activity.
  • Activity 1: Encoders Exercise

    This first activity gets you to take more control over the motors of the robot by controlling each motor individually using the setMotorSpeed() command.

    🔗 Encoder

  • Activity 2: Touch Sensor

    In this activity you will be starting to use the external sensors to control the behaviour of the robot. In other words the robot will be influenced by what is happening to it.

    There is a lot of content and new concepts introduced in this activity. Take your time working through it and please ask questions to be sure that you understand what is happening.

    There is additional content in this activity covering Boolean logic. Take time to go over this as well and to download the fact sheet. An understanding of basic Boolean logic is critical to your ability to program the robot to behave in different ways depending on the outcomes of tests. This underpins the way the robot makes “decisions”.

    🔗 Touch Sensor
  • Activity 3: Distance Sensor

    This is almost the same activity as in activity 2 but uses the Ultrasonic Sensor to detect when it is near an obstacle rather than waiting until it touches the obstacle.

    🔗 Distance Sensor
  • Activity 4: Gyro Sensor

    Again this builds on activity 2 but introduces the Gyro Sensor. It also introduces the concept of data being retained in some sensors until reset. The Try It exercise highlights this and shows how a program can sometimes compile and run but not behave in a way you would expect.

    🔗 Gyro Sensor
  • Activity 5: Colour Sensor (conditionals)

    While this activity introduces the colorSensor the more important part is the first use of the “IF- ELSE” statement. This brings in the capability for the program to do different things depending on the input received at the time. This is a fundamental element of programming so please make sure that you are comfortable with the concept and the way the code is written. As always, if you are unsure, please ask questions and take time to go over all of the content.

    Note: Robot uses the American spelling of “color” in the code. If you use the UK English spelling of “colour” the program will not recognise it.

    🔗 Colour Sensor
  • Activity 6: Colour Sensor (Repeat Behaviours)

    This activity integrates the REPEAT loop from lab 1 with the IF ELSE from activity 5 in this lab. It allows a seemingly complex behaviour to allow the robot to navigate a maze to be built out of the repetition of a simple decision structure.

    It is important that you not only become comfortable with the code but also pay attention to how the problem of navigating the maze is solved. This is introducing the problem solving approach to programming that we will be building on in subsequent exercises.

    Note: The REPEAT command is not standard C but is specific to Robot C (natural language). Later in the module we will introduce the standard C loop structures which also work in Robot C.

    🔗 Colour Sensor
  • Activity 7: Colour Sensor (Line Tracking)

    This final activity uses the REPEAT and IF-ELSE structures to build a very different but useful capability for a robot, the ability to follow a track. If you understood activity 6 then this should be relatively straightforward for you.

    🔗 Colour Sensor
  • Summary

    This Lab has introduced some key elements to programming robots. You are now able to get values from a range of sensors. You can also use selection structures (IF-ELSE) to change how the robot behaves depending on the inputs from those sensors. By using repetition structures (loops like REPEAT and REPEATUNTIL), you are able to get the robot to keep doing a task.

    You have also covered Boolean logic and how it is applied to the test conditions used in the selection and repetition structures.

    There is a lot of content in this lab. Please make sure that you are comfortable with the concepts and the code before moving on. As always, please ask questions.