Similar to circuit #4, a scrolling marquee display delivers
a message with multiple LEDs. Essentially the same task
the shift register achieves here in Circuit #14.
Circuit 2
Arduino Code:
14
Troubleshooting:
The RedBoard's power LED goes out
This happened to us a couple of times, it happens when
the chip is inserted backward. If you fix it quickly
nothing will break.
Not Quite Working
Sorry to sound like a broken record but it is probably
something as simple as a crossed wire.
Frustration
Shoot us an e-mail, this circuit is both simple and
complex at the same time. We want to hear about
problems you have so we can address them in future
editions:
You should see the LEDs light up
similarly to circuit 4 (but this
time, you're using a shift register).
If they aren't, make sure you have
assembled the circuit correctly
and verified and uploaded the
code to your board. See the
troubleshooting tips below.
Code to Note:
Real World Application:
Open Arduino IDE
//
File > Examples > SIK Guide >
Circuit # 14
What You Should See:
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.
You'll communicate with the shift register (and a lot of other parts) using an
interface called SPI, or Serial Peripheral Interface. This interface uses a data
line and a separate clock line that work together to move data in or out of
the RedBoard at high speed. The MSBFIRST parameter specifies the order
in which to send the individual bits, in this case we're sending the Most
Significant Bit first.
shiftOut(datapin, clockpin, MSBFIRST, data);
Bits are the smallest possible piece of memory in a computer; each one can
store either a "1" or a "0". Larger numbers are stored as arrays of bits.
Sometimes we want to manipulate these bits directly, for example now when
we're sending eight bits to the shift register and we want to make them 1 or 0
to turn the LEDs on or off. The RedBoard has several commands, such as
bitWrite(), that make this easy to do.
bitWrite(byteVar, desiredBit, desiredState);
Page 76
Содержание RedBoard
Страница 13: ...Page 11...