Skip to content

Instantly share code, notes, and snippets.

@kalyan02
Last active December 7, 2015 12:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kalyan02/51ec4ac3a921752fa1a5 to your computer and use it in GitHub Desktop.
Save kalyan02/51ec4ac3a921752fa1a5 to your computer and use it in GitHub Desktop.
4015IC Arduino Test
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