Data Sheet
100 : circuit 5b
CODE TO NOTE
PARSING STRINGS:
Serial.readStringUntil(β β);
Reads a serial message until the first space and saves it
as a string.
STRING TO INT:
string_name.toInt();
If a number is stored in a string variable, this will
convert it to an integer, which can be used in math
equations.
FUNCTIONS TO NOTE
rightMotor(motor_distance);
Drive the right motor long enough to travel the specified
distance.
leftMotor(motor_distance);
Drive the left motor long enough to travel the specified
distance.
CODING CHALLENGES
READ MORE COMMANDS: Add code to the sketch that takes not only direction but
also distance. The two should be separated by a character the code can parse out and
know where the next value begins.
ADD MORE COMMANDS: This sketch only uses four of the many ASCII characters. Use
different keys to move the robot in different ways or have commands turn on LEDs.
TROUBLESHOOTING
Motor not
spinning
Check the wiring to the motor driver. There are a lot of connections,
and itβs easy to mix one of them up with another. If only one motor is
working, check the wires coming from the nonworking motor. Make
sure they have not come loose from the motor.
Switch not
working
Make sure that you are hooked up to the middle pin and one side pin on
the switch.
SIK v4 Book Oct 13.indb 100 10/18/17 10:02 AM