Little Robot Friends | lrf
The Little Robot Friends Arduino library consists of a variety of functions that allow you to code the robot's behavior. You can create custom expressions, code songs and make use of the different inputs and outputs that the robot has built-in.
This is the top-level of the library. Functions for everything from making the eyes blink to using the speaker or enabling/disabling inputs and outputs are included here.
Functions called from within the core functions of the library have the prefix of "lrf"
Robot Level
setup()
Description
This function initiates the LRF library. It is required for the basic functioning of the robot. It must be called from the "setup" portion of the Arduino sketch.
Examples
void setup(){
lrf.setup();
}
Syntax
setup()
Parameters
none
Returns
none
Notes
none
loop()
Description
This function services the LRF library. It is required for the basic functioning of the robot. It must be called from the "loop" portion of the Arduino sketch.
Examples
void loop(){
lrf.loop();
}
Syntax
loop()
Parameters
none
Returns
none
Notes
none
setBoredomTimer()
Description
This function sets the duration at which the robot will enter sleep mode. It requires that the user provide the duration in seconds. Setting the duration to a value of 0 will disable the boredom function and prevent the robot from entering sleep mode.
Examples
Setting a custom duration:
lrf.setBoredomTimer(120);
Disabling boredom entirely:
lrf.setBoredomTimer(0);
Syntax
setBoredomTimer(seconds)
Parameters
seconds
: unsigned int - the number of seconds to wait before the robot will begin to snore and enter sleep mode.
Returns
none
Notes
none
Expressions
blinkAndSay()
Description
This function will make the robot perform a user defined expression.
Examples
lrf.blinkAndSay(*myExpression);
Syntax
blinkAndSay(expression)
Parameters
expression
: LRFExpression* type - A pointer to the expression that the user wants to play.
Returns
none
Notes
This function makes use of the pointer symbol. *
blinkAndSayPreset()
Description
This function makes the robot perform a preset expression.
Examples
lrf.blinkAndSayPreset(LRFExpression_Hello);
Syntax
blinkAndSayPreset(expression)
Parameters
expression
: LRFExpressionName preset - The expression that the user wants to play.
Returns
none
Notes
none
setExpressionPreset()
Description
This function overrides a preset expression.
Examples
lrf.setExpressionPreset(LRFExpression_Hello, *myExpression);
Syntax
setExpressionPreset(expressionName, newExpression)
Parameters
expressionName
: LRFExpressionName preset - The expression that the user wants to reassign.newExpression
: LRFExpression* - A pointer to the new expression you wish to assign.
Returns
none
Notes
none
isExpressing()
Description
This function determines if the robot is currently performing an expression. It returns a value of 'true' if the robot is expressing.
Examples
if (lrf.isExpressing() == true){
lrf.eyes.clear();
}
Syntax
isExpressing()
Parameters
none
Returns
bool
Notes
none
Chat
chat()
Description
This function causes the robot to emit a series of "chat" sounds, this gives the effect of the robot talking in its tonal language.
Examples
lrf.chat();
Syntax
chat()
Parameters
none
Returns
none
Notes
none
stopChatting()
Description
This function will stop the the robot from "chatting" or speaking in its tonal language if the chat()
function has been called.
Examples
lrf.stopChatting();
Syntax
stopChatting()
Parameters
none
Returns
none
Notes
none
Singing
sing()
Description
This function will make the robot sing a user-defined song.
Examples
lrf.sing(*mySong);
Syntax
sing(song)
Parameters
song
: LRFSong* type - A pointer to the song that the user wants to play.
Returns
none
Notes
This function makes use of the pointer symbol. *
stopSinging()
Description
This function stops the robot from singing, if it is currently doing so.
Examples
lrf.stopSinging();
Syntax
stopSinging()
Parameters
none
Returns
none
Notes
none
Inputs
enableInputs()
Description
This function enables the inputs of the robot: microphone, touch, light and motion. They are enabled by default.
Examples
lrf.enableInputs();
Syntax
enableInputs()
Parameters
none
Returns
none
Notes
none
disableInputs()
Description
This function disables the inputs of the robot: microphone, touch, light and motion.
Examples
lrf.disableInputs();
Syntax
disableInputs()
Parameters
none
Returns
none
Notes
none
Outputs
enableOutputs()
Description
This function enables the outputs of the robot: speaker and LEDs. They are enabled by default.
Examples
lrf.enableOutputs();
Syntax
enableOutputs()
Parameters
none
Returns
none
Notes
none
disableOutputs()
Description
This function disables the outputs of the robot: speaker and LEDs.
Examples
lrf.disableOutputs();
Syntax
disableOutputs()
Parameters
none
Returns
none
Notes
none
Events
enableEvents()
Description
This function enables the event system. This allows for the various interactions with the inputs and outputs. They are enabled by default.
Examples
lrf.enableEvents();
Syntax
enableEvents()
Parameters
none
Returns
none
Notes
none
disableEvents()
Description
This function disables the event system. This prevents various interactions with the inputs and outputs.
Examples
lrf.disableEvents();
Syntax
disableEvents()
Parameters
none
Returns
none
Notes
none
fireEvent()
Description
This function "fires" a desired event.
Examples
lrf.fireEvent(myEvent);
Syntax
fireEvent(event)
Parameters
event
: LRFEvent type - The event name that you want to fire.
Returns
none
Notes
none
setEventHandler()
Description
This function sets the event handler for a certain event. It overrides any proceeding event assignment, included default events.
Examples
lrf.setEventHandler(LRFEvent_Tickle, myEventHandler);
Syntax
setEventHandler(event, eventHandler)
Parameters
event
: LRFEvent type - The event that you want to mapeventHandler
: LRFEventHandler Type - The event handler, a section of code that executes when the event occurs.
Returns
none
Notes
none
enableEventExpressions()
Description
This function enables the expressions that occur when events are fired. They are enabled by default.
Examples
lrf.enableEventExpressions();
Syntax
enableEventExpressions()
Parameters
none
Returns
none
Notes
none
disableEventExpressions()
Description
This function disables the expressions that occur when events are fired.
Examples
lrf.disableEventExpressions();
Syntax
disableEventExpressions()
Parameters
none
Returns
none
Notes
none
setEventExpression()
Description
This function maps an expression to an event.
Examples
lrf.setEventExpression(LRFEvent_Tickle, LRFExpression_Hello);
Syntax
setEventExpression(eventName, expressionName)
Parameters
eventName
: LRFEvent type - The name of the event you are mapping the expression to.expressionName
: LRFExpressionName Type - The name of the expression you wish to map.
Returns
none
Notes
none