Little Robot Friends
Arduino Library Reference  version 1.1
MyLRF03: Blink & Say

Combining Patterns and Sounds to Make Expressions

This tutorial uses example code found in:MyLRF03_BlinkAndSay.cpp

Great work! Your Little Robot Friend has learned to sing. Time to put together what you’ve learned so far in order to make something really special. Now that we have a simple understanding of making patterns and sounds, what we really want to do is combine them to make full-blown robot expressions.

There are a couple simple functions for doing this called lrf.blinkAndSay(). Once you’ve defined a pattern and a sound, you can combine them using this function. The following code is copied from the examples in Tutorials 1-3. Let’s start with a very simple combination of two colours with one sound. By now, the content and format should look pretty familiar.

After you’ve decided on the colours and sound, you can plug both variables into the lrf.blinkAndSay() function in setup().

void setup(void) // Arduino setup routine that gets called ONCE when the robot turns on
{
lrf.setup(); // lrf library should be set up before anything else
delay(1000);
lrf.blinkAndSay(myPattern, mySound); // let's try both at the same time
delay(1000); // this causes your pattern to have the same duration as your sound)
};

Once you’ve been able to get this to work we can experiment with multi-sound expressions that allow us to use an array of sounds to give our robot even more character.

Now you can add simply add a second lrf.blinkAndSay() function in void setup that can contain both your colours and your sound, or just your sound. Don’t forget to label your array!

lrf.blinkAndSay(myPattern, mySounds, 3); // let's try multiple sounds
delay(1000); // the pattern resets after each sound
};

That's it! Now you can make full-blown robot expressions. Time to get creative!

All Done? Why Not Try This...

  • make a happy and welcoming pattern
  • make a happy and welcoming sound
  • make a set of custom sounds that are all happy and welcoming
  • play around with the sounds to try and make your robot say 'hi, how ya doing?'