Last active
December 7, 2015 12:33
-
-
Save kalyan02/51ec4ac3a921752fa1a5 to your computer and use it in GitHub Desktop.
4015IC Arduino Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int R_DATA = 1; | |
const int R_RESET = 2; | |
const int R_CLOCK = 3; | |
void setup() { | |
pinMode(R_DATA, OUTPUT); | |
pinMode(R_RESET, OUTPUT); | |
pinMode(R_CLOCK, OUTPUT); | |
int b[] = {0,0,0,0,1,0,1,1}; | |
writeByte(b); | |
} | |
void writeByte(int b[]) { | |
// Reset all bits to LOW | |
digitalWrite( R_RESET, LOW ); | |
// One by one, shift out | |
for( int i=0; i<8; i++ ) { | |
// LOW | |
digitalWrite( R_DATA, LOW ); | |
digitalWrite( R_CLOCK, LOW ); | |
// BIT status | |
// Weirdly, DATA_LOW makes OUTPUT HIGH | |
digitalWrite( R_DATA, b[i] == 1 ? LOW : HIGH ); | |
digitalWrite( R_CLOCK, HIGH ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment