Little Robot Friends
Arduino Library Reference  version 1.1
MyLRF03_BlinkAndSay.cpp
1 //
2 // MyLRF03-BlinkAndSay.cpp
3 // LittleRobotFriends
4 //
5 // Created by Mark Argo on 2014-06-11.
6 // Copyright (c) 2014 Aesthetec Studio Inc. All rights reserved.
7 //
8 
9 /*
10  THIS SOFTWARE IS PROVIDED “AS IS”, WITHOUT ANY REPRESENTATIONS, CONDITIONS,
11  AND/OR WARRANTIES OF ANY KIND. WITHOUT LIMITATION, AESTHETEC STUDIO AND ITS
12  AFFILIATES, LICENSORS, SUPPLIERS, CONTRIBUTORS, SUBCONTRACTORS, DISTRIBUTORS
13  AND ALL CONTRIBUTORS DISCLAIM ANY EXPRESS OR IMPLIED REPRESENTATIONS,
14  CONDITIONS, OR WARRANTIES OF MERCHANTABILITY, MERCHANTABLE QUALITY, SATISFACTORY
15  QUALITY, NON-INFRINGEMENT, TITLE, DURABILITY, OR FITNESS FOR A PARTICULAR
16  PURPOSE, WHETHER ARISING BY STATUTE, COURSE OF DEALING, USAGE OF TRADE, OR
17  OTHERWISE. EXCEPT AS OTHERWISE PROVIDED IN THIS AGREEMENT, YOU SHALL BEAR
18  THE ENTIRE RISK FOR ANY USE OR ANY OTHER EXPLOITATION MADE BY YOU OF ANY
19  RIGHTS IN THE COVERED SOFTWARE.
20 
21  Additional copyright information found at http://littlerobotfriends.com/legal/
22 */
23 
24 //
25 
26 /*
27 
28  Tutorial #3 - Blinking and speaking at the same time (with multiple sounds).
29 
30  This sketch shows you how to create and run a custom light patterns and sounds
31  at the same time. You can also create more complex expressions with multiple
32  sounds!
33 
34  Goals:
35  - make a custom pattern
36  - make a custom sound
37  - make a set of custom sounds
38  - play around with the sounds to try and say 'hi, how ya doing?'
39 
40  */
41 
42 #include "LRF.h"
43 
44 // Create a light pattern for the eyes
45 LRFPattern myPattern = {
46  LRFColor_Blue, // starting color
47  LRFColor_Green, // target color
48  LRFPatternMode_Fade // pattern behaviour (see LRFUtils.h for more info)
49 };
50 
51 // Create a sound for the speaker
52 LRFSound mySound = {
53  LRFNote_D, // note
54  LRFOctave_6, // octave
55  LRFIntonation_Falling, // intonation (see LRFUtils.h for more info)
56  LRFDuration_Long, // note length
57  LRFDuration_None // pause length (after note has played)
58 };
59 
60 // Create an array of sounds
61 LRFSound mySounds[3] = {
64  { LRFNote_D, LRFOctave_4, LRFIntonation_Flat, LRFDuration_Long, LRFDuration_None } // <-- make sure the last entry has no comma!
65 };
66 
67 // ------------------ everything below this point runs the program --------------------
68 
69 void setup(void) // Arduino setup routine that gets called ONCE when the robot turns on
70 {
71  lrf.setup(); // lrf library should be set up before anything else
72  delay(1000);
73 
74  lrf.blinkAndSay(myPattern, mySound); // let's try both at the same time
75  // this causes your pattern to have the same duration as your sound)
76  delay(1000);
77 
78  lrf.blinkAndSay(myPattern, mySounds, 3); // let's try multiple sounds
79  delay(1000); // the pattern resets after each sound
80 }
81 
82 // Arduino loop routine that gets called OVER AND OVER while the robot runs
83 void loop(void)
84 {
85  // run the lrf library
86  lrf.loop();
87 
88  // any other functions put in here might cause the lrf to behave strange (no delays plz!)
89 }
Falling tone (sad or upset)
Definition: LRFUtils.h:221
high octave
Definition: LRFUtils.h:205
void loop(void)
run the LRF library loop
Definition: LRF.cpp:175
Allows for access of sound data as a structure or raw integer.
Definition: LRFUtils.h:307
This is the core API class for access LRF library functions.
Green.
Definition: LRFUtils.h:50
C (65hz)
Definition: LRFUtils.h:179
Flat tone (no change)
Definition: LRFUtils.h:219
A (55 hertz at octave #1)
Definition: LRFUtils.h:176
No duration (0 ms)
Definition: LRFUtils.h:236
Fade from start to target.
Definition: LRFUtils.h:95
void setup(void)
setup the LRF library
Definition: LRF.cpp:108
Base * 16 (whole note)
Definition: LRFUtils.h:241
void blinkAndSay(LRFPattern pattern, LRFSound sound)
Blink and speak at the same time.
Definition: LRF.cpp:213
Allows for access of pattern data as a structure or raw integer.
Definition: LRFUtils.h:156
D (73hz)
Definition: LRFUtils.h:181
Base * 4 (1/4 note)
Definition: LRFUtils.h:239
Blue.
Definition: LRFUtils.h:51
middle octave
Definition: LRFUtils.h:203