mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-30 16:24:09 +03:00
Run new astyle formatter against all the examples
This commit is contained in:
@ -1,24 +1,24 @@
|
||||
/* Robot Logo
|
||||
|
||||
This sketch demonstrates basic movement of the Robot.
|
||||
When the sketch starts, press the on-board buttons to tell
|
||||
the robot how to move. Pressing the middle button will
|
||||
save the pattern, and the robot will follow accordingly.
|
||||
You can record up to 20 commands. The robot will move for
|
||||
This sketch demonstrates basic movement of the Robot.
|
||||
When the sketch starts, press the on-board buttons to tell
|
||||
the robot how to move. Pressing the middle button will
|
||||
save the pattern, and the robot will follow accordingly.
|
||||
You can record up to 20 commands. The robot will move for
|
||||
one second per command.
|
||||
|
||||
|
||||
This example uses images on an SD card. It looks for
|
||||
files named "lg0.bmp" and "lg1.bmp" and draws them on the
|
||||
screen.
|
||||
|
||||
Circuit:
|
||||
* Arduino Robot
|
||||
|
||||
|
||||
created 1 May 2013
|
||||
by X. Yang
|
||||
modified 12 May 2013
|
||||
by D. Cuartielles
|
||||
|
||||
|
||||
This example is in the public domain
|
||||
*/
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
int commands[20]; // array for storing commands
|
||||
|
||||
void setup() {
|
||||
// initialize the Robot, SD card, and display
|
||||
// initialize the Robot, SD card, and display
|
||||
Robot.begin();
|
||||
Robot.beginTFT();
|
||||
Robot.beginSD();
|
||||
@ -37,39 +37,39 @@ void setup() {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
|
||||
Robot.drawBMP("intro.bmp", 0, 0); //display background image
|
||||
|
||||
|
||||
iniCommands(); // remove commands from the array
|
||||
addCommands(); // add commands to the array
|
||||
|
||||
|
||||
delay(1000); // wait for a second
|
||||
|
||||
|
||||
executeCommands(); // follow orders
|
||||
|
||||
Robot.stroke(0,0,0);
|
||||
|
||||
Robot.stroke(0, 0, 0);
|
||||
Robot.text("Done!", 5, 103); // write some text to the display
|
||||
delay(1500); // wait for a moment
|
||||
}
|
||||
|
||||
// empty the commands array
|
||||
void iniCommands() {
|
||||
for(int i=0; i<20; i++)
|
||||
commands[i]=-1;
|
||||
for (int i = 0; i < 20; i++)
|
||||
commands[i] = -1;
|
||||
}
|
||||
|
||||
// add commands to the array
|
||||
void addCommands() {
|
||||
Robot.stroke(0,0,0);
|
||||
Robot.stroke(0, 0, 0);
|
||||
// display text on the screen
|
||||
Robot.text("1. Press buttons to\n add commands.\n\n 2. Middle to finish.", 5, 5);
|
||||
|
||||
|
||||
// read the buttons' state
|
||||
for(int i=0; i<20;) { //max 20 commands
|
||||
for (int i = 0; i < 20;) { //max 20 commands
|
||||
int key = Robot.keyboardRead();
|
||||
if(key == BUTTON_MIDDLE) { //finish input
|
||||
if (key == BUTTON_MIDDLE) { //finish input
|
||||
break;
|
||||
}else if(key == BUTTON_NONE) { //if no button is pressed
|
||||
} else if (key == BUTTON_NONE) { //if no button is pressed
|
||||
continue;
|
||||
}
|
||||
commands[i] = key; // save the button to the array
|
||||
@ -82,11 +82,11 @@ void addCommands() {
|
||||
// run through the array and move the robot
|
||||
void executeCommands() {
|
||||
// print status to the screen
|
||||
Robot.text("Excuting...",5,70);
|
||||
|
||||
Robot.text("Excuting...", 5, 70);
|
||||
|
||||
// read through the array and move accordingly
|
||||
for(int i=0; i<20; i++) {
|
||||
switch(commands[i]) {
|
||||
for (int i = 0; i < 20; i++) {
|
||||
switch (commands[i]) {
|
||||
case BUTTON_LEFT:
|
||||
Robot.turn(-90);
|
||||
break;
|
||||
@ -103,10 +103,10 @@ void executeCommands() {
|
||||
return;
|
||||
}
|
||||
// print the current command to the screen
|
||||
Robot.stroke(255,0,0);
|
||||
Robot.stroke(255, 0, 0);
|
||||
PrintCommandI(i, 86);
|
||||
delay(1000);
|
||||
|
||||
|
||||
// stop moving for a second
|
||||
Robot.motorsStop();
|
||||
delay(1000);
|
||||
@ -115,7 +115,7 @@ void executeCommands() {
|
||||
|
||||
// convert the button press to a single character
|
||||
char keyToChar(int key) {
|
||||
switch(key) {
|
||||
switch (key) {
|
||||
case BUTTON_LEFT:
|
||||
return '<';
|
||||
case BUTTON_RIGHT:
|
||||
@ -129,6 +129,6 @@ char keyToChar(int key) {
|
||||
|
||||
// display a command
|
||||
void PrintCommandI(int i, int originY) {
|
||||
Robot.text(keyToChar(commands[i]), i%14*8+5, i/14*10+originY);
|
||||
Robot.text(keyToChar(commands[i]), i % 14 * 8 + 5, i / 14 * 10 + originY);
|
||||
}
|
||||
|
||||
|
@ -1,19 +1,19 @@
|
||||
/* Robot Line Follow
|
||||
|
||||
This sketch demonstrates the line following capabilities
|
||||
of the Arduino Robot. On the floor, place some black
|
||||
of the Arduino Robot. On the floor, place some black
|
||||
electrical tape along the path you wish the robot to follow.
|
||||
To indicate a stopping point, place another piece of tape
|
||||
perpendicular to the path.
|
||||
|
||||
Circuit:
|
||||
* Arduino Robot
|
||||
|
||||
|
||||
created 1 May 2013
|
||||
by X. Yang
|
||||
modified 12 May 2013
|
||||
by D. Cuartielles
|
||||
|
||||
|
||||
This example is in the public domain
|
||||
*/
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
long timerOrigin; // used for counting elapsed time
|
||||
|
||||
void setup() {
|
||||
// initialize the Robot, SD card, display, and speaker
|
||||
// initialize the Robot, SD card, display, and speaker
|
||||
Robot.begin();
|
||||
Robot.beginTFT();
|
||||
Robot.beginSD();
|
||||
@ -30,45 +30,45 @@ void setup() {
|
||||
|
||||
// show the logots on the TFT screen
|
||||
Robot.displayLogos();
|
||||
|
||||
|
||||
Robot.drawBMP("lf.bmp", 0, 0); // display background image
|
||||
|
||||
Robot.playFile("chase.sqm"); // play a song from the SD card
|
||||
|
||||
|
||||
// add the instructions
|
||||
Robot.text("Line Following\n\n place the robot on\n the track and \n see it run", 5, 5);
|
||||
Robot.text("Press the middle\n button to start...", 5, 61);
|
||||
Robot.waitContinue();
|
||||
|
||||
// These are some general values that work for line following
|
||||
// These are some general values that work for line following
|
||||
// uncomment one or the other to see the different behaviors of the robot
|
||||
//Robot.lineFollowConfig(14, 9, 50, 10);
|
||||
Robot.lineFollowConfig(11, 7, 60, 5);
|
||||
|
||||
|
||||
|
||||
|
||||
//set the motor board into line-follow mode
|
||||
Robot.setMode(MODE_LINE_FOLLOW);
|
||||
|
||||
Robot.setMode(MODE_LINE_FOLLOW);
|
||||
|
||||
// start
|
||||
Robot.fill(255, 255, 255);
|
||||
Robot.stroke(255, 255, 255);
|
||||
Robot.rect(0, 0, 128, 80); // erase the previous text
|
||||
Robot.stroke(0, 0, 0);
|
||||
Robot.text("Start", 5, 5);
|
||||
|
||||
|
||||
Robot.stroke(0, 0, 0); // choose color for the text
|
||||
Robot.text("Time passed:", 5, 21); // write some text to the screen
|
||||
|
||||
timerOrigin=millis(); // keep track of the elapsed time
|
||||
|
||||
while(!Robot.isActionDone()) { //wait for the finish signal
|
||||
Robot.debugPrint(millis()-timerOrigin, 5, 29); // show how much time has passed
|
||||
|
||||
timerOrigin = millis(); // keep track of the elapsed time
|
||||
|
||||
while (!Robot.isActionDone()) { //wait for the finish signal
|
||||
Robot.debugPrint(millis() - timerOrigin, 5, 29); // show how much time has passed
|
||||
}
|
||||
|
||||
Robot.stroke(0, 0, 0);
|
||||
|
||||
Robot.stroke(0, 0, 0);
|
||||
Robot.text("Done!", 5, 45);
|
||||
}
|
||||
void loop() {
|
||||
//nothing here, the program only runs once. Reset the robot
|
||||
//nothing here, the program only runs once. Reset the robot
|
||||
//to do it again!
|
||||
}
|
||||
|
@ -1,18 +1,18 @@
|
||||
/* Disco Bot
|
||||
|
||||
This sketch shows you how to use the melody playing
|
||||
feature of the robot, with some really cool 8-bit music.
|
||||
Music will play when the robot is turned on, and it
|
||||
This sketch shows you how to use the melody playing
|
||||
feature of the robot, with some really cool 8-bit music.
|
||||
Music will play when the robot is turned on, and it
|
||||
will show you some dance moves.
|
||||
|
||||
Circuit:
|
||||
* Arduino Robot
|
||||
|
||||
|
||||
created 1 May 2013
|
||||
by X. Yang
|
||||
modified 12 May 2013
|
||||
by D. Cuartielles
|
||||
|
||||
|
||||
This example is in the public domain
|
||||
*/
|
||||
|
||||
@ -25,12 +25,12 @@
|
||||
F: go forward
|
||||
B: go backwards
|
||||
|
||||
The number after each command determines how long
|
||||
The number after each command determines how long
|
||||
each step lasts. Each number is 1/2 second long.
|
||||
|
||||
The "\0" indicates end of string
|
||||
*/
|
||||
char danceScript[] = "S4L1R1S2F1B1S1\0";
|
||||
char danceScript[] = "S4L1R1S2F1B1S1\0";
|
||||
|
||||
int currentScript = 0; // what step are we at
|
||||
|
||||
@ -49,34 +49,34 @@ long waitFrom;
|
||||
long waitTime = 0;
|
||||
|
||||
void setup() {
|
||||
// initialize the Robot, SD card, display, and speaker
|
||||
// initialize the Robot, SD card, display, and speaker
|
||||
Robot.begin();
|
||||
Robot.beginSpeaker();
|
||||
Robot.beginSD();
|
||||
Robot.beginTFT();
|
||||
|
||||
|
||||
// draw "lg0.bmp" and "lg1.bmp" on the screen
|
||||
Robot.displayLogos();
|
||||
|
||||
|
||||
// Print instructions to the screen
|
||||
Robot.text("1. Use left and\n right key to switch\n song", 5, 5);
|
||||
Robot.text("2. Put robot on the\n ground to dance", 5, 33);
|
||||
|
||||
// wait for a few soconds
|
||||
delay(3000);
|
||||
|
||||
|
||||
setInterface(); // display the current song
|
||||
play(0); //play the first song in the array
|
||||
|
||||
|
||||
resetWait(); //Initialize non-blocking delay
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// read the butttons on the robot
|
||||
int key = Robot.keyboardRead();
|
||||
|
||||
|
||||
// Right/left buttons play next/previous song
|
||||
switch(key) {
|
||||
switch (key) {
|
||||
case BUTTON_UP:
|
||||
case BUTTON_LEFT:
|
||||
play(-1); //play previous song
|
||||
@ -86,25 +86,25 @@ void loop() {
|
||||
play(1); //play next song
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// dance!
|
||||
runScript();
|
||||
}
|
||||
|
||||
// Dancing function
|
||||
void runScript() {
|
||||
if(!waiting()) { // if the previous instructions have finished
|
||||
// get the next 2 commands (direction and duration)
|
||||
parseCommand(danceScript[currentScript], danceScript[currentScript+1]);
|
||||
void runScript() {
|
||||
if (!waiting()) { // if the previous instructions have finished
|
||||
// get the next 2 commands (direction and duration)
|
||||
parseCommand(danceScript[currentScript], danceScript[currentScript + 1]);
|
||||
currentScript += 2;
|
||||
if(danceScript[currentScript] == '\0') // at the end of the array
|
||||
if (danceScript[currentScript] == '\0') // at the end of the array
|
||||
currentScript = 0; // start again at the beginning
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// instead of delay, use this timer
|
||||
boolean waiting() {
|
||||
if(millis()-waitFrom >= waitTime)
|
||||
if (millis() - waitFrom >= waitTime)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
@ -122,9 +122,9 @@ void resetWait() {
|
||||
}
|
||||
|
||||
// read the direction and dirstion of the steps
|
||||
void parseCommand(char dir, char duration) {
|
||||
void parseCommand(char dir, char duration) {
|
||||
//convert the scripts to action
|
||||
switch(dir) {
|
||||
switch (dir) {
|
||||
case 'L':
|
||||
Robot.motorsWrite(-255, 255);
|
||||
break;
|
||||
@ -142,7 +142,7 @@ void parseCommand(char dir, char duration) {
|
||||
break;
|
||||
}
|
||||
//You can change "500" to change the pace of dancing
|
||||
wait(500*(duration-'0'));
|
||||
wait(500 * (duration - '0'));
|
||||
}
|
||||
|
||||
// display the song
|
||||
@ -154,10 +154,10 @@ void setInterface() {
|
||||
|
||||
// display the next song
|
||||
void select(int seq, boolean onOff) {
|
||||
if(onOff){//select
|
||||
if (onOff) { //select
|
||||
Robot.stroke(0, 0, 0);
|
||||
Robot.text(musics[seq], 0, 0);
|
||||
}else{//deselect
|
||||
} else { //deselect
|
||||
Robot.stroke(255, 255, 255);
|
||||
Robot.text(musics[seq], 0, 0);
|
||||
}
|
||||
@ -166,9 +166,9 @@ void select(int seq, boolean onOff) {
|
||||
// play the slected song
|
||||
void play(int seq) {
|
||||
select(currentSong, false);
|
||||
if(currentSong <= 0 && seq == -1) { //previous of 1st song?
|
||||
currentSong = SONGS_COUNT-1; //go to last song
|
||||
} else if(currentSong >= SONGS_COUNT-1 && seq == 1) { //next of last?
|
||||
if (currentSong <= 0 && seq == -1) { //previous of 1st song?
|
||||
currentSong = SONGS_COUNT - 1; //go to last song
|
||||
} else if (currentSong >= SONGS_COUNT - 1 && seq == 1) { //next of last?
|
||||
currentSong = 0; //go to 1st song
|
||||
} else {
|
||||
currentSong += seq; //next song
|
||||
|
@ -1,21 +1,21 @@
|
||||
/* Robot Compass
|
||||
|
||||
The robot has an on-board compass module, with
|
||||
which it can tell the direction the robot is
|
||||
facing. This sketch will make sure the robot
|
||||
goes towards a certain direction.
|
||||
|
||||
which it can tell the direction the robot is
|
||||
facing. This sketch will make sure the robot
|
||||
goes towards a certain direction.
|
||||
|
||||
Beware, magnets will interfere with the compass
|
||||
readings.
|
||||
|
||||
Circuit:
|
||||
* Arduino Robot
|
||||
|
||||
|
||||
created 1 May 2013
|
||||
by X. Yang
|
||||
modified 12 May 2013
|
||||
by D. Cuartielles
|
||||
|
||||
|
||||
This example is in the public domain
|
||||
*/
|
||||
|
||||
@ -35,32 +35,32 @@ void setup() {
|
||||
Robot.displayLogos();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
void loop() {
|
||||
// read the compass orientation
|
||||
compassValue = Robot.compassRead();
|
||||
|
||||
|
||||
// how many degrees are we off
|
||||
int diff = compassValue-direc;
|
||||
|
||||
// modify degress
|
||||
if(diff > 180)
|
||||
diff = -360+diff;
|
||||
else if(diff < -180)
|
||||
diff = 360+diff;
|
||||
|
||||
int diff = compassValue - direc;
|
||||
|
||||
// modify degress
|
||||
if (diff > 180)
|
||||
diff = -360 + diff;
|
||||
else if (diff < -180)
|
||||
diff = 360 + diff;
|
||||
|
||||
// Make the robot turn to its proper orientation
|
||||
diff = map(diff, -180, 180, -255, 255);
|
||||
|
||||
if(diff > 0) {
|
||||
// keep the right wheel spinning,
|
||||
// change the speed of the left wheel
|
||||
speedLeft = 255-diff;
|
||||
|
||||
if (diff > 0) {
|
||||
// keep the right wheel spinning,
|
||||
// change the speed of the left wheel
|
||||
speedLeft = 255 - diff;
|
||||
speedRight = 255;
|
||||
} else {
|
||||
// keep the right left spinning,
|
||||
// change the speed of the left wheel
|
||||
// change the speed of the left wheel
|
||||
speedLeft = 255;
|
||||
speedRight = 255+diff;
|
||||
speedRight = 255 + diff;
|
||||
}
|
||||
// write out to the motors
|
||||
Robot.motorsWrite(speedLeft, speedRight);
|
||||
|
@ -1,21 +1,21 @@
|
||||
/* Robot Inputs
|
||||
|
||||
This sketch shows you how to use the on-board
|
||||
potentiometer and buttons as inputs.
|
||||
This sketch shows you how to use the on-board
|
||||
potentiometer and buttons as inputs.
|
||||
|
||||
Turning the potentiometer draws a clock-shaped
|
||||
circle. The up and down buttons change the pitch,
|
||||
while the left and right buttons change the tempo.
|
||||
Turning the potentiometer draws a clock-shaped
|
||||
circle. The up and down buttons change the pitch,
|
||||
while the left and right buttons change the tempo.
|
||||
The middle button resets tempo and pitch.
|
||||
|
||||
Circuit:
|
||||
* Arduino Robot
|
||||
|
||||
|
||||
created 1 May 2013
|
||||
by X. Yang
|
||||
modified 12 May 2013
|
||||
by D. Cuartielles
|
||||
|
||||
|
||||
This example is in the public domain
|
||||
*/
|
||||
|
||||
@ -26,16 +26,16 @@ int tempo = 60;
|
||||
int pitch = 1000;
|
||||
|
||||
void setup() {
|
||||
// initialize the Robot, SD card, speaker, and display
|
||||
// initialize the Robot, SD card, speaker, and display
|
||||
Robot.begin();
|
||||
Robot.beginTFT();
|
||||
Robot.beginSpeaker();
|
||||
Robot.beginSD();
|
||||
|
||||
// draw "lg0.bmp" and "lg1.bmp" on the screen
|
||||
// draw "lg0.bmp" and "lg1.bmp" on the screen
|
||||
Robot.displayLogos();
|
||||
|
||||
// play a sound file
|
||||
// play a sound file
|
||||
Robot.playFile("Melody.sqm");
|
||||
}
|
||||
|
||||
@ -50,55 +50,55 @@ void loop() {
|
||||
// Draw the basic interface
|
||||
void renderUI() {
|
||||
//fill the buttons blank
|
||||
Robot.fill(255, 255, 255);
|
||||
Robot.fill(255, 255, 255);
|
||||
Robot.rect(53, 58, 13, 13); // left
|
||||
Robot.rect(93, 58, 13, 13); // right
|
||||
Robot.rect(73, 38, 13, 13); // up
|
||||
Robot.circle(79, 64, 6); // middle
|
||||
Robot.rect(73, 78, 13, 13); // down
|
||||
|
||||
|
||||
//draw the knob
|
||||
Robot.noFill();
|
||||
Robot.circle(26, 116, 17); // knob
|
||||
|
||||
//draw the vertical bargraph
|
||||
int fullPart=map(pitch, 200, 2000, 0, 58); //length of filled bargraph
|
||||
Robot.fill(255, 255, 255);
|
||||
Robot.rect(21, 30, 13, 58-fullPart);
|
||||
Robot.fill(0, 0, 255);
|
||||
Robot.rect(21, 88-fullPart, 13, fullPart); //58-fullPart+30
|
||||
int fullPart = map(pitch, 200, 2000, 0, 58); //length of filled bargraph
|
||||
Robot.fill(255, 255, 255);
|
||||
Robot.rect(21, 30, 13, 58 - fullPart);
|
||||
Robot.fill(0, 0, 255);
|
||||
Robot.rect(21, 88 - fullPart, 13, fullPart); //58-fullPart+30
|
||||
|
||||
//draw the horizontal bargraph
|
||||
fullPart = map(tempo, 20, 100, 0, 58); // length of filled bargraph
|
||||
Robot.fill(255, 190, 0);
|
||||
Robot.fill(255, 190, 0);
|
||||
Robot.rect(53, 110, fullPart, 13);
|
||||
Robot.fill(255, 255, 255);
|
||||
Robot.rect(53+fullPart, 110, 58-fullPart, 13);
|
||||
Robot.fill(255, 255, 255);
|
||||
Robot.rect(53 + fullPart, 110, 58 - fullPart, 13);
|
||||
}
|
||||
|
||||
void keyDown(int keyCode) {
|
||||
// use a static int so it is persistent over time
|
||||
static int oldKey;
|
||||
switch(keyCode) {
|
||||
switch (keyCode) {
|
||||
case BUTTON_LEFT:
|
||||
//left button pressed, reduces tempo
|
||||
tempo -= 5;
|
||||
if(tempo < 20) tempo = 20; //lowest tempo 20
|
||||
Robot.fill(255,190,0);
|
||||
if (tempo < 20) tempo = 20; //lowest tempo 20
|
||||
Robot.fill(255, 190, 0);
|
||||
|
||||
Robot.rect(53, 58, 13, 13);
|
||||
break;
|
||||
case BUTTON_RIGHT:
|
||||
//right button pressed, increases tempo
|
||||
tempo += 5;
|
||||
if(tempo > 100) tempo = 100; //highest tempo 100
|
||||
Robot.fill(255,190,0);
|
||||
if (tempo > 100) tempo = 100; //highest tempo 100
|
||||
Robot.fill(255, 190, 0);
|
||||
Robot.rect(93, 58, 13, 13);
|
||||
break;
|
||||
case BUTTON_UP:
|
||||
//up button pressed, increases pitch
|
||||
pitch += 120;
|
||||
if(pitch > 2000) pitch = 2000;
|
||||
if (pitch > 2000) pitch = 2000;
|
||||
Robot.fill(0, 0, 255);
|
||||
|
||||
Robot.rect(73, 38, 13, 13);
|
||||
@ -106,8 +106,8 @@ void keyDown(int keyCode) {
|
||||
case BUTTON_DOWN:
|
||||
//down button pressed, reduces pitch
|
||||
pitch -= 120;
|
||||
if(pitch < 200){
|
||||
pitch = 200;
|
||||
if (pitch < 200) {
|
||||
pitch = 200;
|
||||
}
|
||||
Robot.fill(0, 0, 255);
|
||||
|
||||
@ -117,49 +117,49 @@ void keyDown(int keyCode) {
|
||||
//middle button pressed, resets tempo and pitch
|
||||
tempo = 60;
|
||||
pitch = 1000;
|
||||
Robot.fill(160,160,160);
|
||||
Robot.fill(160, 160, 160);
|
||||
|
||||
Robot.circle(79, 64, 6);
|
||||
break;
|
||||
case BUTTON_NONE:
|
||||
//Only when the keys are released(thus BUTTON_NONE is
|
||||
//encountered the first time), the interface will be
|
||||
//encountered the first time), the interface will be
|
||||
//re-drawn.
|
||||
if(oldKey != BUTTON_NONE){
|
||||
if (oldKey != BUTTON_NONE) {
|
||||
renderUI();
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(oldKey != keyCode) {
|
||||
if (oldKey != keyCode) {
|
||||
// change the song's tempo
|
||||
Robot.tempoWrite(tempo);
|
||||
// change the song's pitch
|
||||
Robot.tuneWrite(float(pitch/1000.0));
|
||||
Robot.tuneWrite(float(pitch / 1000.0));
|
||||
}
|
||||
oldKey = keyCode;
|
||||
}
|
||||
|
||||
//Draw a circle according to value
|
||||
//of the knob.
|
||||
//of the knob.
|
||||
void drawKnob(int val) {
|
||||
static int val_old;
|
||||
int r=map(val,0,1023,1,15);
|
||||
|
||||
//Only updates when the
|
||||
int r = map(val, 0, 1023, 1, 15);
|
||||
|
||||
//Only updates when the
|
||||
//value changes.
|
||||
if(val_old!=r){
|
||||
if (val_old != r) {
|
||||
Robot.noFill();
|
||||
|
||||
|
||||
//erase the old circle
|
||||
Robot.stroke(255, 255, 255);
|
||||
Robot.circle(26,116,r+1);
|
||||
|
||||
Robot.circle(26, 116, r + 1);
|
||||
|
||||
//draw the new circle
|
||||
Robot.stroke(255, 0, 255);
|
||||
Robot.circle(26,116,r);
|
||||
Robot.circle(26, 116, r);
|
||||
|
||||
Robot.stroke(0, 0, 0);
|
||||
|
||||
val_old=r;
|
||||
|
||||
val_old = r;
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
/* 6 Wheel Calibration
|
||||
*
|
||||
* Use this sketch to calibrate the wheels in your robot.
|
||||
* Your robot should drive as straight as possible when
|
||||
* Use this sketch to calibrate the wheels in your robot.
|
||||
* Your robot should drive as straight as possible when
|
||||
* putting both motors at the same speed.
|
||||
*
|
||||
* Run the software and follow the on-screen instructions.
|
||||
* Use the trimmer on the bottom board to make sure the
|
||||
* Run the software and follow the on-screen instructions.
|
||||
* Use the trimmer on the bottom board to make sure the
|
||||
* robot is working at its best!
|
||||
*
|
||||
* (c) 2013 X. Yang
|
||||
@ -14,7 +14,7 @@
|
||||
|
||||
#include <ArduinoRobot.h>
|
||||
|
||||
void setup(){
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Robot.begin();
|
||||
Robot.beginTFT();
|
||||
@ -22,17 +22,17 @@ void setup(){
|
||||
|
||||
Robot.setTextWrap(false);
|
||||
Robot.displayLogos();
|
||||
|
||||
writeAllScripts();
|
||||
|
||||
}
|
||||
void loop(){
|
||||
int val=map(Robot.knobRead(),0,1023,-255,255);
|
||||
Serial.println(val);
|
||||
Robot.motorsWrite(val,val);
|
||||
|
||||
int WC=map(Robot.trimRead(),0,1023,-20,20);
|
||||
Robot.debugPrint(WC,108,149);
|
||||
writeAllScripts();
|
||||
|
||||
}
|
||||
void loop() {
|
||||
int val = map(Robot.knobRead(), 0, 1023, -255, 255);
|
||||
Serial.println(val);
|
||||
Robot.motorsWrite(val, val);
|
||||
|
||||
int WC = map(Robot.trimRead(), 0, 1023, -20, 20);
|
||||
Robot.debugPrint(WC, 108, 149);
|
||||
delay(40);
|
||||
|
||||
}
|
||||
|
@ -1,20 +1,20 @@
|
||||
/* Runaway Robot
|
||||
|
||||
Play tag with your robot! With an ultrasonic
|
||||
Play tag with your robot! With an ultrasonic
|
||||
distance sensor, it's capable of detecting and avoiding
|
||||
obstacles, never bumping into walls again!
|
||||
|
||||
|
||||
You'll need to attach an untrasonic range finder to M1.
|
||||
|
||||
Circuit:
|
||||
* Arduino Robot
|
||||
* US range finder like Maxbotix EZ10, with analog output
|
||||
|
||||
|
||||
created 1 May 2013
|
||||
by X. Yang
|
||||
modified 12 May 2013
|
||||
by D. Cuartielles
|
||||
|
||||
|
||||
This example is in the public domain
|
||||
*/
|
||||
|
||||
@ -30,14 +30,14 @@ void setup() {
|
||||
Robot.beginTFT();
|
||||
Robot.beginSD();
|
||||
Robot.displayLogos();
|
||||
|
||||
|
||||
// draw a face on the LCD screen
|
||||
setFace(true);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// If the robot is blocked, turn until free
|
||||
while(getDistance() < 40) { // If an obstacle is less than 20cm away
|
||||
while (getDistance() < 40) { // If an obstacle is less than 20cm away
|
||||
setFace(false); //shows an unhappy face
|
||||
Robot.motorsStop(); // stop the motors
|
||||
delay(1000); // wait for a moment
|
||||
@ -45,7 +45,7 @@ void loop() {
|
||||
setFace(true); // happy face
|
||||
}
|
||||
// if there are no objects in the way, keep moving
|
||||
Robot.motorsWrite(255, 255);
|
||||
Robot.motorsWrite(255, 255);
|
||||
delay(100);
|
||||
}
|
||||
|
||||
@ -54,20 +54,20 @@ float getDistance() {
|
||||
// read the value from the sensor
|
||||
int sensorValue = Robot.analogRead(sensorPin);
|
||||
//Convert the sensor input to cm.
|
||||
float distance_cm = sensorValue*1.27;
|
||||
return distance_cm;
|
||||
float distance_cm = sensorValue * 1.27;
|
||||
return distance_cm;
|
||||
}
|
||||
|
||||
// make a happy or sad face
|
||||
void setFace(boolean onOff) {
|
||||
if(onOff) {
|
||||
if (onOff) {
|
||||
// if true show a happy face
|
||||
Robot.background(0, 0, 255);
|
||||
Robot.setCursor(44, 60);
|
||||
Robot.stroke(0, 255, 0);
|
||||
Robot.setTextSize(4);
|
||||
Robot.print(":)");
|
||||
}else{
|
||||
} else {
|
||||
// if false show an upset face
|
||||
Robot.background(255, 0, 0);
|
||||
Robot.setCursor(44, 60);
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* 08 Remote Control
|
||||
|
||||
If you connect a IR receiver to the robot,
|
||||
you can control it like a RC car.
|
||||
Using the remote control comes with sensor
|
||||
pack, You can make the robot move around
|
||||
|
||||
If you connect a IR receiver to the robot,
|
||||
you can control it like a RC car.
|
||||
Using the remote control comes with sensor
|
||||
pack, You can make the robot move around
|
||||
without even touching it!
|
||||
|
||||
Circuit:
|
||||
Circuit:
|
||||
* Arduino Robot
|
||||
* Connect the IRreceiver to D2
|
||||
* Remote control from Robot sensor pack
|
||||
@ -14,12 +14,12 @@
|
||||
based on the IRremote library
|
||||
by Ken Shirriff
|
||||
http://arcfn.com
|
||||
|
||||
|
||||
created 1 May 2013
|
||||
by X. Yang
|
||||
modified 12 May 2013
|
||||
by D. Cuartielles
|
||||
|
||||
|
||||
This example is in the public domain
|
||||
*/
|
||||
|
||||
@ -35,12 +35,12 @@
|
||||
#define IR_CODE_TURN_RIGHT 284127885
|
||||
#define IR_CODE_CONTINUE -1
|
||||
|
||||
boolean isActing=false; //If the robot is executing command from remote
|
||||
long timer;
|
||||
const long TIME_OUT=150;
|
||||
boolean isActing = false; //If the robot is executing command from remote
|
||||
long timer;
|
||||
const long TIME_OUT = 150;
|
||||
|
||||
void setup() {
|
||||
// initialize the Robot, SD card, display, and speaker
|
||||
// initialize the Robot, SD card, display, and speaker
|
||||
Serial.begin(9600);
|
||||
Robot.begin();
|
||||
Robot.beginTFT();
|
||||
@ -56,36 +56,36 @@ void loop() {
|
||||
processResult();
|
||||
resumeIRremote(); // resume receiver
|
||||
}
|
||||
|
||||
|
||||
//If the robot does not receive any command, stop it
|
||||
if(isActing && (millis()-timer>=TIME_OUT)){
|
||||
if (isActing && (millis() - timer >= TIME_OUT)) {
|
||||
Robot.motorsStop();
|
||||
isActing=false;
|
||||
isActing = false;
|
||||
}
|
||||
}
|
||||
void processResult() {
|
||||
unsigned long res = getIRresult();
|
||||
switch(res){
|
||||
switch (res) {
|
||||
case IR_CODE_FORWARD:
|
||||
changeAction(1,1); //Move the robot forward
|
||||
changeAction(1, 1); //Move the robot forward
|
||||
break;
|
||||
case IR_CODE_BACKWARDS:
|
||||
changeAction(-1,-1); //Move the robot backwards
|
||||
changeAction(-1, -1); //Move the robot backwards
|
||||
break;
|
||||
case IR_CODE_TURN_LEFT:
|
||||
changeAction(-0.5,0.5); //Turn the robot left
|
||||
changeAction(-0.5, 0.5); //Turn the robot left
|
||||
break;
|
||||
case IR_CODE_TURN_RIGHT:
|
||||
changeAction(0.5,-0.5); //Turn the robot Right
|
||||
changeAction(0.5, -0.5); //Turn the robot Right
|
||||
break;
|
||||
case IR_CODE_CONTINUE:
|
||||
timer=millis(); //Continue the last action, reset timer
|
||||
timer = millis(); //Continue the last action, reset timer
|
||||
break;
|
||||
}
|
||||
}
|
||||
void changeAction(float directionLeft, float directionRight){
|
||||
Robot.motorsWrite(255*directionLeft, 255*directionRight);
|
||||
timer=millis();
|
||||
isActing=true;
|
||||
void changeAction(float directionLeft, float directionRight) {
|
||||
Robot.motorsWrite(255 * directionLeft, 255 * directionRight);
|
||||
timer = millis();
|
||||
isActing = true;
|
||||
}
|
||||
|
||||
|
@ -1,25 +1,25 @@
|
||||
/* Picture Browser
|
||||
|
||||
You can make your own gallery/picture show with the
|
||||
Robot. Put some pictures on the SD card, start the
|
||||
sketch, they will diplay on the screen.
|
||||
|
||||
Use the left/right buttons to navigate through the
|
||||
previous and next images.
|
||||
|
||||
Press up or down to enter a mode where you change
|
||||
You can make your own gallery/picture show with the
|
||||
Robot. Put some pictures on the SD card, start the
|
||||
sketch, they will diplay on the screen.
|
||||
|
||||
Use the left/right buttons to navigate through the
|
||||
previous and next images.
|
||||
|
||||
Press up or down to enter a mode where you change
|
||||
the pictures by rotating the robot.
|
||||
|
||||
You can add your own pictures onto the SD card, and
|
||||
|
||||
You can add your own pictures onto the SD card, and
|
||||
view them in the Robot's gallery!
|
||||
|
||||
Pictures must be uncompressed BMP, 24-bit color depth,
|
||||
Pictures must be uncompressed BMP, 24-bit color depth,
|
||||
160 pixels wide, and 128 pixels tall.
|
||||
|
||||
They should be named as "picN.bmp". Replace 'N' with a
|
||||
|
||||
They should be named as "picN.bmp". Replace 'N' with a
|
||||
number between 0 and 9.
|
||||
|
||||
The current code only supports 10 pictures. How would you
|
||||
The current code only supports 10 pictures. How would you
|
||||
improve it to handle more?
|
||||
|
||||
Circuit:
|
||||
@ -29,7 +29,7 @@
|
||||
by X. Yang
|
||||
modified 12 May 2013
|
||||
by D. Cuartielles
|
||||
|
||||
|
||||
This example is in the public domain
|
||||
*/
|
||||
|
||||
@ -49,14 +49,14 @@ int mode = 0; // Current mode
|
||||
char modeNames[][9] = { "keyboard", "tilt " };
|
||||
|
||||
void setup() {
|
||||
// initialize the Robot, SD card, display, and speaker
|
||||
// initialize the Robot, SD card, display, and speaker
|
||||
Robot.beginSD();
|
||||
Robot.beginTFT();
|
||||
Robot.begin();
|
||||
|
||||
// draw "lg0.bmp" and "lg1.bmp" on the screen
|
||||
|
||||
// draw "lg0.bmp" and "lg1.bmp" on the screen
|
||||
Robot.displayLogos();
|
||||
|
||||
|
||||
// draw init3.bmp from the SD card on the screen
|
||||
Robot.drawBMP("init3.bmp", 0, 0);
|
||||
|
||||
@ -71,10 +71,10 @@ void setup() {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
buffer[3] = '0'+i;// change filename of the img to be displayed
|
||||
buffer[3] = '0' + i; // change filename of the img to be displayed
|
||||
Robot.drawBMP(buffer, 0, 0); // draw the file on the screen
|
||||
// change control modes
|
||||
switch(mode) {
|
||||
switch (mode) {
|
||||
case CONTROL_MODE_COMPASS:
|
||||
compassControl(3);
|
||||
break;
|
||||
@ -87,15 +87,15 @@ void loop() {
|
||||
|
||||
void keyboardControl() {
|
||||
//Use buttons to control the gallery
|
||||
while(true) {
|
||||
while (true) {
|
||||
int keyPressed = Robot.keyboardRead(); // read the button values
|
||||
switch(keyPressed) {
|
||||
switch (keyPressed) {
|
||||
case BUTTON_LEFT: // display previous picture
|
||||
if(--i < 1) i = NUM_PICS;
|
||||
if (--i < 1) i = NUM_PICS;
|
||||
return;
|
||||
case BUTTON_MIDDLE: // do nothing
|
||||
case BUTTON_RIGHT: // display next picture
|
||||
if(++i > NUM_PICS) i = 1;
|
||||
if (++i > NUM_PICS) i = 1;
|
||||
return;
|
||||
case BUTTON_UP: // change mode
|
||||
changeMode(-1);
|
||||
@ -110,23 +110,23 @@ void keyboardControl() {
|
||||
// if controlling by the compass
|
||||
void compassControl(int change) {
|
||||
// Rotate the robot to change the pictures
|
||||
while(true) {
|
||||
while (true) {
|
||||
// read the value of the compass
|
||||
int oldV = Robot.compassRead();
|
||||
|
||||
|
||||
//get the change of angle
|
||||
int diff = Robot.compassRead()-oldV;
|
||||
if(diff > 180) diff -= 360;
|
||||
else if(diff < -180) diff += 360;
|
||||
|
||||
if(abs(diff) > change) {
|
||||
if(++i > NUM_PICS) i = 1;
|
||||
int diff = Robot.compassRead() - oldV;
|
||||
if (diff > 180) diff -= 360;
|
||||
else if (diff < -180) diff += 360;
|
||||
|
||||
if (abs(diff) > change) {
|
||||
if (++i > NUM_PICS) i = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// chage modes, if buttons are pressed
|
||||
int keyPressed = Robot.keyboardRead();
|
||||
switch(keyPressed) {
|
||||
switch (keyPressed) {
|
||||
case BUTTON_UP:
|
||||
changeMode(-1);
|
||||
return;
|
||||
@ -142,13 +142,13 @@ void compassControl(int change) {
|
||||
void changeMode(int changeDir) {
|
||||
// alternate modes
|
||||
mode += changeDir;
|
||||
if(mode < 0) {
|
||||
if (mode < 0) {
|
||||
mode = 1;
|
||||
} else if(mode > 1)
|
||||
mode=0;
|
||||
|
||||
// display the mode on screen
|
||||
Robot.fill(255, 255, 255);
|
||||
} else if (mode > 1)
|
||||
mode = 0;
|
||||
|
||||
// display the mode on screen
|
||||
Robot.fill(255, 255, 255);
|
||||
Robot.stroke(255, 255, 255);
|
||||
Robot.rect(0, 0, 128, 12);
|
||||
Robot.stroke(0, 0, 0);
|
||||
|
@ -1,8 +1,8 @@
|
||||
/* Robot Rescue
|
||||
|
||||
In this example, the robot enters the line following mode and
|
||||
plays some music until it reaches its target. Once it finds the
|
||||
target, it pushes it out of the track. It then returns to the
|
||||
plays some music until it reaches its target. Once it finds the
|
||||
target, it pushes it out of the track. It then returns to the
|
||||
track and looks for a second target.
|
||||
|
||||
You can make the robot push as many objects as you want to, just
|
||||
@ -18,20 +18,20 @@
|
||||
by X. Yang
|
||||
modified 12 May 2013
|
||||
by D. Cuartielles
|
||||
|
||||
|
||||
This example is in the public domain
|
||||
*/
|
||||
|
||||
#include <ArduinoRobot.h> // include the robot library
|
||||
|
||||
void setup(){
|
||||
// initialize the Robot, SD card, display, and speaker
|
||||
void setup() {
|
||||
// initialize the Robot, SD card, display, and speaker
|
||||
Robot.begin();
|
||||
Robot.beginTFT();
|
||||
Robot.beginSD();
|
||||
Robot.beginSpeaker();
|
||||
|
||||
// draw "lg0.bmp" and "lg1.bmp" on the screen
|
||||
|
||||
// draw "lg0.bmp" and "lg1.bmp" on the screen
|
||||
Robot.displayLogos();
|
||||
|
||||
// display the line following instructional image from the SD card
|
||||
@ -51,13 +51,13 @@ void setup(){
|
||||
Robot.rect(0, 0, 128, 80); // erase the previous text
|
||||
Robot.stroke(0, 0, 0);
|
||||
Robot.text("Start", 5, 5);
|
||||
|
||||
|
||||
// use this to calibrate the line following algorithm
|
||||
// uncomment one or the other to see the different behaviors of the robot
|
||||
// Robot.lineFollowConfig(14, 9, 50, 10);
|
||||
Robot.lineFollowConfig(11, 7, 60, 5);
|
||||
|
||||
// run the rescue sequence
|
||||
|
||||
// run the rescue sequence
|
||||
rescueSequence();
|
||||
Robot.text("Found obstacle", 5, 12);
|
||||
// find the track again
|
||||
@ -66,24 +66,24 @@ void setup(){
|
||||
// run the rescue sequence a second time
|
||||
rescueSequence();
|
||||
Robot.text("Found obstacle", 5, 26);
|
||||
|
||||
|
||||
// here you could go on ...
|
||||
|
||||
|
||||
// write status on the screen
|
||||
Robot.stroke(0, 0, 0);
|
||||
Robot.text("Done!", 5, 25);
|
||||
}
|
||||
|
||||
void loop(){
|
||||
void loop() {
|
||||
//nothing here, the program only runs once.
|
||||
}
|
||||
|
||||
// run the sequence
|
||||
void rescueSequence(){
|
||||
void rescueSequence() {
|
||||
//set the motor board into line-follow mode
|
||||
Robot.setMode(MODE_LINE_FOLLOW);
|
||||
|
||||
while(!Robot.isActionDone()){ // wait until it is no longer following the line
|
||||
Robot.setMode(MODE_LINE_FOLLOW);
|
||||
|
||||
while (!Robot.isActionDone()) { // wait until it is no longer following the line
|
||||
}
|
||||
delay(1000);
|
||||
|
||||
@ -92,32 +92,32 @@ void rescueSequence(){
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void doRescue(){
|
||||
void doRescue() {
|
||||
// Reached the endline, engage the target
|
||||
Robot.motorsWrite(200,200);
|
||||
Robot.motorsWrite(200, 200);
|
||||
delay(250);
|
||||
Robot.motorsStop();
|
||||
delay(1000);
|
||||
|
||||
// Turn the robot
|
||||
// Turn the robot
|
||||
Robot.turn(90);
|
||||
Robot.motorsStop();
|
||||
delay(1000);
|
||||
|
||||
|
||||
// Move forward
|
||||
Robot.motorsWrite(200,200);
|
||||
Robot.motorsWrite(200, 200);
|
||||
delay(500);
|
||||
Robot.motorsStop();
|
||||
delay(1000);
|
||||
|
||||
|
||||
// move backwards, leave the target
|
||||
Robot.motorsWrite(-200,-200);
|
||||
Robot.motorsWrite(-200, -200);
|
||||
delay(500);
|
||||
Robot.motorsStop();
|
||||
}
|
||||
|
||||
void goToNext(){
|
||||
// Turn the robot
|
||||
void goToNext() {
|
||||
// Turn the robot
|
||||
Robot.turn(-90);
|
||||
Robot.motorsStop();
|
||||
delay(1000);
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* Hello User
|
||||
|
||||
Hello User! This sketch is the first thing you see
|
||||
when starting this robot. It gives you a warm welcome,
|
||||
showing you some of the really amazing abilities of
|
||||
the robot, and make itself really personal to you.
|
||||
Hello User! This sketch is the first thing you see
|
||||
when starting this robot. It gives you a warm welcome,
|
||||
showing you some of the really amazing abilities of
|
||||
the robot, and make itself really personal to you.
|
||||
|
||||
Circuit:
|
||||
* Arduino Robot
|
||||
@ -12,18 +12,18 @@
|
||||
by X. Yang
|
||||
modified 12 May 2013
|
||||
by D. Cuartielles
|
||||
|
||||
|
||||
This example is in the public domain
|
||||
*/
|
||||
|
||||
#include <ArduinoRobot.h> // include the robot library
|
||||
// include the utility function for ths sketch
|
||||
// see the details below
|
||||
#include <utility/RobotTextManager.h>
|
||||
#include <utility/RobotTextManager.h>
|
||||
|
||||
char buffer[20];//for storing user name
|
||||
|
||||
void setup(){
|
||||
void setup() {
|
||||
//necessary initialization sequence
|
||||
Robot.begin();
|
||||
Robot.beginTFT();
|
||||
@ -31,19 +31,19 @@ void setup(){
|
||||
|
||||
// show the logos from the SD card
|
||||
Robot.displayLogos();
|
||||
|
||||
|
||||
// clear the screen
|
||||
Robot.clearScreen();
|
||||
|
||||
// From now on, display different slides of
|
||||
|
||||
// From now on, display different slides of
|
||||
// text/pictures in sequence. The so-called
|
||||
// scripts are strings of text stored in the
|
||||
// robot's memory
|
||||
|
||||
|
||||
// these functions are explained below
|
||||
|
||||
|
||||
//Script 6
|
||||
textManager.writeScript(5, 4, 0);
|
||||
textManager.writeScript(5, 4, 0);
|
||||
textManager.writeScript(9, 10, 0);
|
||||
Robot.waitContinue();
|
||||
delay(500);
|
||||
@ -59,7 +59,7 @@ void setup(){
|
||||
//Script 8
|
||||
// this function enables sound and images at once
|
||||
textManager.showPicture("init2.bmp", 0, 0);
|
||||
|
||||
|
||||
textManager.writeScript(7, 2, 0);
|
||||
textManager.writeScript(9, 7, 0);
|
||||
Robot.waitContinue();
|
||||
@ -84,56 +84,56 @@ void setup(){
|
||||
//Input screen
|
||||
textManager.writeScript(0, 1, 1);
|
||||
textManager.input(3, 1, USERNAME);
|
||||
|
||||
|
||||
textManager.writeScript(1, 5, 1);
|
||||
textManager.input(7, 1, ROBOTNAME);
|
||||
|
||||
delay(1000);
|
||||
Robot.clearScreen();
|
||||
|
||||
|
||||
//last screen
|
||||
textManager.showPicture("init4.bmp", 0, 0);
|
||||
textManager.writeText(1, 2, "Hello");
|
||||
Robot.userNameRead(buffer);
|
||||
textManager.writeText(3, 2, buffer);
|
||||
|
||||
textManager.writeScript(4,10,0);
|
||||
textManager.writeScript(4, 10, 0);
|
||||
|
||||
Robot.waitContinue(BUTTON_LEFT);
|
||||
Robot.waitContinue(BUTTON_RIGHT);
|
||||
textManager.showPicture("kt1.bmp", 0, 0);
|
||||
}
|
||||
|
||||
void loop(){
|
||||
void loop() {
|
||||
// do nothing here
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
textManager mostly contains helper functions for
|
||||
textManager mostly contains helper functions for
|
||||
R06_Wheel_Calibration and R01_Hello_User.
|
||||
|
||||
The ones used in this example:
|
||||
textManager.setMargin(margin_left, margin_top):
|
||||
Configure the left and top margin for text
|
||||
display. The margins will be used for
|
||||
display. The margins will be used for
|
||||
textManager.writeText().
|
||||
Parameters:
|
||||
margin_left, margin_top: the margin values
|
||||
from the top and left side of the screen.
|
||||
Returns:
|
||||
none
|
||||
|
||||
|
||||
textManager.writeScript(script_number,line,column):
|
||||
Display a script of Hello User example.
|
||||
Display a script of Hello User example.
|
||||
Parameters:
|
||||
script_number: an int value representing the
|
||||
script_number: an int value representing the
|
||||
script to be displayed.
|
||||
line, column: in which line,column is the script
|
||||
displayed. Same as writeText().
|
||||
Returns:
|
||||
none
|
||||
|
||||
|
||||
textManager.input(line,column,codename):
|
||||
Print an input indicator(">") in the line and column,
|
||||
dispaly and receive input from a virtual keyboard,
|
||||
@ -147,9 +147,9 @@ The ones used in this example:
|
||||
to access the values later.
|
||||
Returns:
|
||||
none;
|
||||
|
||||
|
||||
textManager.writeText(line,column,text):
|
||||
Display text on the specific line and column.
|
||||
Display text on the specific line and column.
|
||||
It's different from Robot.text() as the later
|
||||
uses pixels for positioning the text.
|
||||
Parameters:
|
||||
@ -160,18 +160,18 @@ The ones used in this example:
|
||||
text:a char array(string) of the text to be displayed.
|
||||
Returns:
|
||||
none
|
||||
|
||||
|
||||
textManager.showPicture(filename, x, y):
|
||||
It has the same functionality as Robot.drawPicture(),
|
||||
while fixing the conflict between drawPicture() and
|
||||
while fixing the conflict between drawPicture() and
|
||||
sound playing. Using Robot.drawPicture(), it'll have
|
||||
glitches when playing sound at the same time. Using
|
||||
showPicture(), it'll stop sound when displaying
|
||||
showPicture(), it'll stop sound when displaying
|
||||
picture, so preventing the problem.
|
||||
Parameters:
|
||||
filename:string, name of the bmp file in sd
|
||||
x,y: int values, position of the picture
|
||||
Returns:
|
||||
none
|
||||
|
||||
none
|
||||
|
||||
*/
|
||||
|
@ -1,24 +1,24 @@
|
||||
/*
|
||||
All IO Ports
|
||||
|
||||
|
||||
This example goes through all the IO ports on your robot and
|
||||
reads/writes from/to them. Uncomment the different lines inside
|
||||
reads/writes from/to them. Uncomment the different lines inside
|
||||
the loop to test the different possibilities.
|
||||
|
||||
The M inputs on the Control Board are multiplexed and therefore
|
||||
The M inputs on the Control Board are multiplexed and therefore
|
||||
it is not recommended to use them as outputs. The D pins on the
|
||||
Control Board as well as the D pins on the Motor Board go directly
|
||||
to the microcontroller and therefore can be used both as inputs
|
||||
to the microcontroller and therefore can be used both as inputs
|
||||
and outputs.
|
||||
|
||||
|
||||
Circuit:
|
||||
* Arduino Robot
|
||||
|
||||
|
||||
created 1 May 2013
|
||||
by X. Yang
|
||||
modified 12 May 2013
|
||||
by D. Cuartielles
|
||||
|
||||
|
||||
This example is in the public domain
|
||||
*/
|
||||
|
||||
@ -29,7 +29,7 @@ uint8_t arr[] = { M0, M1, M2, M3, M4, M5, M6, M7 };
|
||||
uint8_t arr2[] = { D0, D1, D2, D3, D4, D5 };
|
||||
uint8_t arr3[] = { D7, D8, D9, D10 };
|
||||
|
||||
void setup(){
|
||||
void setup() {
|
||||
// initialize the robot
|
||||
Robot.begin();
|
||||
|
||||
@ -37,8 +37,8 @@ void setup(){
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop(){
|
||||
// read all the D inputs at the Motor Board as analog
|
||||
void loop() {
|
||||
// read all the D inputs at the Motor Board as analog
|
||||
//analogReadB_Ds();
|
||||
|
||||
// read all the D inputs at the Motor Board as digital
|
||||
@ -61,12 +61,12 @@ void loop(){
|
||||
|
||||
// write all the D outputs at the Control Board as digital
|
||||
//digitalWriteT_Ds();
|
||||
delay(40);
|
||||
delay(40);
|
||||
}
|
||||
|
||||
// read all M inputs on the Control Board as analog inputs
|
||||
void analogReadMs() {
|
||||
for(int i=0;i<8;i++) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
Serial.print(Robot.analogRead(arr[i]));
|
||||
Serial.print(",");
|
||||
}
|
||||
@ -75,7 +75,7 @@ void analogReadMs() {
|
||||
|
||||
// read all M inputs on the Control Board as digital inputs
|
||||
void digitalReadMs() {
|
||||
for(int i=0;i<8;i++) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
Serial.print(Robot.digitalRead(arr[i]));
|
||||
Serial.print(",");
|
||||
}
|
||||
@ -84,7 +84,7 @@ void digitalReadMs() {
|
||||
|
||||
// read all D inputs on the Control Board as analog inputs
|
||||
void analogReadT_Ds() {
|
||||
for(int i=0; i<6; i++) {
|
||||
for (int i = 0; i < 6; i++) {
|
||||
Serial.print(Robot.analogRead(arr2[i]));
|
||||
Serial.print(",");
|
||||
}
|
||||
@ -93,7 +93,7 @@ void analogReadT_Ds() {
|
||||
|
||||
// read all D inputs on the Control Board as digital inputs
|
||||
void digitalReadT_Ds() {
|
||||
for(int i=0; i<6; i++) {
|
||||
for (int i = 0; i < 6; i++) {
|
||||
Serial.print(Robot.digitalRead(arr2[i]));
|
||||
Serial.print(",");
|
||||
}
|
||||
@ -103,13 +103,13 @@ void digitalReadT_Ds() {
|
||||
// write all D outputs on the Control Board as digital outputs
|
||||
void digitalWriteT_Ds() {
|
||||
// turn all the pins on
|
||||
for(int i=0; i<6; i++) {
|
||||
for (int i = 0; i < 6; i++) {
|
||||
Robot.digitalWrite(arr2[i], HIGH);
|
||||
}
|
||||
delay(500);
|
||||
|
||||
// turn all the pins off
|
||||
for(int i=0; i<6; i++){
|
||||
for (int i = 0; i < 6; i++) {
|
||||
Robot.digitalWrite(arr2[i], LOW);
|
||||
}
|
||||
delay(500);
|
||||
@ -118,13 +118,13 @@ void digitalWriteT_Ds() {
|
||||
// write all D outputs on the Motor Board as digital outputs
|
||||
void digitalWriteB_Ds() {
|
||||
// turn all the pins on
|
||||
for(int i=0; i<4; i++) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
Robot.digitalWrite(arr3[i], HIGH);
|
||||
}
|
||||
delay(500);
|
||||
|
||||
// turn all the pins off
|
||||
for(int i=0; i<4; i++) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
Robot.digitalWrite(arr3[i], LOW);
|
||||
}
|
||||
delay(500);
|
||||
@ -132,7 +132,7 @@ void digitalWriteB_Ds() {
|
||||
|
||||
// read all D inputs on the Motor Board as analog inputs
|
||||
void analogReadB_Ds() {
|
||||
for(int i=0; i<4; i++) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
Serial.print(Robot.analogRead(arr3[i]));
|
||||
Serial.print(",");
|
||||
}
|
||||
@ -141,7 +141,7 @@ void analogReadB_Ds() {
|
||||
|
||||
// read all D inputs on the Motor Board as digital inputs
|
||||
void digitalReadB_Ds() {
|
||||
for(int i=0; i<4; i++) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
Serial.print(Robot.digitalRead(arr3[i]));
|
||||
Serial.print(",");
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Beep
|
||||
|
||||
|
||||
Test different pre-configured beeps on
|
||||
the robot's speaker.
|
||||
|
||||
@ -8,15 +8,15 @@
|
||||
- BEEP_SIMPLE
|
||||
- BEEP_DOUBLE
|
||||
- BEEP_LONG
|
||||
|
||||
|
||||
Circuit:
|
||||
* Arduino Robot
|
||||
|
||||
|
||||
created 1 May 2013
|
||||
by X. Yang
|
||||
modified 12 May 2013
|
||||
by D. Cuartielles
|
||||
|
||||
|
||||
This example is in the public domain
|
||||
*/
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Clean EEPROM
|
||||
|
||||
|
||||
This example erases the user information stored on the
|
||||
external EEPROM memory chip on your robot.
|
||||
|
||||
@ -11,21 +11,21 @@
|
||||
|
||||
EEPROMs shouldn't be rewritten too often, therefore the
|
||||
code runs only during setup and not inside loop.
|
||||
|
||||
|
||||
Circuit:
|
||||
* Arduino Robot
|
||||
|
||||
|
||||
created 1 May 2013
|
||||
by X. Yang
|
||||
modified 12 May 2013
|
||||
by D. Cuartielles
|
||||
|
||||
|
||||
This example is in the public domain
|
||||
*/
|
||||
|
||||
#include <ArduinoRobot.h>
|
||||
|
||||
void setup(){
|
||||
void setup() {
|
||||
// initialize the robot
|
||||
Robot.begin();
|
||||
|
||||
@ -33,9 +33,9 @@ void setup(){
|
||||
Robot.userNameWrite("");
|
||||
Robot.robotNameWrite("");
|
||||
Robot.cityNameWrite("");
|
||||
Robot.countryNameWrite("");
|
||||
Robot.countryNameWrite("");
|
||||
}
|
||||
|
||||
void loop(){
|
||||
// do nothing
|
||||
void loop() {
|
||||
// do nothing
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
Compass
|
||||
|
||||
|
||||
Try the compass both on the robot's TFT
|
||||
and through the serial port.
|
||||
|
||||
|
||||
Circuit:
|
||||
* Arduino Robot
|
||||
|
||||
|
||||
created 1 May 2013
|
||||
by X. Yang
|
||||
modified 12 May 2013
|
||||
by D. Cuartielles
|
||||
|
||||
|
||||
This example is in the public domain
|
||||
*/
|
||||
|
||||
@ -33,8 +33,8 @@ void loop() {
|
||||
int compass = Robot.compassRead();
|
||||
|
||||
// print out the sensor's value
|
||||
Serial.println(compass);
|
||||
|
||||
Serial.println(compass);
|
||||
|
||||
// show the value on the robot's screen
|
||||
Robot.drawCompass(compass);
|
||||
}
|
||||
|
@ -1,29 +1,29 @@
|
||||
/*
|
||||
IR array
|
||||
|
||||
Read the analog value of the IR sensors at the
|
||||
bottom of the robot. The also-called line following
|
||||
|
||||
Read the analog value of the IR sensors at the
|
||||
bottom of the robot. The also-called line following
|
||||
sensors are a series of pairs of IR sender/receiver
|
||||
used to detect how dark it is underneath the robot.
|
||||
|
||||
The information coming from the sensor array is stored
|
||||
into the Robot.IRarray[] and updated using the Robot.updateIR()
|
||||
method.
|
||||
|
||||
|
||||
Circuit:
|
||||
* Arduino Robot
|
||||
|
||||
|
||||
created 1 May 2013
|
||||
by X. Yang
|
||||
modified 12 May 2013
|
||||
by D. Cuartielles
|
||||
|
||||
|
||||
This example is in the public domain
|
||||
*/
|
||||
|
||||
#include <ArduinoRobot.h>
|
||||
|
||||
void setup(){
|
||||
void setup() {
|
||||
// initialize the robot
|
||||
Robot.begin();
|
||||
|
||||
@ -31,12 +31,12 @@ void setup(){
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop(){
|
||||
// store the sensor information into the array
|
||||
void loop() {
|
||||
// store the sensor information into the array
|
||||
Robot.updateIR();
|
||||
|
||||
// iterate the array and print the data to the Serial port
|
||||
for(int i=0; i<5; i++){
|
||||
for (int i = 0; i < 5; i++) {
|
||||
Serial.print(Robot.IRarray[i]);
|
||||
Serial.print(" ");
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
LCD Debug Print
|
||||
|
||||
|
||||
Use the Robot's library function debugPrint() to
|
||||
quickly send a sensor reading to the robot's creen.
|
||||
|
||||
|
||||
Circuit:
|
||||
* Arduino Robot
|
||||
|
||||
|
||||
created 1 May 2013
|
||||
by X. Yang
|
||||
modified 12 May 2013
|
||||
by D. Cuartielles
|
||||
|
||||
|
||||
This example is in the public domain
|
||||
*/
|
||||
|
||||
@ -26,7 +26,7 @@ void setup() {
|
||||
// initialize the screen
|
||||
Robot.beginTFT();
|
||||
}
|
||||
void loop(){
|
||||
void loop() {
|
||||
// read a value
|
||||
value = analogRead(A4);
|
||||
|
||||
|
@ -1,16 +1,16 @@
|
||||
/*
|
||||
LCD Print
|
||||
|
||||
|
||||
Print the reading from a sensor to the screen.
|
||||
|
||||
|
||||
Circuit:
|
||||
* Arduino Robot
|
||||
|
||||
|
||||
created 1 May 2013
|
||||
by X. Yang
|
||||
modified 12 May 2013
|
||||
by D. Cuartielles
|
||||
|
||||
|
||||
This example is in the public domain
|
||||
*/
|
||||
|
||||
@ -28,17 +28,17 @@ void setup() {
|
||||
|
||||
void loop() {
|
||||
// read a analog port
|
||||
value=Robot.analogRead(TK4);
|
||||
value = Robot.analogRead(TK4);
|
||||
|
||||
// write the sensor value on the screen
|
||||
Robot.stroke(0, 255, 0);
|
||||
Robot.textSize(1);
|
||||
Robot.text(value, 0, 0);
|
||||
Robot.text(value, 0, 0);
|
||||
|
||||
delay(500);
|
||||
|
||||
// erase the previous text on the screen
|
||||
Robot.stroke(255, 255, 255);
|
||||
Robot.textSize(1);
|
||||
Robot.text(value, 0, 0);
|
||||
Robot.text(value, 0, 0);
|
||||
}
|
||||
|
@ -1,19 +1,19 @@
|
||||
/*
|
||||
LCD Write Text
|
||||
|
||||
|
||||
Use the Robot's library function text() to
|
||||
print out text to the robot's screen. Take
|
||||
into account that you need to erase the
|
||||
information before continuing writing.
|
||||
|
||||
|
||||
Circuit:
|
||||
* Arduino Robot
|
||||
|
||||
|
||||
created 1 May 2013
|
||||
by X. Yang
|
||||
modified 12 May 2013
|
||||
by D. Cuartielles
|
||||
|
||||
|
||||
This example is in the public domain
|
||||
*/
|
||||
|
||||
@ -32,7 +32,7 @@ void loop() {
|
||||
delay(2000);
|
||||
Robot.stroke(255, 255, 255); // choose the color white
|
||||
Robot.text("Hello World", 0, 0); // writing text in the same color as the BG erases the text!
|
||||
|
||||
|
||||
Robot.stroke(0, 0, 0); // choose the color black
|
||||
Robot.text("I am a robot", 0, 0); // print the text
|
||||
delay(3000);
|
||||
|
@ -1,22 +1,22 @@
|
||||
/*
|
||||
Line Following with Pause
|
||||
|
||||
|
||||
As the robot has two processors, one to command the motors and one to
|
||||
take care of the screen and user input, it is possible to write
|
||||
take care of the screen and user input, it is possible to write
|
||||
programs that put one part of the robot to do something and get the
|
||||
other half to control it.
|
||||
|
||||
This example shows how the Control Board assigns the Motor one to
|
||||
follow a line, but asks it to stop every 3 seconds.
|
||||
|
||||
|
||||
Circuit:
|
||||
* Arduino Robot
|
||||
|
||||
|
||||
created 1 May 2013
|
||||
by X. Yang
|
||||
modified 12 May 2013
|
||||
by D. Cuartielles
|
||||
|
||||
|
||||
This example is in the public domain
|
||||
*/
|
||||
|
||||
@ -37,13 +37,13 @@ void setup() {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// tell the robot to take a break and stop
|
||||
Robot.pauseMode(true);
|
||||
Robot.debugPrint('p');
|
||||
delay(3000);
|
||||
// tell the robot to take a break and stop
|
||||
Robot.pauseMode(true);
|
||||
Robot.debugPrint('p');
|
||||
delay(3000);
|
||||
|
||||
// tell the robot to move on
|
||||
Robot.pauseMode(false);
|
||||
Robot.debugPrint('>');
|
||||
delay(3000);
|
||||
// tell the robot to move on
|
||||
Robot.pauseMode(false);
|
||||
Robot.debugPrint('>');
|
||||
delay(3000);
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*
|
||||
Melody
|
||||
|
||||
Plays a melody stored in a string.
|
||||
|
||||
|
||||
Plays a melody stored in a string.
|
||||
|
||||
The notes and durations are encoded as follows:
|
||||
|
||||
NOTES:
|
||||
@ -31,12 +31,12 @@
|
||||
|
||||
Circuit:
|
||||
* Arduino Robot
|
||||
|
||||
|
||||
created 1 May 2013
|
||||
by X. Yang
|
||||
modified 12 May 2013
|
||||
by D. Cuartielles
|
||||
|
||||
|
||||
This example is in the public domain
|
||||
|
||||
This code uses the Squawk sound library designed by STG. For
|
||||
|
@ -1,16 +1,16 @@
|
||||
/*
|
||||
Motor Test
|
||||
|
||||
|
||||
Just see if the robot can move and turn.
|
||||
|
||||
|
||||
Circuit:
|
||||
* Arduino Robot
|
||||
|
||||
|
||||
created 1 May 2013
|
||||
by X. Yang
|
||||
modified 12 May 2013
|
||||
by D. Cuartielles
|
||||
|
||||
|
||||
This example is in the public domain
|
||||
*/
|
||||
|
||||
@ -22,19 +22,19 @@ void setup() {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Robot.motorsWrite(255,255); // move forward
|
||||
Robot.motorsWrite(255, 255); // move forward
|
||||
delay(2000);
|
||||
Robot.motorsStop(); // fast stop
|
||||
delay(1000);
|
||||
Robot.motorsWrite(-255,-255); // backward
|
||||
Robot.motorsWrite(-255, -255); // backward
|
||||
delay(1000);
|
||||
Robot.motorsWrite(0,0); // slow stop
|
||||
Robot.motorsWrite(0, 0); // slow stop
|
||||
delay(1000);
|
||||
Robot.motorsWrite(-255,255); // turn left
|
||||
Robot.motorsWrite(-255, 255); // turn left
|
||||
delay(2000);
|
||||
Robot.motorsStop(); // fast stop
|
||||
delay(1000);
|
||||
Robot.motorsWrite(255,-255); // turn right
|
||||
Robot.motorsWrite(255, -255); // turn right
|
||||
delay(2000);
|
||||
Robot.motorsStop(); // fast stop
|
||||
delay(1000);
|
||||
|
@ -1,18 +1,18 @@
|
||||
/*
|
||||
Speed by Potentiometer
|
||||
|
||||
|
||||
Control the robot's speed using the on-board
|
||||
potentiometer. The speed will be printed on
|
||||
the TFT screen.
|
||||
|
||||
the TFT screen.
|
||||
|
||||
Circuit:
|
||||
* Arduino Robot
|
||||
|
||||
|
||||
created 1 May 2013
|
||||
by X. Yang
|
||||
modified 12 May 2013
|
||||
by D. Cuartielles
|
||||
|
||||
|
||||
This example is in the public domain
|
||||
*/
|
||||
|
||||
@ -28,12 +28,12 @@ void setup() {
|
||||
|
||||
void loop() {
|
||||
// read the value of the potentiometer
|
||||
int val=map(Robot.knobRead(), 0, 1023, -255, 255);
|
||||
int val = map(Robot.knobRead(), 0, 1023, -255, 255);
|
||||
|
||||
// print the value to the TFT screen
|
||||
Robot.debugPrint(val);
|
||||
|
||||
// set the same speed on both of the robot's wheels
|
||||
Robot.motorsWrite(val,val);
|
||||
Robot.motorsWrite(val, val);
|
||||
delay(10);
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
/*
|
||||
Turn Test
|
||||
|
||||
|
||||
Check if the robot turns a certain amount of degrees.
|
||||
|
||||
|
||||
Circuit:
|
||||
* Arduino Robot
|
||||
|
||||
|
||||
created 1 May 2013
|
||||
by X. Yang
|
||||
modified 12 May 2013
|
||||
by D. Cuartielles
|
||||
|
||||
|
||||
This example is in the public domain
|
||||
*/
|
||||
|
||||
@ -21,7 +21,7 @@ void setup() {
|
||||
Robot.begin();
|
||||
}
|
||||
|
||||
void loop(){
|
||||
void loop() {
|
||||
Robot.turn(50); //turn 50 degrees to the right
|
||||
Robot.motorsStop();
|
||||
delay(1000);
|
||||
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
Turn Test
|
||||
|
||||
Check if the robot turns a certain amount of degrees.
|
||||
|
||||
Circuit:
|
||||
* Arduino Robot
|
||||
|
||||
created 1 May 2013
|
||||
by X. Yang
|
||||
modified 12 May 2013
|
||||
by D. Cuartielles
|
||||
|
||||
This example is in the public domain
|
||||
*/
|
||||
|
||||
#include <ArduinoRobot.h>
|
||||
|
||||
void setup() {
|
||||
// initialize the robot
|
||||
Robot.begin();
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
void loop() {
|
||||
Robot.turn(50); //turn 50 degrees to the right
|
||||
=======
|
||||
void loop(){
|
||||
Robot.turn(50);//turn 50 degrees to the right
|
||||
Robot.motorsStop();
|
||||
>>>>>>> f062f704463222e83390b4a954e211f0f7e6e66f
|
||||
delay(1000);
|
||||
|
||||
Robot.turn(-100);//turn 100 degrees to the left
|
||||
Robot.motorsStop();
|
||||
delay(1000);
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Keyboard Test
|
||||
|
||||
|
||||
Check how the robot's keyboard works. This example
|
||||
sends the data about the key pressed through the
|
||||
serial port.
|
||||
@ -12,15 +12,15 @@
|
||||
It is possible to recalibrate the thresholds of the buttons using
|
||||
the Robot.keyboardCalibrate() function, that takes a 5 ints long
|
||||
array as parameter
|
||||
|
||||
|
||||
Circuit:
|
||||
* Arduino Robot
|
||||
|
||||
|
||||
created 1 May 2013
|
||||
by X. Yang
|
||||
modified 12 May 2013
|
||||
by D. Cuartielles
|
||||
|
||||
|
||||
This example is in the public domain
|
||||
*/
|
||||
|
||||
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
Keyboard Test
|
||||
|
||||
Check how the robot's keyboard works. This example
|
||||
sends the data about the key pressed through the
|
||||
serial port.
|
||||
|
||||
All the buttons on the Control Board are tied up to a
|
||||
single analog input pin, in this way it is possible to multiplex a
|
||||
whole series of buttons on one single pin.
|
||||
|
||||
It is possible to recalibrate the thresholds of the buttons using
|
||||
the Robot.keyboardCalibrate() function, that takes a 5 ints long
|
||||
array as parameter
|
||||
|
||||
Circuit:
|
||||
* Arduino Robot
|
||||
|
||||
created 1 May 2013
|
||||
by X. Yang
|
||||
modified 12 May 2013
|
||||
by D. Cuartielles
|
||||
|
||||
This example is in the public domain
|
||||
*/
|
||||
|
||||
#include <ArduinoRobot.h>
|
||||
|
||||
<<<<<<< HEAD
|
||||
// it is possible to use an array to calibrate
|
||||
//int vals[] = { 0, 133, 305, 481, 724 };
|
||||
|
||||
void setup() {
|
||||
// initialize the serial port
|
||||
Serial.begin(9600);
|
||||
|
||||
// calibrate the keyboard
|
||||
//Robot.keyboardCalibrate(vals);//For the new robot only.
|
||||
=======
|
||||
void setup(){
|
||||
Serial.begin(9600);
|
||||
>>>>>>> f062f704463222e83390b4a954e211f0f7e6e66f
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// print out the keyboard readings
|
||||
Serial.println(Robot.keyboardRead());
|
||||
delay(100);
|
||||
}
|
Reference in New Issue
Block a user