因為老師教學和板子的關係分成了兩個參數最下方的部分只執行到一個參數
有大大們可以幫解答嗎
下方該怎麼改
圖案是一個笑臉
//**************************************************************//
// Name : shiftOutCode, Dual Binary Counters //
// Author : Carlyn Maw, Tom Igoe //
// Date : 25 Oct, 2006 //
// Version : 1.0 //
// Notes : Code for using a 74HC595 Shift Register //
// : to count from 0 to 255 //
//**************************************************************//
// X 軸
int dataPin = 2; //data input pin 14
int latchPin = 3; //latch pin 12
int clockPin = 4; //shift clock pin 11
// Y 軸
int dataPin_1 = 5; //data input pin 14
int latchPin_1 = 6; //latch pin 12
int clockPin_1 = 7; //shift clock pin 11
void setup() {
Serial.begin(9600);
pinMode(latchPin, OUTPUT);
pinMode(latchPin_1, OUTPUT);
}
void loop() {
//Smile for 8x8 Matrix LED
digitalWrite(latchPin, 0);
digitalWrite(latchPin_1, 0);
shiftOut(dataPin_1, clockPin_1, B01111111); //mask(col) Y軸
shiftOut(dataPin, clockPin, B00111100); //row X軸
digitalWrite(latchPin, 1);
digitalWrite(latchPin_1, 1);
digitalWrite(latchPin, 0);
digitalWrite(latchPin_1, 0);
shiftOut(dataPin_1, clockPin_1, B10111111); //mask(col) Y軸
shiftOut(dataPin, clockPin, B01000010); //row X軸
digitalWrite(latchPin, 1);
digitalWrite(latchPin_1, 1);
digitalWrite(latchPin, 0);
digitalWrite(latchPin_1, 0);
shiftOut(dataPin_1, clockPin_1, B11011111); //mask(col) Y軸
shiftOut(dataPin, clockPin, B10100101); //row X軸
digitalWrite(latchPin, 1);
digitalWrite(latchPin_1, 1);
digitalWrite(latchPin, 0);
digitalWrite(latchPin_1, 0);
shiftOut(dataPin_1, clockPin_1, B11101111); //mask(col) Y軸
shiftOut(dataPin, clockPin, B10000001); //row X軸
digitalWrite(latchPin, 1);
digitalWrite(latchPin_1, 1);
digitalWrite(latchPin, 0);
digitalWrite(latchPin_1, 0);
shiftOut(dataPin_1, clockPin_1, B11110111); //mask(col) Y軸
shiftOut(dataPin, clockPin, B10100101); //row X軸
digitalWrite(latchPin, 1);
digitalWrite(latchPin_1, 1);
digitalWrite(latchPin, 0);
digitalWrite(latchPin_1, 0);
shiftOut(dataPin_1, clockPin_1, B11111011); //mask(col) Y軸
shiftOut(dataPin, clockPin, B10011001); //row X軸
digitalWrite(latchPin, 1);
digitalWrite(latchPin_1, 1);
digitalWrite(latchPin, 0);
digitalWrite(latchPin_1, 0);
shiftOut(dataPin_1, clockPin_1, B11111101); //mask(col) Y軸
shiftOut(dataPin, clockPin, B01000010); //row X軸
digitalWrite(latchPin, 1);
digitalWrite(latchPin_1, 1);
digitalWrite(latchPin, 0);
digitalWrite(latchPin_1, 0);
shiftOut(dataPin_1, clockPin_1, B11111110); //mask(col) Y軸
shiftOut(dataPin, clockPin, B00111100); //row X軸
digitalWrite(latchPin, 1);
digitalWrite(latchPin_1, 1);
}
void shiftOut(int myDataPin, int myClockPin, byte myDataOut) {
int i=0;
int pinState;
pinMode(myClockPin, OUTPUT);
pinMode(myDataPin, OUTPUT);
digitalWrite(myDataPin, 0);
digitalWrite(myClockPin, 0);
for (i=7; i>=0; i--) {
digitalWrite(myClockPin, 0);
if ( myDataOut & (1<<i) ) {
pinState= 1;
}
else {
pinState= 0;
}
digitalWrite(myDataPin, pinState);
digitalWrite(myClockPin, 1);
digitalWrite(myDataPin, 0);
}
digitalWrite(myClockPin, 0);
} |