Arduino Uno Quick Start Manual page 248

Hide thumbs Also See for Arduino Uno:
Table of Contents

Advertisement

delay(MOTOR_DELAY);
}
void blame(const
_servo.write(_team.get_position(name));
delay(MOTOR_DELAY);
}
};
A
Blaminatr
object aggregates a
initializes the
Team
the
method.
attach
The most interesting method is
to blame, calculates his position, and moves the servo accordingly. Let s put
it all together now:
Motors/Blaminatr/Blaminatr.ino
const unsigned int
Line 1
const unsigned int
-
const unsigned int
-
-
const
char* members[] = { "nobody", "Bob", "Alice", "Maik", NULL };
5
Team team(members);
-
Blaminatr blaminatr(team);
-
-
void
setup() {
-
Serial.begin(BAUD_RATE);
10
blaminatr.attach(MOTOR_PIN);
-
blaminatr.blame("nobody");
-
}
-
-
void
loop() {
15
char
name[MAX_NAME + 1];
-
if
(Serial.available()) {
-
unsigned int
-
while
(Serial.available() && i < MAX_NAME + 1) {
-
const char
20
if
(c != -1 && c != '\n')
-
name[i++] = c;
-
delay(SERIAL_DELAY);
-
}
-
name[i] = 0;
25
Serial.print(name);
-
Serial.println(" is to
-
blaminatr.blame(name);
-
}
-
}
30
char* name) {
Team
object and a
instance while we can initialize the
blame
. It expects the name of the team member
MAX_NAME = 30;
BAUD_RATE = 9600;
SERIAL_DELAY = 5;
i = 0;
c = Serial.read();
blame.");
www.it-ebooks.info
Building a Blaminatr
Servo
object. The constructor
Servo
instance by calling
233
report erratum
discuss

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the Arduino Uno and is the answer not in the manual?

Subscribe to Our Youtube Channel

Table of Contents