Skip to content

Instantly share code, notes, and snippets.

@JeffersGlass
Created April 26, 2020 20:19
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 JeffersGlass/cf8b5b6acd961fe6634c7a37cf93b3a4 to your computer and use it in GitHub Desktop.
Save JeffersGlass/cf8b5b6acd961fe6634c7a37cf93b3a4 to your computer and use it in GitHub Desktop.
//The three pins connected to their respective ports
//on the shift registers
int CLK_PIN = 10;
int DATA_PIN = 11;
int LATCH_PIN = 12;
void setup() {
//Configure out shift-register outputs
pinMode(CLK_PIN, OUTPUT);
pinMode(DATA_PIN, OUTPUT);
pinMode(LATCH_PIN, OUTPUT);;
}
void loop() {
//Check input - have any buttons been pressed? Update variables to account for what buttons have been pressed.
//check gamestate - has enough time passed for us to do a "tick" of gamestate? If so update the appropriate variables
// and the board display
//check displayUpdate - has enough time passed to need to update the display? If so, take the appropriate actions
// to update the state of the board
}
void checkInput(){
}
void checkGamestate(){
}
void displayUpdate(){
}
void sendIntToDisplay(int input){
//Make sure clock and latch are low before we start, since they
//Trigger on a rising-edge
digitalWrite(CLK_PIN, LOW);
digitalWrite(LATCH_PIN, LOW);
//Clock out the data
shiftOut(DATA_PIN, CLK_PIN, LSBFIRST, lowByte(input));
shiftOut(DATA_PIN, CLK_PIN, LSBFIRST, highByte(input));
//Latch the data in
digitalWrite(LATCH_PIN, HIGH);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment