48 lines
994 B
C
48 lines
994 B
C
|
#include <wiringPi.h>
|
||
|
#include <stdio.h>
|
||
|
#define LATCH_PIN 2
|
||
|
#define CLOCK_PIN 0
|
||
|
#define DATA_PIN 3
|
||
|
const int zeroes[] = {0, 0, 0, 0, 0, 0, 0, 0};
|
||
|
const int ones[] = {1, 1, 1, 1, 1, 1, 1, 1};
|
||
|
const int checker1[] = {0, 1, 0, 1, 0, 1, 0, 1};
|
||
|
const int checker2[] = {1, 0, 1, 0, 1, 0, 1, 0};
|
||
|
void dWrite(int i, int j){
|
||
|
delay(10);
|
||
|
digitalWrite(i, j);
|
||
|
}
|
||
|
void ssend() {
|
||
|
dWrite (LATCH_PIN, HIGH);
|
||
|
dWrite (LATCH_PIN, LOW);
|
||
|
}
|
||
|
void write(int mode){
|
||
|
printf("Writing: (%d)\n", mode);
|
||
|
dWrite(DATA_PIN, mode);
|
||
|
dWrite(CLOCK_PIN, HIGH);
|
||
|
dWrite(CLOCK_PIN, LOW);
|
||
|
dWrite(DATA_PIN, LOW);
|
||
|
}
|
||
|
void writeLine(const int modes[8]) {
|
||
|
for(int i = 0; i < 8; i++) {
|
||
|
write(modes[i]);
|
||
|
//write(1);
|
||
|
}
|
||
|
}
|
||
|
void cclear() {
|
||
|
writeLine(zeroes);
|
||
|
ssend();
|
||
|
}
|
||
|
int main (void) {
|
||
|
wiringPiSetup ();
|
||
|
pinMode (DATA_PIN, OUTPUT);
|
||
|
pinMode (CLOCK_PIN, OUTPUT);
|
||
|
pinMode (LATCH_PIN, OUTPUT);
|
||
|
for (;;) {
|
||
|
writeLine(checker1);
|
||
|
ssend();
|
||
|
writeLine(checker2);
|
||
|
ssend();
|
||
|
}
|
||
|
return 0 ;
|
||
|
}
|