//**************************************************************//
// Name : shiftOutCode, Hello World //
// 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 //
//****************************************************************
#define LATCH_PIN1 8 //ST_CP
#define CLOCK_PIN1 12 //SH_CP
#define DATA_PIN1 11 //DS
#define LATCH_PIN2 7 //ST_CP
#define CLOCK_PIN2 10 //SH_CP
#define DATA_PIN2 9 //DS
#define DELAY_MS 10
//Pin connected to ST_CP of 74HC595
int latchPin = 8;
//Pin connected to SH_CP of 74HC595
int clockPin = 12;
////Pin connected to DS of 74HC595
int dataPin = 11;
byte character[] = {
0b01000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000
};
void x_write(byte data){
digitalWrite(LATCH_PIN1, LOW);
shiftOut(DATA_PIN1, CLOCK_PIN1, LSBFIRST, ~data);
digitalWrite(LATCH_PIN1, HIGH);
}
void y_write(byte data){
digitalWrite(LATCH_PIN2, LOW);
shiftOut(DATA_PIN2, CLOCK_PIN2, LSBFIRST, data);
digitalWrite(LATCH_PIN2, HIGH);
}
void setup() {
//set pins to output because they are addressed in the main loop
pinMode(LATCH_PIN1, OUTPUT);
pinMode(CLOCK_PIN1, OUTPUT);
pinMode(DATA_PIN1, OUTPUT);
pinMode(LATCH_PIN2, OUTPUT);
pinMode(CLOCK_PIN2, OUTPUT);
pinMode(DATA_PIN2, OUTPUT);
Serial.begin(9600);
}
void loop() {
delay(10);
for(int i = 0; i < 7; i++){
x_write(pow(2, i) );
y_write(character[i]);
delay(DELAY_MS);
}
}