Sensor triggered random color/sound drawing

Modified on Tue, 09 May 2023 at 03:58 PM

This feature is available in the Photon Blocks interface only.

It is extremely useful in activities where you want to use the robot to draw random colors or sounds (and assign them a specific meaning). The example below shows in detail how to change the colors of the robot’s eyes and ears. In a similar way, you can program randomization of sounds and triggering actions.

How does the sample program work?
When touched on the head, the robot changes the color of its eyes and ears to a randomly drawn color from a selected pool of 6 colors. Three (3) seconds after drawing, the eyes and ears turn off – the robot waits for another draw triggering action.


How to activate the draw?
1. If you want the Photon Robot to start drawing colors, it must detect a trigger action, such as a touch on the head – add a “Wait” block to your program (place it at the beginning of your program).
2. You can find the “Wait” block in the blocks’ third category (robot’s head icon). The default setting for this block is 1 second. Click on it to open an additional menu.
3. A list of all possible sensor triggers comes up. Select the third symbol (a hand
above the robot’s head).
4. Then move the slider towards the hand symbol (meaning: draw when you detect touch).
5. When you start the program using the “Play” button, the robot will wait for your specified action. Detected touch activates the random color draw. To draw a color again, you must restart the program or use "Repeat the program over and over again feature".




Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article