🔌Arduino to Misty
In this project, you will use Arduino to trigger Misty to change the colour of her chest LED.
Last updated
In this project, you will use Arduino to trigger Misty to change the colour of her chest LED.
Last updated
Misty’s Arduino backpack
2 buttons
2 LEDs
2 resistance 330 Ω
2 resistance 10 kΩ
Some wires of different lengths.
The Arduino code is composed of two parts: the void setup and the void loop. The first one will run only once at the beginning and here you set all your variables. The second part will run in a loop until stopped.
In this void setup, you open the serial and set the pins you’ll use in this project. In the void loop, you associate the pins to our buttons and then we set two conditions:
If the green button is pressed you’ll turn on the green LED on the Arduino board and you will write in the serial the word “green” if this doesn’t happen the green LED will be off. It happens the same with the blue button as you can read in the code. At the end, we insert a pause in order not to send too many signals to Misty.
To allow Misty to read in the Serial you need to build an event, so you can import the usual libraries that Misty uses to register events. Then we create the robot and the function that will be called with the event.
In this function we read the serial message and if the condition is verified Misty will complete the function. If we press the green button, Arduino will write “green” in the serial and Misty will register “green” as message from the serial port, so she’ll act as shown in the function.