Difference between revisions of "Week Z"

From Robert-Depot
Jump to: navigation, search
(plain multiplexer)
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
Multiplexed Displays
 
Multiplexed Displays
 +
 +
from [[Electronic Technologies for Art]]
 +
 
== Dot Matrix ==
 
== Dot Matrix ==
 
=== Circuit ===
 
=== Circuit ===
Line 30: Line 33:
 
int clockPin = 8; // CP input (pin 14) on 4017 decade counter.  
 
int clockPin = 8; // CP input (pin 14) on 4017 decade counter.  
 
int resetPin = 9; // MR (pin 15) on 4017.
 
int resetPin = 9; // MR (pin 15) on 4017.
 
+
                   
 
 
 
void setup()                    // run once, when the sketch starts
 
void setup()                    // run once, when the sketch starts
 
{
 
{
Line 37: Line 39:
 
   pinMode(resetPin, OUTPUT);
 
   pinMode(resetPin, OUTPUT);
 
    
 
    
 +
  // set row pins to be outputs
 
   for(int j=0;j<7;j++)
 
   for(int j=0;j<7;j++)
 
     pinMode(j, OUTPUT);
 
     pinMode(j, OUTPUT);
Line 42: Line 45:
 
}
 
}
  
void loop()                    // run over and over again
+
void loop()                     
 
{
 
{
   for (int i=0; i<5; i++)
+
 
 +
   for (int col=0; col<5; col++)
 
   {
 
   {
     for(int j=0;j<7;j++)
+
     for(int row=0;row<7;row++)
       digitalWrite(j, img[i+j*5]);    
+
       digitalWrite(row, HIGH);
 
     delay(1);
 
     delay(1);
 
    
 
    
     digitalWrite(clockPin, HIGH);  // sets the LED on
+
    // send the next clock pulse
     digitalWrite(clockPin, LOW);   // sets the LED off
+
    // (to move the decade counter
 +
     digitalWrite(clockPin, HIGH);   
 +
     digitalWrite(clockPin, LOW);
 
   };
 
   };
 +
 
 +
  // reset the counter to the first column
 
   digitalWrite(resetPin, HIGH);
 
   digitalWrite(resetPin, HIGH);
 
   digitalWrite(resetPin, LOW);
 
   digitalWrite(resetPin, LOW);
 
}
 
}
 +
 +
 
</pre>
 
</pre>
  
Line 77: Line 87:
 
                     0, 0, 0, 0, 0,  
 
                     0, 0, 0, 0, 0,  
 
                     1, 0, 0, 0, 1,  
 
                     1, 0, 0, 0, 1,  
                     1, 0, 0, 0, 1,  
+
                     0, 1, 1, 1, 0,  
                     0, 1, 1, 1, 0 };
+
                     0, 0, 0, 0, 0 };
 
                      
 
                      
 
void setup()                    // run once, when the sketch starts
 
void setup()                    // run once, when the sketch starts
Line 85: Line 95:
 
   pinMode(resetPin, OUTPUT);
 
   pinMode(resetPin, OUTPUT);
 
    
 
    
 +
  // set row pins to be outputs
 
   for(int j=0;j<7;j++)
 
   for(int j=0;j<7;j++)
 
     pinMode(j, OUTPUT);
 
     pinMode(j, OUTPUT);
Line 90: Line 101:
 
}
 
}
  
void loop()                    // run over and over again
+
void loop()                     
 
{
 
{
   for (int i=0; i<5; i++)
+
 
 +
   for (int col=0; col<5; col++)
 
   {
 
   {
     for(int j=0;j<7;j++)
+
     for(int row=0;row<7;row++)
       digitalWrite(j, img[i+j*5]);       
+
       digitalWrite(row, img[col+row*5]);       
 
     delay(1);
 
     delay(1);
 
    
 
    
     digitalWrite(clockPin, HIGH);  // sets the LED on
+
    // send the next clock pulse
     digitalWrite(clockPin, LOW);   // sets the LED off
+
    // (to move the decade counter
 +
     digitalWrite(clockPin, HIGH);   
 +
     digitalWrite(clockPin, LOW);
 
   };
 
   };
 +
 
 +
  // reset the counter to the first column
 
   digitalWrite(resetPin, HIGH);
 
   digitalWrite(resetPin, HIGH);
 
   digitalWrite(resetPin, LOW);
 
   digitalWrite(resetPin, LOW);
 
}
 
}
 +
 
</pre>
 
</pre>
  
 
=== See Also ===
 
=== See Also ===
 
Examples -> Library-Matrix
 
Examples -> Library-Matrix

Latest revision as of 08:32, 26 May 2009

Multiplexed Displays

from Electronic Technologies for Art

Dot Matrix

Circuit

http://www.best-microcontroller-projects.com/support-files/led-dot-matrix-display.pdf

You will need:

  • 5 x 470 ohm resistors
  • 1 LN2803 (NPN transistor array)
  • 1 4017 (decade counter)

It will use 7 output pins on your controller: 5 for the column data, one as the clock for the counter, and one to reset the clock counter. Thats pretty good.

If you are going to drive two 5x7 arrays, you can use the same clock signal and reset for both decade counters, so you will only need 12 pins total, to draw any picture you want, 10x7 pixels wide. This is pretty cool.

  • Decade counter and single data output. You will see a moving line of lights.
  • Decade counter with 5 lines of output.

Arduino Code

plain multiplexer

draws a solid block of lights

/*
 * 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.
                     
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);
}


smiley

/*
 * 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(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, img[col+row*5]);      
    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);
}

See Also

Examples -> Library-Matrix