Little Robot Friends
Arduino Library Reference
version 1.1
|
This tutorial uses example code found in:
MyLRF05_MoreEventHandlers.cppNow that you know how to create your own custom event handler, it’s time to make multiple event handlers so you can create your own set of unique responses for your Little Robot Friend.
Call the LRF Library and include the setup and loop:
Now create a few light patterns and sounds for the event handlers:
As you can see, we’ve only created one array of sounds. This is because we’ll just be using the same sound for each event handler we’ll be making.
Now we just need to make our own event handler functions. Don’t forget to put in the expressions:
We’ve made two, just to show the difference in events. In the setup()
we need to connect our event handlers:
The events that we have chosen to customize are the tap, where you tap or poke the robot hair, and the tickle, where you tap or poke the hair multiple times. As you can see, in order to customize a different event you need to have a different setEventHandler() function for each one. Take a look at the LRFEvent for even more customizable events.
Now all you need to do is upload the code and test out the new event types you have created.