Activity: Conversation Bot

Use the input block to create a conversation between you and your rover. Use variables to save information in the conversation or ask the robot to do different tasks.

Relevant Coding Skills

Branching
Iteration

Relevant Rover Concepts

LEDs
Buzzer

Activity Demonstration

Setup

This exercise doesn't necessarily require a lot of space as you can choose whether the robot will move or not. There is no limit to how the conversation can work. Try and involve things like LEDs and Sounds from the rover. This often leads to needing to use variables, branching, loops, and functions.

 

Here’s Our Approach

This example code is not the only conversation that can be had with the rover. This just demonstrates how you can use the input block with variables and if statements. This can be easily extended with loops, motors, sensors, and functions.

Stage 1

Use the request input block to greet the user and then ask which colour they prefer. We can use a print block with string concatenation to say hello. Make sure to store the inputs in well-named variables to make your code easy to read.

Stage 2

Use an IF statement to check whether the response is something we understand and the ELSE branch to say when we don’t understand. Use a set all LEDs block to set the colour of the LEDs when we get a response we understand

Stage 3

Add more responses to the IF statement as ELSE IF (ELIF) branches.

Example Code

Example Code

 

Related Posts

Previous
Previous

Activity: Lane Guidance

Next
Next

Activity: Colourful Sounds