In this example we're going to get to know the following method better:
bob3.setLed(id, color);
Up until now, we've used the method, for example, to turn eye 1 on in white:
bob3.setLed(EYE_1, WHITE);
Now, we will take a closer look!
In the blue sidebar on the left you can find all the different methods available to your BOB3.
If you hover over a method with your cursor, a popup will show you information about the method.
Try it out with the method bob3.setLed(id, color);
The method bob3.setLed(id, color);
has two parameters: id and color
In place of the id you can use one of the four constants
EYE_1
, EYE_2
, LED_3
or LED_4
or the LEDs number,
i.e. 1
, 2
, 3
or 4
.
For color you can use a color constant, e.g.
WHITE
or a hexadecimal color value, e.g. 0xD13
.
Compile the program and test it on your BOB3.
What does the programme do?
Add the following line:
bob3.setLed(3, WHITE);
Recompile the program and test it on your BOB3.
Add another line of code to make the second tummy LED light up white!
Compile your new program and test it on your BOB3.