5,710
edits
Changes
Week Z
,no edit summary
Multiplexed Displays
from [[Electronic Technologies for Art]]
== Dot Matrix ==
=== Circuit ===
* Decade counter with 5 lines of output.
=== Arduino Code ===
==== plain multiplexer ====
draws a solid block of lights
<pre>
/*
int clockPin = 8; // CP input (pin 14) on 4017 decade counter.
int resetPin = 9; // MR (pin 15) on 4017.
void setup() // run once, when the sketch starts
{
pinMode(clockPin, OUTPUT);
pinMode(resetPin, OUTPUT);
// set row pins to be outputs
for(int j=0;j<7;j++)
pinMode(j, OUTPUT);
}
void loop()
{
for (int col=0; col<5; col++)
{
for(int row=0;row<7;row++)
digitalWrite(row, HIGH);
delay(1);
// send the next clock pulse
// (to move the decade counter
digitalWrite(clockPin, HIGH);
digitalWrite(clockPin, LOW);
};
// reset the counter to the first column
digitalWrite(resetPin, HIGH);
digitalWrite(resetPin, LOW);
}
</pre>
==== smiley ====
<pre>
/*
* Multiplexer
*
* Driving a multiplexed 5X7 LED display.
* 1 clock signal drives a decade counter
* to select lines 1-7. 1 reset pin.
* 5 data lines drive columns 1-5.
*/
int clockPin = 8; // CP input (pin 14) on 4017 decade counter.
int resetPin = 9; // MR (pin 15) on 4017.
boolean img[5*7] = { 0, 0, 0, 0, 0,
0, 1, 0, 1, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
1, 0, 0, 0, 1,
0, 1, 1, 1, 0,
0, 0, 0, 0, 0 };
void setup() // run once, when the sketch starts
{
pinMode(resetPin, OUTPUT);
// set row pins to be outputs
for(int j=0;j<7;j++)
pinMode(j, OUTPUT);
}
void loop() // run over and over again
{
for (int icol=0; icol<5; icol++)
{
for(int jrow=0;jrow<7;jrow++) digitalWrite(jrow, HIGHimg[col+row*5]); delay(1); // send the next clock pulse // (to move the decade counter digitalWrite(clockPin, HIGH); // sets the LED on digitalWrite(clockPin, LOW); }; // sets reset the counter to the LED off};first column
digitalWrite(resetPin, HIGH);
digitalWrite(resetPin, LOW);
}
</pre>
=== See Also ===
Examples -> Library-Matrix