Circuit 2
Arduino Code:
12
Troubleshooting:
Motor Not Spinning
If you sourced your own transistor, double check with
the data sheet that the pinout is compatible with a
P2N2222AG (many are reversed).
Still No Luck
If you sourced your own motor, double check that it will
work with 5 volts and that it does not draw too much
power.
Still Not Working
Sometimes the RedBoard will disconnect from the
computer. Try un-plugging and then re-plugging it into
your USB port.
The DC Motor should spin if you have
assembled the circuit’s components correctly,
and also verified/uploaded the correct code. If
your circuit is not working check the
troubleshooting section below.
Code to Note:
Real World Application:
Radio Controlled(RC) cars use Direct Current(DC)
motors to turn the wheels for propulsion.
Open Arduino IDE
//
File > Examples > SIK Guide >
Circuit # 12
IOREF
RES
ET
RESET
7-15V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
7
~6
~5
4
~3
2
1
0
TX
RX
13
3.3V
5V
GND
GND
VIN
A0
A1
A2
A3
A4
A5
POWER
ANALOG IN
DIGIT
AL (PWM~)
ON
ISP
TX
RX
IOREF
RES
ET
RESET
7-15V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
7
~6
~5
4
~3
2
1
0
TX
RX
13
3.3V
5V
GND
GND
VIN
A0
A1
A2
A3
A4
A5
POWER
ANALOG IN
DIGIT
AL (PWM~)
ON
ISP
TX
RX
LEARN. SHARE. HACK.
What You Should See:
The RedBoard's serial port can be used to receive as well as send data.
Because data could arrive at any time, the RedBoard stores, or
"buffers" data coming into the port until you're ready to use it. The
Serial.available() command returns the number of characters that the
port has received, but haven't been used by your sketch yet. Zero
means no data has arrived.
while (Serial.available() > 0)
If the port has data waiting for you, there are a number of ways for
you to use it. Since we're typing numbers into the port, we can
use the handy Serial.parseInt() command to extract, or "parse"
integer numbers from the characters it's received. If you type "1"
"0" "0" to the port, this function will return the number 100.
speed = Serial.parseInt();
Page 68
Summary of Contents for RedBoard
Page 13: ...Page 11...