Escolar Documentos
Profissional Documentos
Cultura Documentos
Chapter 1 Challenges
Questions
1. What device will be the brain of your BOE
Shield-Bot?
Exercises
1. Write a piece of code that displays the value
of i = followed by the value of stored in the
variable i in the Serial Monitor. Both should display
on the same line, and then move the cursor to the
beginning of the next line for displaying more
messages.
Serial.print("the value of i = ");
Serial.println(i);
Projects
1. Write a sketch to display the printable
ASCII characters. The first printable character is
the space character, which is one press/release of
your keyboards space bar between apostrophes,
like this: . The last printable character is the tilde
character ~. Alternately, you could use 32 for the
loops start value and 126 for the end value.
void setup()
{
Serial.begin(9600);
void loop()
{
// Empty, no repeating code.
}
void setup()
{
Serial.begin(9600);
int a = 20;
if(a % 2 == 0)
{
Serial.print("a is even");
}
else
{
Serial.print("a is odd");
}
}
void loop()
{
// Empty, no repeating code.
}
Chapter 2 Challenges
Questions
1. How do you connect two leads together
using a breadboard?
digitalWrite(13, HIGH) // 5 V
digitalWrite(13, LOW) // 0 V
Servo.writeMicroseconds(value) followed by
delay(ms) followed by
Servo.writeMicroseconds(newValue) or
Servo.detach(pin) will keep the servo turning for
ms milliseconds.
Exercises
1. Write a loop function that makes an LED blink
5 times per second, with an on time thats 1/3rd of
its off time. (Disconnect the servos for this
exercise!)
Projects
1. Look up the servo librarys detach function
and use it in place
of servoLeft and servoRight.writeMicrosecond
s(1500) to stop servos after they turn for 3
seconds.
servoLeft.writeMicroseconds(1700); // Pin 13
counterclockwise
servoRight.writeMicroseconds(1300); // Pin 12
clockwise
delay(3000); // ..for 3 seconds
servoLeft.detach(); // Stop servo
signal to pin 13
servoRight.detach(); // Stop servo
signal to pin 12
}