This library is archived and is no longer being maintained. It can be still be downloaded and used, but is read-only and cannot be contributed to. Furthermore, the Robot Library now exists as three separate libraries: Robot_Control, Robot_Motor and RobotIRremote.
The Robot library is included with Arduino IDE 1.0.5 and later.
The Robot has a number of built in sensors and actuators. The library is designed to easily access the robot's functionality.
The robot has two boards, a motor board and control board. Each board has a separate programmable processor.
The library allows you to interface with the various sensors and peripherals on the control board :
The library also enables you to do a number of things with the motor board :
For more information about the Robot, visit the getting started guide and the hardware page.
This library enables easy access to the functionality of the Arduino Robot. It relies on a number of 3rd party libraries including Fat16, EasyTransfer, Squawk, and IRRemote. It also relies on a number of Arduino libraries like TFT, SPI, and Wire. Their functionality has been replicated inside the robot's library to optimize the code's size.
It is possible to program both the Control and the Motor boards. However, it is recommended that novice programmers begin with programming the control board, leaving the motor board for later. The library exposes the sensors on both boards through a single object.
There are two main classes that command the robot:
You can find examples for this library in the Examples from Libraries page.
RobotControl
The constructor is empty. As the methods can be accessed through the Robot object directly, you don't need to call the constructor.
none
none
1#include <ArduinoRobot.h>2void setup(){3 //methods can be accessed directly through Robot4 Robot.begin();5 Robot.motorsWrite(255,255);6}7void loop(){8}
begin()
Initializes the robot. Must be called in setup() to use Robot-specific features.
Robot.begin() does not initialize features like sound, the LCD module, or the SD card. Refer to the links in the "See also" section for reference on initializing these other modules.
1Robot.begin()
none
none
1#include <ArduinoRobot.h>2void setup(){3 Robot.begin();4 //do stuff here5}6void loop(){7 //do stuff here8}
setMode()
Change the robot's mode. Depending on the mode it is currently in, the commands may change.
1Robot.setMode(modeName)
none
1#include <ArduinoRobot.h>2void setup(){3 Robot.begin();4 Robot.setMode(MODE_LINE_FOLLOW);5}6void loop(){7
8}
pauseMode()
Pause or resume the mode-specific action for the bottom board.
For line-following mode, the robot will stop following the line, but still receiving commands.
1Robot.pauseMode(onOff)
onOff: boolean. true pauses the mode, false resumes it.
none
1#include <ArduinoRobot.h>2long timer;3
4void setup(){5 Robot.begin();6 Robot.beginLCD();7 delay(3000);8
9 Robot.setMode(MODE_LINE_FOLLOW);10 timer=millis();11 while(!Robot.isActionDone()){12 //pauses line-following for 3 seconds every 5 seconds13 if(millis()-timer>=5000){14 Robot.pauseMode(true);15 delay(3000);16 Robot.pauseMode(false);17 timer=millis();18 }19 Robot.debugPrint(millis());20 }21 Robot.text("Done!",0,10,true);22 while(true);23
24}25void loop(){26}
isActionDone()
Checks if the current motor board mode action is finished.
Line-following mode will report an action completed signal when it reaches a finishing line (a perpendicular line).
1Robot.isActionDone()
none
boolean
1#include <ArduinoRobot.h>2long timer;3
4void setup(){5 Robot.begin();6 Robot.beginLCD();7 delay(3000);8
9 Robot.setMode(MODE_LINE_FOLLOW);10 timer=millis();11 while(!Robot.isActionDone()){12 //pauses line-following for 3 seconds every 5 seconds13 if(millis()-timer>=5000){14 Robot.pauseMode(true);15 delay(3000);16 Robot.pauseMode(false);17 timer=millis();18 }19 Robot.debugPrint(millis());20 }21 Robot.text("Done!",0,10,true);22 while(true);23
24}25void loop(){26}
lineFollowConfig()
Change the parameters for line following.
Use this function if line-following is not working as expected, or you want to change the robot's speed while line-following.
This function changes the "PD algorithms" that enable to robot to think about what may happen next while line reading. The robot attempts to predict any possible errors on the next reading of the IR sensors, and corrects its movement accordingly by changing the speed of each wheel separately.
See the note below for a deeper explanation.
1Robot.lineFollowConfig(KP,KD,robotSpeed,intergrationTime)
none
1#include <ArduinoRobot.h>2long timer;3
4void setup(){5 Robot.begin();6 Robot.beginLCD();7 delay(3000);8
9 Robot.lineFollowConfig(11,5,50,10);//set PID10 Robot.setMode(MODE_LINE_FOLLOW);11 timer=millis();12 while(!Robot.isActionDone()){13 //pauses line-following for 3 seconds every 5 seconds14 if(millis()-timer>=5000){15 Robot.pauseMode(true);16 delay(3000);17 Robot.pauseMode(false);18 timer=millis();19 }20 Robot.debugPrint(millis());21 }22 Robot.text("Done!",0,10,true);23 while(true);24
25}26void loop(){27}
digitalRead()
Reads the digital value one the defined port. These are exposed as TinkerKit connectors on the robot. See the diagrams below for pin locations
1Robot.digitalRead(portName)
port: Valid names are TK0 to TK7 (found on the Control board), TKD0 to TKD5 (on the Control board), and B_TK1 to B_TK4 (on the Motor Board).
HIGH or LOW
1#include <ArduinoRobot.h>2void setup(){3 Robot.begin();4 Serial.begin(9600);5
6}7void loop(){8 Serial.println(Robot.digitalRead(TK0)); //Print the value read on port TK09 delay(100);10}
digitalWrite()
Write a HIGH or a LOW value to the defined port on the robot. the ports are exposed on the robot as TinkerKit connectors.
1Robot.digitalWrite(port, value)
port: TKD0 to TKD5 (on the Control board), B_TK1 to B_TK4(on the Motor Board), or LED1 (located on the control board)
value: HIGH or LOW
none
1#include <ArduinoRobot.h>2void setup(){3 Robot.begin();4}5
6void loop(){7 Robot.digitalWrite(TDK0, HIGH); // Turn on a Tinkerkit LED connected to TDK08 delay(1000);9 Robot.digitalWrite(TK0, LOW); // Turn the LED off10 delay(1000);11}
You cannot call Robot.digitalWrite() on TK0 to TK7
analogRead()
Reads the value from the specified port on the robot. The ports are exposed on the robot as TinkerKit connectors.
The board has a 10-bit analog to digital converter. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1023.
1Robot.analogRead(port)
port: TK0 to TK7 (found on the Control Board), TKD0 to TKD5 (found on the Control Board), or B_TK1 to B_TK4 (found on the motor Board)
int : 0 to 1023
If the input port is not connected to anything, the value returned by Robot.analogRead() will fluctuate based on a number of factors (e.g. the values of the other analog inputs, how close your hand is to the board, etc.).
1#include <ArduinoRobot.h>2
3void setup(){4 Robot.begin();5 Serial.begin(9600);6}7
8void loop(){9 Serial.println(Robot.analogRead(TK0)); //Print the value on port TK010 delay(100);11}
analogWrite()
Writes an analog value as PWM to the specified port on the robot. The board has a 8-bit PWM, allowing for 256 discrete levels.
Robot.analogWrite() only works on TKD4, located on the Control Board. It cannot be used at the same time as TK0 through TK7.
1Robot.analogWrite(port, value)
port: TKD4
value : 0 to 255
none
1#include <ArduinoRobot.h>2
3void setup(){4 Robot.begin();5 Serial.begin(9600);6}7
8void loop(){9 for(int x=0;x<256;x++){10 Robot.analogWrite(TKD4, x); //increase brightness of an LED on TK011 delay(20);12 }13}
updateIR()
Reads the values of the 5 IR line-reading sensors on the underside of the robot and stores the values in an array. This array can be accessed through Robot.IRarray[]. This function needs to be called from the Control Board.
To obtain the reading from a specific IR sensor, use IRRead() on the Motor Board.
none
Robot.IRarray[] : contains the values of the 5 sensors
1#include <ArduinoRobot.h>2
3void setup(){4 Robot.begin();5 Serial.begin(9600);6}7
8void loop(){9 Robot.updateIR(); // update the IR array10 for(int i=0;i<=4;i++){11 Serial.print(Robot.IRarray[i]); // print the values to the serial port12 Serial.print(",");13 }14 Serial.println("");15 delay(100);16}
knobRead()
Gets the analog value as a 10-bit value from the on-board potentiometer. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1023.
1Robot.knobRead()
none
int: 0 to 1023
1#include <ArduinoRobot.h>2
3void setup(){4 Robot.begin();5 Serial.begin(9600);6
7}8void loop(){9 Serial.println(Robot.knobRead());10 delay(100);11}
compassRead()
Get the current direction from on-board compass. The values are degrees of rotation from north (in a clockwise direction), so that east is 90, south is 180, and west is 270.
1Robot.compassRead()
none
int: 0 to 359, representing the number of degrees of rotation from north.
The compass module may be disrupted by magnetic fields in surrounding areas.
1#include <ArduinoRobot.h>2
3void setup(){4 Robot.begin();5 Serial.begin(9600);6
7}8void loop(){9 Serial.println(Robot.compassRead());10 delay(100);11}
keyboardRead()
Detects if one of the 5 momentary buttons on the control board is pressed.
1Robot.keyboardRead()
none
1#include <ArduinoRobot.h>2
3void setup(){4 Robot.begin();5 Serial.begin(9600);6}7
8void loop(){9 Serial.println(Robot.keyboardRead());10 delay(100);11}
waitContinue()
Pauses the current program and waits for a key press from one of the 5 momentary buttons. Once you press the key, the program continues.
1Robot.waitContinue()2Robot.waitContinue(key)
key: the momentary switch to listen for. The default value is BUTTON_MIDDLE. Valid choices are
none
1#include <ArduinoRobot.h>2
3void setup(){4 Robot.begin();5 Robot.waitContinue();//stop the robot, and wait for the middle button to be pressed6}7
8void loop(){9 Robot.motorsWrite(255,255);10 delay(2000);11 Robot.motorsWrite(0,0);12 delay(2000);13}
motorsWrite()
Controls the speed and direction of the two motors connected to the robot's wheels. motorsWrite() needs values between -255 and 255. If the value is greater than 0, the wheel turns forward. If less than 0, the motor turns backwards.
1Robot.motorsWrite(speedLeft, speedRight)
none
1#include <ArduinoRobot.h>2
3void setup(){4 Robot.begin();5}6void loop(){7 Robot.motorsWrite(255,255); //Make the robot go forward, full speed8 delay(1000);9 Robot.motorsWrite(0,0); //Make the robot stop10 delay(1000);11 Robot.motorsWrite(255,-255);//Make the robot rotate right, full speed12 delay(1000);13 Robot.motorsWrite(0,0); //Make the robot stop14 delay(1000);15}
motorsStop()
Stop both motors of the robot.
1Robot.motorsStop()
none
none
1#include <ArduinoRobot.h>2
3void setup(){4 Robot.begin();5}6void loop(){7 Robot.motorsWrite(255,255); //Make the robot go forward, full speed8 delay(1000);9 Robot.motorsStop(); //Fast stop the robot10 delay(1000);11 Robot.motorsWrite(255,-255);//Make the robot rotate right, full speed12 delay(1000);13 Robot.motorsWrite(0,0); //Slow stop the robot14 delay(1000);15}
You can as well stop the motors by calling Robot.motorsWrite(0,0). Difference is, after the later is called, the motors may still move a little due to momentum(so called slow stop). Robot.motorsStop() will stop the motors and make them stiff, so stop instantly.
turn()
Make the robot turn a certain number of degrees from its current orientation. The current position is derived from the onboard compass.
1Robot.turn(degrees)
degrees:-180 to 180. Positive number for turning right, negative number for turning left.
none
Magnetic objects in the surrounding may disrupt the compass module. Keep magnets, such as strong speakers, away from the robot.
1#include <ArduinoRobot.h>2
3void setup(){4 Robot.begin();5}6void loop(){7 Robot.turn(90); //Make the robot turn 90 degrees right8 delay(1000);9}
pointTo()
Make the robot point in a particular direction. pointTo() makes the robot face an absolute direction based on the compass.
1Robot.pointTo(degrees)
degrees:0 to 359.
none
Magnetic objects in the surrounding may disrupt the compass module. Keep magnets, such as strong speakers, away from the robot.
1#include <ArduinoRobot.h>2
3void setup(){4 Robot.begin();5 Robot.pointTo(90); //The robot will turn to 90, by the value of compass6}7void loop(){8}
beginSpeaker()
Initializes the speaker and sound libraries. Must be included in setup().
1Robot.beginSpeaker()
none
none
1#include <ArduinoRobot.h>2
3void setup(){4 Robot.begin();5 Robot.beginSpeaker();//Initialize the sound module6}7
8void loop(){9 char aTinyMelody[] = "8eF-FFga4b.a.g.F.8beee-d2e.1-";// This is what we will play10 Robot.playMelody(aTinyMelody);// Play the melody11
12}
playMelody()
Plays a melody according to a string of music notes. The input string also contains information about note duration, as well as silences. Must be preceded by Robot.beginSpeaker() in setup().
NB : when a melody is playing, all other processes stop
1Robot.playMelody(melody)
melody: A string of notes to be played and their duration.
The string may contain following chars: Notes
c
: play "C"C
: play "#C"d
: play "D"D
: play "#D"e
: play "E"f
: play "F"F
: play "#F"g
: play "G"G
: play "#G"a
: play "A"A
: play "#A"b
: play "B"-
: silence1
: Set the following as full notes2
: Set the following as half notes4
: Set the following as quarter notes8
: Set the following as eight notes.
: Set the note duration as its duration plus an half of its duration (Example 1/4 + 1/8)none
1#include <ArduinoRobot.h>2
3void setup(){4 Robot.begin();5 Robot.beginSpeaker();//Initialize the sound module6}7
8void loop(){9 char aTinyMelody[] = "8eF-FFga4b.a.g.F.8beee-d2e.1-";// This is what we will play10 Robot.playMelody(aTinyMelody);// Play the melody11
12}
beep()
Make a short beeping sound. Must be preceded by Robot.beginSpeaker() in setup().
NB : when a beep is playing, all other processes stop
1Robot.beep(beep_length)
beep_length: Any of the const below indicating type of beep sound.
none
1#include <ArduinoRobot.h>2
3void setup(){4 Robot.begin();5 Robot.beginSpeaker();//Initialize the sound module6}7
8void loop(){9 Robot.beep(BEEP_SIMPLE);//Make a single beep sound10 delay(1000);11}
playFile()
Play a .sqm music file stored on a SD card. Robot.beginSpeaker() and Robot.beginSD() are both required in setup().
Unlike Robot.playMelody() and Robot.playBeep(), playFile() does not halt other processes while playing. However, you cannot load new images on the LCD screen when playFile() is in use.
Valid files for playback are generated/converted by the sound library Squawk. See the library README for details on how to create your own music.
1Robot.playFile(filename)
filename: file name of the music to be played
none
1#include <ArduinoRobot.h>2
3void setup(){4 Robot.begin();5 Robot.beginSpeaker();//Initialize the sound module6 Robot.beginSD();//Initialize the sd card7 Robot.playFile("melody.sqm");//Play the original music come with the robot.8}9
10void loop(){11 //do other stuff here12}
tuneWrite()
When playing a music file through playFile(), this will change the pitch of the sound. The larger the value, the higher the pitch.
1Robot.tuneWrite(pitch)
pitch: float, indicating the pitch of the sound currently playing. 1.0 is the baseline value.
none
1#include <ArduinoRobot.h>2
3void setup(){4 Robot.begin();5 Robot.beginSpeaker();//Initialize the sound module6 Robot.beginSD();//Initialize the sd card7 Robot.playFile("melody.sqm");//Play the original music come with the robot.8 Robot.tuneWrite(1.4);//40% higher than default9}10
11void loop(){12
13}
tempoWrite()
When playing a music file with playFile(), this will change the tempo, or speed of the playback. The larger the value, the quicker the sound will play back. Smaller values will slow the playback.
1Robot.tempoWrite(speed)
speed: int, the tempo. Default is 50.
none
1#include <ArduinoRobot.h>2
3void setup(){4 Robot.begin();5 Robot.beginSpeaker();//Initialize the sound module6 Robot.beginSD();//Initialize the sd card7 Robot.playFile("melody.sqm");//Play the original music come with the robot.8 Robot.tempoWrite(70);//20 higher than default9}10
11void loop(){12
13}
beginTFT()
Initialize the TFT module. All general TFT functions are dependent on this.
1Robot.beginTFT()2Robot.beginTFT(foreGround, backGround)
foreGround: set a universal foreground color. Default is black. backGround: set a universal background color. Default is white.
none
1#include <ArduinoRobot.h>2
3void setup(){4 Robot.begin();5 Robot.beginTFT();//Initialize the TFT module6}7
8void loop(){9 Robot.fill(255,255,255);10 Robot.text("Hello World",0,0);11 delay(2000);12
13 Robot.fill(0,0,0);14 Robot.text("Hello World",0,0,false);//It's necessary to erase the old text, before showing new text15
16 Robot.fill(255,255,255);17 Robot.text("I am a robot",0,0);18 delay(3000);19
20 Robot.fill(0,0,0);21 Robot.text("I am a robot",0,0);22}
text()
Write some text to an attached TFT.
When updating the screen, remember to erase the text before writing new text on the same place, or the new/old text will be overlapping each other.
The screen is only 128 pixels tall and 160 pixels wide. It's recommended to use small values for x and y, or text may be cropped/invisible in unpredictable ways.
1Robot.text(toWrite, x, y, writeOrErase)
toWrite: text/value to be written on the LCD. Can be a string, an int or a long.
x: x axis of starting position on the screen.
y: y axis of starting position on the screen.
writeOrErase: specify whether to write the text or erase the text. Use true to write and false to erase.
none
1#include <ArduinoRobot.h>2
3void setup(){4 Robot.begin();5 Robot.beginTFT();//Initialize the TFT module6}7
8void loop(){9 Robot.text("Hello World",0,0,true);10 delay(2000);11
12 Robot.text("Hello World",0,0,false);//It's necessary to erase the old text, for showing new text13 Robot.text("I am a robot",0,0,true);14 delay(3000);15
16 Robot.text("I am a robot",0,0,false);17}
beginBMPFromEEPROM()
After beginBMPFromEEPROM() is called, drawBMP() will look for images from the EEPROM, until endBMPFromEEPROM() is called.
Images stored in EEPROM are accessed more slowly than from an SD card.
If drawBMP() cannot find images from EEPROM with the given file name, no image will be rendered on screen, even if a bmp with the same file name is stored on a SD card.
Call endBMPFromEEPROM() after drawBMP() if you want to get images from a SD card afterwards.
1Robot.beginBMPFromEEPROM()
none
none
1#include <ArduinoRobot.h>2
3void setup(){4 Serial.begin(9600);5 Robot.begin();6 Robot.readyLCD();7
8 //The image is pulled from EEPROM9 Robot.beginBMPFromEEPROM();10 Robot.drawBMP("inicio.bmp",0,0);11 Robot.endBMPFromEEPROM();12
13}14void loop(){15}
endBMPFromEEPROM()
Stops drawBMP() from pulling images in EEPROM. Used in conjunction with beginBMPFromEEPROM().
1Robot.endBMPFromEEPROM()
none
none
1#include <ArduinoRobot.h>2void setup(){3 Serial.begin(9600);4 Robot.begin();5 Robot.readyLCD();6
7 //The image is pulled from EEPROM8 Robot.beginBMPFromEEPROM();9 Robot.drawBMP("inicio.bmp",0,0);10 Robot.endBMPFromEEPROM();11
12}13
14void loop(){15}
drawDire(direction)
A helper function for drawing a compass on the LCD screen
direction: an int between 0 and 359, indicating where the compass should be pointing at. Typically it's one get from Robot.compassRead().
none
1#include <ArduinoRobot.h>2void setup(){3 Robot.begin();4 Robot.readyLCD();//Initialize the LCD module5}6void loop(){7 int dire=Robot.compassRead();8 Robot.drawDire(dire);9}
drawBMP()
Display a bmp file on the LCD screen. The bmp file should be stored in sd card. BMP format should be 24-bit color, and no bigger than 128*160. If an image dimensions exceed the size of the screen, it will be cropped.
To use this method, you must initialize the SD card by calling Robot.beginSD() in setup().
1Robot.drawBMP(filename, x, y)
filename: name of the bmp file to be displayed. x: x-axis of starting position on the screen. y: y-axis of starting position on the screen.
none
1// Draws an image named "intro.bmp" from the SD card2
3#include <ArduinoRobot.h>4
5void setup(){6 Robot.begin();7 Robot.readyTFT();8 Robot.beginSD();9
10 //The image is pulled from sd card11 Robot.drawBMP("intro.bmp",0,0);12}13
14void loop(){15 // nothing happening here16}
debugPrint()
Print and refresh a value to the LCD screen. You need to first initialize the LCD screen in setup() by calling Robot.readyLCD(). If no starting point is defined, text defaults to starting at 0,0, the top left of the screen.
1Robot.debugPrint(toPrint)2Robot.debugPrint(toPrint, x, y)
toPrint: value to be printed. Must be int or long. x: x axis of starting position on the screen. y: y axis of starting position on the screen.
none
1#include <ArduinoRobot.h>2
3void setup(){4 Robot.begin();5 Robot.readyTFT();//Initialize the TFT module6}7
8void loop(){9 int val=Robot.analogRead(TK0); //Get analog value from port TK0 on top board.10 Robot.debugPrint(val); //No need to erase the old value11 delay(100);12}
clearScreen()
Fill the entire screen with the background color. Default is black.
1Robot.clearScreen();
none
none
1#include <ArduinoRobot.h>2
3void setup(){4 Robot.begin();5 Robot.beginTFT();//Initialize the TFT module6}7
8void loop(){9 Robot.text("Hello World",0,0,true);10 delay(2000);11
12 Robot.clearScreen();//empty the screen13 delay(2000);14}
displayLogos()
A helper function for displaying an opening sequence in some of the examples.
displayLogos() draws "lg0.bmp" and "lg1.bmp" from an attached SD card to the screen, with 2 seconds of delay between the first and second image. There is a 2 second delay after "lg1.bmp", for a total of 4 seconds.
You need to initialize both the LCD and SD card, and have "lg0.bmp" and "lg1.bmp" on the card (they are installed by default).
1Robot.displayLogos();
none
none
1#include <ArduinoRobot.h>2
3void setup(){4 Robot.begin();5 Robot.beginTFT();//Initialize the TFT module6 Robot.displayLogos();//Show the opening sequence7}8
9void loop(){10 Robot.text("Hello World",0,0,true);11 delay(2000);12
13 Robot.text("Hello World",0,0,false);//It's necessary to erase the old text, for showing new text14 Robot.text("I am a robot",0,0,true);15 delay(3000);16
17 Robot.text("I am a robot",0,0,false);18}
drawCompass()
A helper function for displaying the compass on the TFT. Relies on Robot.beginTFT(). drawCompass() uses debugPrint(), which can't be used in the same sketch.
Mind where you draw text and other graphic elements when using drawCompass() so that you don;t overlap elements.
1Robot.drawCompass(degrees);
degrees: int between 0 and 359. Typically it's determined by Robot.compassRead().
none
1#include <ArduinoRobot.h>2
3int compassValue;4
5void setup(){6 Robot.begin();7 Robot.beginTFT();//Initialize the TFT module8}9
10void loop(){11 compassValue=Robot.compassRead();12 Robot.drawCompass(compassValue);//draw the compass13}
beginSD()
Initialize the SD card for use. Functions that read data from a SD card like drawBMP() and playFile() are dependent on this.
NB : This function uses a lot of memory, and may leads to undefined results if used in a complex sketch. It's recommended to not use this unless you are using the SD card.
1Robot.beginSD()
none
none
1#include <ArduinoRobot.h>2
3void setup(){4 Robot.begin();5 Robot.readyTFT();6 Robot.beginSD();//Initialize the sd card7
8 Robot.drawBMP("inicio.bmp",0,0);//draw an image from the sd card9
10}11
12void loop(){13}
userNameRead()
Read the name stored in EEPROM. The name is set by userNameWrite(). EEPROM is not erased when the robot is turned off and can be read anytime after being set.
1Robot.userNameRead(container)
container: a char array with 8 elements.
none
1#include <ArduinoRobot.h>2
3void setup(){4 Serial.begin(9600);5 Robot.begin();6}7
8void loop(){9 Robot.userNameWrite("Aaa");10 Robot.robotNameWrite("The Robot");11 Robot.cityNameWrite("Malmo");12 Robot.countryNameWrite("Sweden");13
14 char container[8];15 Robot.userNameRead(container)16 Serial.println(container);17
18 Robot.robotNameRead(container)19 Serial.println(container);20
21 Robot.cityNameRead(container)22 Serial.println(container);23
24 Robot.countryNameRead(container)25 Serial.println(container);26}
userNameWrite()
Store your name into EEPROM. EEPROM is always saved, even when the power is switched off.
1Robot.userNameWrite(name)
name: string to be stored
none
1#include <ArduinoRobot.h>2
3void setup(){4 Serial.begin(9600);5 Robot.begin();6}7
8void loop(){9 Robot.userNameWrite("Aaa");10 Robot.robotNameWrite("The Robot");11 Robot.cityNameWrite("Malmo");12 Robot.countryNameWrite("Sweden");13
14 Serial.println(Robot.userNameRead());15 Serial.println(Robot.robotNameRead());16 Serial.println(Robot.cityNameRead());17 Serial.println(Robot.countryNameRead());18}
RobotNameRead()
Read the robot name stored in EEPROM. This can be set by robotNameWrite().
1Robot.RobotNameRead(container)
container: a char array with 8 elements.
none
1#include <ArduinoRobot.h>2
3void setup(){4 Serial.begin(9600);5 Robot.begin();6}7
8void loop(){9 Robot.userNameWrite("Aaa");10 Robot.robotNameWrite("The Robot");11 Robot.cityNameWrite("Malmo");12 Robot.countryNameWrite("Sweden");13
14 char container[8];15 Robot.userNameRead(container)16 Serial.println(container);17
18 Robot.robotNameRead(container)19 Serial.println(container);20
21 Robot.cityNameRead(container)22 Serial.println(container);23
24 Robot.countryNameRead(container)25 Serial.println(container);26}
robotNameWrite()
Store the robot's name into EEPROM.
1Robot.robotNameWrite(name)
name: string to be stored
none
1#include <ArduinoRobot.h>2
3void setup(){4 Serial.begin(9600);5 Robot.begin();6}7
8void loop(){9 Robot.userNameWrite("Aaa");10 Robot.robotNameWrite("The Robot");11 Robot.cityNameWrite("Malmo");12 Robot.countryNameWrite("Sweden");13
14 Serial.println(Robot.userNameRead());15 Serial.println(Robot.robotNameRead());16 Serial.println(Robot.cityNameRead());17 Serial.println(Robot.countryNameRead());18}
cityNameRead()
Read your city's name stored in EEPROM. This can be set by cityNameWrite().
1Robot.cityNameRead(container)
container: a char array with 8 elements.
none
1#include <ArduinoRobot.h>2
3void setup(){4 Serial.begin(9600);5 Robot.begin();6}7
8void loop(){9 Robot.userNameWrite("Aaa");10 Robot.robotNameWrite("The Robot");11 Robot.cityNameWrite("Malmo");12 Robot.countryNameWrite("Sweden");13
14 char container[8];15 Robot.userNameRead(container)16 Serial.println(container);17
18 Robot.robotNameRead(container)19 Serial.println(container);20
21 Robot.cityNameRead(container)22 Serial.println(container);23
24 Robot.countryNameRead(container)25 Serial.println(container);26}
cityNameWrite()
Store your city's name into EEPROM.
1Robot.cityNameWrite(name)
name: string to be stored
none
1#include <ArduinoRobot.h>2
3void setup(){4 Serial.begin(9600);5 Robot.begin();6}7
8void loop(){9 Robot.userNameWrite("Aaa");10 Robot.robotNameWrite("The Robot");11 Robot.cityNameWrite("Malmo");12 Robot.countryNameWrite("Sweden");13
14 Serial.println(Robot.userNameRead());15 Serial.println(Robot.robotNameRead());16 Serial.println(Robot.cityNameRead());17 Serial.println(Robot.countryNameRead());18}
countryNameRead()
Read your country's name stored in EEPROM. This is set by userNameWrite().
1Robot.countryNameRead(container)
container: a char array of 8 elements.
none
1#include <ArduinoRobot.h>2
3void setup(){4 Serial.begin(9600);5 Robot.begin();6}7
8void loop(){9 Robot.userNameWrite("Aaa");10 Robot.robotNameWrite("The Robot");11 Robot.cityNameWrite("Malmo");12 Robot.countryNameWrite("Sweden");13
14 char container[8];15 Robot.userNameRead(container)16 Serial.println(container);17
18 Robot.robotNameRead(container)19 Serial.println(container);20
21 Robot.cityNameRead(container)22 Serial.println(container);23
24 Robot.countryNameRead(container)25 Serial.println(container);26}
countryNameWrite()
Store the user's country name into EEPROM.
1Robot.countryNameWrite(name)
name: string to be stored
none
1#include <ArduinoRobot.h>2void setup(){3 Serial.begin(9600);4 Robot.begin();5}6void loop(){7 Robot.userNameWrite("Aaa");8 Robot.robotNameWrite("The Robot");9 Robot.cityNameWrite("Malmo");10 Robot.countryNameWrite("Sweden");11
12 Serial.println(Robot.userNameRead());13 Serial.println(Robot.robotNameRead());14 Serial.println(Robot.cityNameRead());15 Serial.println(Robot.countryNameRead());16}
RobotMotorBoard()
The constructor is empty, as the methods can be accessed through Robot object directly, you don't need to call the constructor.
none
none
1#include <ArduinoRobotMotorBoard.h>2void setup(){3 //methods can be accessed directly through RobotMotor4 RobotMotor.begin();5 RobotMotor.motorsWrite(255,255);6}7void loop(){8}
begin()
Initializes the robot motor board. Must be called in setup() to use Robot-specific features. This can only be called on the Motor Board processor.
1RobotMotor.begin()
none
none
1#include <ArduinoRobotMotorBoard.h>2
3void setup(){4 RobotMotor.begin();5}6
7void loop(){8 //The robot motor board core routine9 RobotMotor.parseCommand();10 RobotMotor.process();11}
process()
Carry out different actions according to the mode Robot is in. It's part of Robot motor board's core routine. If you want to extend it, see this document.
This can only be called from the Motor Board processor.
1RobotMotor.process()
none
none
1#include <ArduinoRobotMotorBoard.h>2void setup(){3 RobotMotor.begin();4}5void loop(){6 //The robot motor board core routine7 RobotMotor.parseCommand();8 RobotMotor.process();9}
parseCommand()
Receive commands from Robot Control Board, and carry them out accordingly. It's part of Robot motor board's core routine. If you want to extend it, see this document.
This can only be called from the Motor Board processor.
1RobotMotor.parseCommand()
none
none
1#include <ArduinoRobotMotorBoard.h>2void setup(){3 RobotMotor.begin();4}5void loop(){6 //The robot motor board core routine7 RobotMotor.parseCommand();8 RobotMotor.process();9}
motorsWrite()
Control the robot's wheels speed and direction from the Motor Board processor. It's different from motorsWrite() of the control board. This one drives the motors directly, while the former sends signals to the motor board. So don't mix them in usage.
1RobotMotor.motorsWrite(speedL, speedR)
speedLeft: controls the speed of left wheel.
speedRight: controls the speed of right wheel.
Both values can be from -255 to 255. If the value is bigger than 0, the wheel turns forward. Smaller than 0, the motor turns backwards.
none
1#include <ArduinoRobotMotorBoard.h>2
3void setup(){4 RobotMotor.begin();5}6
7void loop(){8 RobotMotor.motorsWrite(255,255);9 delay(1000);10 RobotMotor.motorsWrite(0,0);11 delay(1000);12}
IRread()
Get the reading from a specific IR sensor. This can only be called from the Motor Board processor. To read the IR sensors from the Control Board, use updateIR().
1RobotMotor.IRread(num)
num: 1 to 5, corresponding to sensors 1 to 5.
int : 0 to 1023
1#include <ArduinoRobotMotorBoard.h>2void setup(){3 Serial.begin(9600);4 RobotMotor.begin();5}6void loop(){7 Serial.println(RobotMotor.IRread(1));8 delay(10);9}