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