# 16-seg 5 Way Switch

Question:

Hi!
Being a novice, for the displaying part of your test here: is? there anywhere I could read a schematic (limiting resistors and all) on how to hook up this 16seg digit to my arduino? Most greatful…

I did it it the “wrong” way, because I was too lazy and it only was for a tiny test. From the Arduino Mega direct to the segments. One resistor in the common ground return. It properly should be one resistor between the arduino pin and the segment pin. (In fact, for the video I removed the resistor so the LEDs were more visible. Bad, bad …)

Here is the program, the comments explain the wiring, and it also shows the use of arrays.

``````/* Driving the Alpha 16seg display from the 5way switch
Requires the Mega (number of pins)

Pinout          Arduino pins
--2--  -19--     -30-  -35-
|  \   |  /  |  | \   |  /  |         +-v-+
4  3  20 18 17  34 32 31 33 37   14 U |   | R 18
|   \  | /   |  |   \ | /   |    15 E | * | Com GND
--6--  --15-     -36-  -39-     16 L |   | D 17
|   /  | \   |  |   / | \   |         +---+
7  8  10 13 14  38 42 44 43 41
| /    |   \ |  | /   |  \  |
--9--  --12-     -40-  -45-
5, 15 +ve

Mode 0 : Just flash segments on Alpha display
(Serial "echo" of 5Way)
Mode 1 : "Echo" joy stick position with spokes in middle. E lights edge, too
Mode 2 : Show Alphabet, L/R scroll through, U/D Digit/Alpha (Not Yet Written)
*/
#define MODE1

const byte AP[] = { // arranged: outer ring, inner spokes, clockwise
35, 37, 41, 45, 40, 38, 34, 30,
31, 33, 39, 43, 44, 42, 36, 32  } ;
const byte WP[] = { // arranged U-R-D-L-E (clockwise)
14, 18, 17, 16, 15 } ;

const byte ZP[] = { // Maps calculated switch value to a segment entry (inner spokes)
0, 8, 10, 9, 12, 0, 11, 0, 14, 15, 0, 0, 13 } ;
const byte QP[] = { // Maps calculated switch value to two segment entries (outer ring)
7,0, 1,2, 0,1, 3,4, 0,0, 2,3, 0,0, 5,6, 6,7, 0,0, 0,0, 4,5  } ;

int Q = 0 ;
void setup() {
pinMode(13,OUTPUT);
// Setup for driving 16 output ports
for (int p=0; p<16; p++) {
pinMode(AP[p],OUTPUT) ;
digitalWrite(AP[p],HIGH) ; // display is active LOW (common Anode)
}
// Setup for driving 5 input ports
for (int p=0; p<5; p++)  {
pinMode(WP[p],INPUT) ;
digitalWrite(WP[p],HIGH) ;  // Pullup resistor
}
//  Serial.begin(9600) ;
}

void loop() {
#ifdef MODE0
for (int p=0; p<16; p++) {
// clockwise wheel
digitalWrite(AP[p],LOW) ;
delay(100);
digitalWrite(AP[p],HIGH) ;
}
#endif
#ifdef MODE1
byte Z = 0 ;
for (int q=0; q<16; q++) digitalWrite(AP[q],HIGH) ; // turn everything off
for (int p=0; p<4; p++)
if (digitalRead(WP[p])==LOW)  Z += 1<<p ;
//  delay(1000) ; Serial.print(Z,DEC) ; Serial.print(":");Serial.print(ZP[Z],DEC) ; Serial.print(" ");
if (Z) {
digitalWrite(AP[ZP[Z]],LOW) ;