Skip to content

Instantly share code, notes, and snippets.

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 buildcircuit/01121a2f75ca13deec08 to your computer and use it in GitHub Desktop.
Save buildcircuit/01121a2f75ca13deec08 to your computer and use it in GitHub Desktop.
/* Shift Out Data
* --------------
*
* Shows a byte, stored in "dato" on a set of 8 LEDs
*
* (copyleft) 2005 K3, Malmo University
* @author: David Cuartielles, Marcus Hannerstig
* @hardware: David Cuartielles, Marcos Yarza
* @project: made for SMEE - Experiential Vehicles
*/
int data = 8;
int strob = 7;
int clock = 10;
int oe = 9;
int count = 0;
int dato = 0;
void setup()
{
Serial.begin(9600);
pinMode(data, OUTPUT);
pinMode(clock, OUTPUT);
pinMode(strob, OUTPUT);
pinMode(oe, OUTPUT);
}
void PulseClock(void) {
digitalWrite(clock, LOW);
delayMicroseconds(20);
digitalWrite(clock, HIGH);
delayMicroseconds(50);
digitalWrite(clock, LOW);
}
void loop()
{
dato = 255;
for (count = 0; count < 8; count++) {
digitalWrite(data, dato & 01);
//serialWrite((dato & 01) + 48);
dato>>=1;
if (count == 7){
digitalWrite(oe, LOW);
digitalWrite(strob, HIGH);
}
PulseClock();
digitalWrite(oe, HIGH);
}
delayMicroseconds(20);
digitalWrite(strob, LOW);
delay(100); // waits for a moment
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment