1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-08-08 11:22:40 +03:00

Run new astyle formatter against all the examples

This commit is contained in:
Federico Fissore
2013-10-21 09:58:40 +02:00
parent 3c6ee46828
commit b4c68b3dff
259 changed files with 5160 additions and 5217 deletions

View File

@@ -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(",");
}

View File

@@ -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
*/

View File

@@ -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
}

View File

@@ -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);
}

View File

@@ -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(" ");
}

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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
*/

View File

@@ -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);
}