Difference between revisions of "Lesson 27--Microduino 8*8 Lattice Static Display"
(Created page with "{{Language|第二十七课--Microduino 8*8点阵静态显示}} {| style="width: 800px;" |- | ==Objective== The tutorial will teach you use two 74HC595 to control 8** lattice a...") |
|||
Line 17: | Line 17: | ||
'''8*8 lattice LED introduction:''' | '''8*8 lattice LED introduction:''' | ||
− | 8*8 lattice LED is made of 64 light-emitting diodes, | + | 8*8 lattice LED is made of 64 light-emitting diodes, different type has different definition of the pin. This example uses the LD-1088BS 8*8 lattice LED, the pins are defined as follows: |
[[File:第二十七课-Microduino 8_8点阵引脚定义.jpg|600px|center|thumb]] | [[File:第二十七课-Microduino 8_8点阵引脚定义.jpg|600px|center|thumb]] | ||
− | == | + | ==Schematic== |
[[File:第二十七课-Microduino 8_8点阵静态显示原理图.jpg|600px|center|thumb]] | [[File:第二十七课-Microduino 8_8点阵静态显示原理图.jpg|600px|center|thumb]] | ||
− | Pin | + | Pin Table: |
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
Line 180: | Line 180: | ||
==Debug== | ==Debug== | ||
− | Step | + | Step 1: Copy the code to IDE and compile it |
− | Step | + | Step 2: Set up circuit, as follows: |
[[File:第二十七课-Microduino 8_8点阵静态显示连接图.jpg|600px|center|thumb]] | [[File:第二十七课-Microduino 8_8点阵静态显示连接图.jpg|600px|center|thumb]] | ||
− | In order to protect the circuit, plus a 220Ω | + | In order to protect the circuit, plus a 220Ω resistor on the every connection line (total 8 lines) between one 74HC595 chip and 8*8 lattice LED. In our example, we don't use the resistor, so the LED's brightness is strong. If the lattice's quality is bad and easily broken. |
− | Step | + | Step 3: Run program |
==Result== | ==Result== | ||
− | 8*8 lattice LED will | + | 8*8 lattice LED will display a smiling face. |
==Video== | ==Video== |
Latest revision as of 08:35, 12 September 2016
Language: | English • 中文 |
---|
ObjectiveThe tutorial will teach you use two 74HC595 to control 8** lattice and display a static smiling faces. Equipment
Schematic
Program //Pin connects to 74HC595的ST_CP
int latchPin = 8;
//Pin connects to 74HC595的SH_CP
int clockPin = 12;
////Pin connects to 74HC595的DS
int dataPin = 11;
void setup() {
//Set barud roate 9600
Serial.begin(9600);
//Set the latchpin as output
pinMode(latchPin, OUTPUT);
}
void loop() {
//Smile for 8x8 Matrix LED
digitalWrite(latchPin, 0);
shiftOut(dataPin, clockPin, B01111111); //col
shiftOut(dataPin, clockPin, B00111100); //row
digitalWrite(latchPin, 1);
digitalWrite(latchPin, 0);
shiftOut(dataPin, clockPin, B10111111); //col
shiftOut(dataPin, clockPin, B01000010); //row
digitalWrite(latchPin, 1);
digitalWrite(latchPin, 0);
shiftOut(dataPin, clockPin, B11011111); //col
shiftOut(dataPin, clockPin, B10100101); //row
digitalWrite(latchPin, 1);
digitalWrite(latchPin, 0);
shiftOut(dataPin, clockPin, B11101111); //col
shiftOut(dataPin, clockPin, B10000001); //row
digitalWrite(latchPin, 1);
digitalWrite(latchPin, 0);
shiftOut(dataPin, clockPin, B11110111); //col
shiftOut(dataPin, clockPin, B10100101); //row
digitalWrite(latchPin, 1);
digitalWrite(latchPin, 0);
shiftOut(dataPin, clockPin, B11111011); //col
shiftOut(dataPin, clockPin, B10011001); //row
digitalWrite(latchPin, 1);
digitalWrite(latchPin, 0);
shiftOut(dataPin, clockPin, B11111101); //col)
shiftOut(dataPin, clockPin, B01000010); //row
digitalWrite(latchPin, 1);
digitalWrite(latchPin, 0);
shiftOut(dataPin, clockPin, B11111110); //col
shiftOut(dataPin, clockPin, B00111100); //row
digitalWrite(latchPin, 1);
}
void shiftOut(int myDataPin, int myClockPin, byte myDataOut) {
//initialization
int i=0;
int pinState;
pinMode(myClockPin, OUTPUT);
pinMode(myDataPin, OUTPUT);
//clear everything out just in case to
//prepare shift register for bit shifting
digitalWrite(myDataPin, 0);
digitalWrite(myClockPin, 0);
//for each bit in the byte myDataOut�
//NOTICE THAT WE ARE COUNTING DOWN in our for loop
//This means that %00000001 or "1" will go through such
//that it will be pin Q0 that lights.
for (i=7; i>=0; i--) {
digitalWrite(myClockPin, 0);
//if the value passed to myDataOut and a bitmask result
// true then... so if we are at i=6 and our value is
// %11010100 it would the code compares it to %01000000
// and proceeds to set pinState to 1.
if ( myDataOut & (1<<i) ) {
pinState= 1;
}
else {
pinState= 0;
}
//Sets the pin to HIGH or LOW depending on pinState
digitalWrite(myDataPin, pinState);
//register shifts bits on upstroke of clock pin
digitalWrite(myClockPin, 1);
//zero the data pin after shift to prevent bleed through
digitalWrite(myDataPin, 0);
}
//stop shifting
digitalWrite(myClockPin, 0);
} DebugStep 1: Copy the code to IDE and compile it Step 2: Set up circuit, as follows: In order to protect the circuit, plus a 220Ω resistor on the every connection line (total 8 lines) between one 74HC595 chip and 8*8 lattice LED. In our example, we don't use the resistor, so the LED's brightness is strong. If the lattice's quality is bad and easily broken. Step 3: Run program Result8*8 lattice LED will display a smiling face. Video |