EasyManuals Logo

Arduino uno User Manual

Arduino uno
311 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #248 background imageLoading...
Page #248 background image
delay(MOTOR_DELAY);
}
void blame(const char* name) {
_servo.write(_team.get_position(name));
delay(MOTOR_DELAY);
}
};
A
Blaminatr
object aggregates a
Team
object and a
Servo
object. The constructor
initializes the
Team
instance while we can initialize the
Servo
instance by calling
the
attach
method.
The most interesting method is
blame
. It expects the name of the team member
to blame, calculates his position, and moves the servo accordingly. Lets put
it all together now:
Motors/Blaminatr/Blaminatr.ino
const unsigned int MAX_NAME = 30;
Line 1
const unsigned int BAUD_RATE = 9600;
-
const unsigned int SERIAL_DELAY = 5;
-
-
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 i = 0;
-
while (Serial.available() && i < MAX_NAME + 1) {
-
const char c = Serial.read();
20
if (c != -1 && c != '\n')
-
name[i++] = c;
-
delay(SERIAL_DELAY);
-
}
-
name[i] = 0;
25
Serial.print(name);
-
Serial.println(" is to blame.");
-
blaminatr.blame(name);
-
}
-
}
30
report erratum discuss
Building a Blaminatr 233
www.it-ebooks.info

Table of Contents

Other manuals for Arduino uno

Questions and Answers:

Question and Answer IconNeed help?

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

Arduino uno Specifications

General IconGeneral
Form factorArduino
CertificationRoHS, FC, CE
Processor model-
Processor frequency- MHz
Microcontroller modelATmega328
Microcontroller frequency16 MHz
DC input voltage7-12 V
Operating voltage5 V
DC current per I/O pin40 mA
Flash memory0.032 MB
Maximum internal memory- GB
SRAM (Static Random Access Memory)2 KB
EEPROM (Electrically Erasable Programmable Read-Only Memory)1 KB
Wi-FiNo
Number of analog I/O pins6
Number of digital I/O pins14
Weight and Dimensions IconWeight and Dimensions
Board dimensions53.4 x 68.6 mm

Related product manuals