Uno Shield 0
Uno Shield 0 starts with a
SparkFun Joystick Shield Kit,
then adds audio output and a rotary encoder.
Audio Output
By capturing the
RX
and
TX
signals and feeding them into a small speaker,
we can give the user an audible indication of download activity.
The
setup()
function can also emit a beep when it starts up.
Finally, the
loop()
function can emit sounds (e.g., clicks, tones)
to indicate control activity, settings, etc.
Between these, the user should be able to:
- determine that the Arduino is running
- track current modes and settings
- monitor the results of a sketch
- interact with a running sketch
Components
This section covers most of the major components.
Joystick Shield
The
SparkFun Joystick Shield Kit
has four large buttons, arranged in a diamond pattern,
and a small button (to reset the Arduino).
It also has a small (tiltable and clickable)
joystick
and a "prototyping" area with lots of convenient holes.
Other Controls
Rotary encoders (some with built-in push switches)
are
economically available on
eBay.
These can be used to implement menu systems, etc.
I'm also adding four
potentiometers,
to provide settable analog voltages and adjust the
PWM time constants.
Speakers
I'm using a 3.5 mm (1/8") switched stereo
phone connector
to provide audio for an external speaker, headphones, etc.
I may also add a small speaker or two, for convenience.
I'm using another switched 3.5 mm connector to allow sampling
of two (slow!) audio-level (1 V P-P) input channels.
This could be used to measure voltages or slow-moving analog signals,
either from an external source
or (by default) internal PWM-enabled digital pins.
Exercises
This shield should be versatile enough to allow a variety of exercises.
Here is a small sampling, to get us started:
ADCs 0 & 1 can detect analog voltage levels produced by the joystick.
Vertical and horizontal tilt affect
ADC0
and
ADC1
, respectively.
- Measure and report these voltages.
ADCs 2 & 3 can detect voltages produced by potentiometers 0 & 1.
Digital pins 6 & 7, when used as
AIN0
and
AIN1
,
can be used to compare these voltages.
- Measure and report these voltages.
- Compare and report these voltages.
ADCs 4 & 5 can detect voltages from the 1/8" stereo input jack.
If both this jack and the output jack are unoccupied,
they can detect (PWM) analog levels generated by digital pins 9 & 10.
(Potentiometers 2 & 3 determine the time constants.)
- Measure and report these voltages.
- Measure and report the settling time.
Digital Output
Pins 9 & 10 can be cycled to produce (say) square waves
in the left and right channels of the Out Jack.
- Generate the same tone in both channels.
- Vary the amplitude and pitch, using the joystick.
- Vary the pitch, using the rotary encoder.
- Toggle the encoder between amplitude and pitch,
using its push switch.
- Generate a stereo pair of tones in Ionian mode.
- Use the buttons to change the generated mode.
Pin Usage
This section describes our use of the Uno's pins.
Keep the
Uno Pin Usage page handy as a reference!
Default
By default, the Joystick Shield uses the following pins:
Set |
Pin |
Function(s) |
Usage |
Analog |
A0 |
ADC0 |
Joystick (Vertical) |
Analog |
A1 |
ADC1 |
Joystick (Horizontal) |
|
|
|
|
Digital |
D2 |
INT0 |
Joystick (Select) |
Digital |
D3 |
INT1 |
Button (Right) |
Digital |
D4 |
|
Button (Top) |
Digital |
D5 |
|
Button (Bottom) |
Digital |
D6 |
|
Button (Left) |
|
|
|
|
_ |
RESET |
|
Button (Reset) |
As Hacked
In an ideal world, we would simply add our own use cases.
However, the existing pin assignments get in the way of things we'd like to do.
So, we need to hack the wiring, moving some of the pin assignments around.
The current plan is to do this by means of
jumpers (aka "blue wires"),
which re-route signals (e.g., from circuit board holes to different device pins).
The table below indicates these hacks in the change (C) column.
Pins are unchanged (_), added (A) or moved (M) pins, as needed:
Set |
Pin |
Mode |
Usage |
C |
Analog |
A0 |
ADC0 |
Joystick (Vertical) |
_ |
Analog |
A1 |
ADC1 |
Joystick (Horizontal) |
_ |
Analog |
A2 |
ADC2 |
Potentiometer 0 |
A |
Analog |
A3 |
ADC3 |
Potentiometer 1 |
A |
Analog |
A4 |
ADC4 |
In Jack (Right) |
A |
Analog |
A5 |
ADC5 |
In Jack (Left) |
A |
|
|
|
|
|
Digital |
D2 |
INT0 |
Encoder (Select) |
A |
Digital |
D3 |
INT1 |
Encoder (Pin A) |
A |
Digital |
D4 |
|
Encoder (Pin B) |
A |
Digital |
D5 |
|
Button (Bottom) |
_ |
Digital |
D6 |
AIN0 |
Potentiometer 0 |
A |
Digital |
D7 |
AIN1 |
Potentiometer 1 |
A |
Digital |
D8 |
|
Joystick (Select) |
M |
Digital |
D9 |
PWM |
Out Jack (Right) |
A |
Digital |
D10 |
PWM |
Out Jack (Left) |
A |
Digital |
D11 |
|
Button (Top) |
M |
Digital |
D12 |
|
Button (Right) |
M |
Digital |
D13 |
|
Button (Left) |
M |
|
|
|
|
|
_ |
RESET |
|
Button (Reset) |
_ |
Notes
D9 & D10 are only used for output.
They can be used to generate audio tones (via digital waveforms) or analog (PWM) levels.
The remaining pins are only used for input.
Pins A0-A6 measure voltages (e.g., potentiometer settings).
Pins D6 & D7 are used for the analog comparator.
The rest are used to detect buttons, encoder rotation and select, and joystick select.
-
A2
and A3
can each measure a DC voltage level.
We provide these via Potentiometers 0 & 1.
-
D2
and D3
have vectored interrupts. The encoder
needs these; the Joystick and Right button don't.
-
D5
and D6
(AINx
) can compare two DC voltages.
We provide these via Potentiometers 0 & 1.
D5
can also be set up to count button presses.
-
D9
and D10
can generate DC voltages, via PWM
.
These are routed (via Potentiometers 2 & 3) to the
Out Jack and the NC contacts of the In Jack.
Resources
This wiki page is maintained by
Rich Morin,
an independent consultant specializing in software design, development, and documentation.
Please feel free to
email
comments, inquiries, suggestions, etc!