Data Sheet
PROGRAM OVERVIEW
1
Check to see if a command has been sent through the Serial Monitor. If a command has been sent, then set
the motor speed to the number that was sent over the Serial Monitor.
2
Check to see if the switch is ON or OFF.
A: If the switch is ON, drive the motor at the motor speed.
B: If the switch is OFF, stop the motor.
94 : circuit 5a
WHAT YOU
SHOULD SEE
Flip the switch. The motor will spin
at the speed set by the motor speed
variable (default is 0). Open the Serial
Monitor, type any number from 30
to 255 or -30 to -255 , and then press
Enter. Changes in speed will be hard
to notice. Send 0 to stop the motor.
CODE TO NOTE
PARSING INTEGERS:
Serial.parseInt();
.parseInt() receives integer numbers from the Serial
Monitor. It returns the value of the number that it receives,
so you can use it like a variable.
SERIAL AVAILABLE:
Serial.available();
This command checks how many bytes of data are being
sent to the RedBoard. If it is greater than 0, then a message
has been sent. It can be used in an if statement to run code
only when a command has been received.
Open the Arduino IDE
Connect the RedBoard to a USB port on your computer.
Open the Sketch:
File > Examples > SIK_Guide_Code-V_4 > CIRCUIT_5A-MOTOR BASICS
Select UPLOAD to program the sketch on the RedBoard.