Skip to content

Instantly share code, notes, and snippets.

@sham1
Created December 14, 2016 14:35
Show Gist options
  • Save sham1/9362eab4eebed622a350760e04b1c12c to your computer and use it in GitHub Desktop.
Save sham1/9362eab4eebed622a350760e04b1c12c to your computer and use it in GitHub Desktop.
const uint16_t val_1 = (1 << 0);
const uint16_t val_2 = (1 << 8);
const uint16_t val_3 = (1 << 1);
const uint16_t val_4 = (1 << 9);
const uint16_t val_5 = (1 << 2);
const uint16_t val_6 = (1 << 10);
const uint16_t val_7 = (1 << 3);
const uint16_t val_8 = (1 << 11);
const uint16_t val_9 = (1 << 4);
const uint16_t val_ent = (1 << 12);
const int CLOCK_PIN = 13;
const int INPUT_PIN = 12;
const int OUTPUT_PIN = 8;
const int LATCH_PIN = 11;
void setup() {
pinMode(CLOCK_PIN, OUTPUT);
pinMode(INPUT_PIN, OUTPUT);
pinMode(OUTPUT_PIN, INPUT);
pinMode(LATCH_PIN, OUTPUT);
Serial.begin(9600);
}
void loop() {
// When the stuff breaks!
// Enter code
Serial.print("Test");
prepare_button(val_4);
while (digitalRead(OUTPUT_PIN) == LOW);
Serial.print("DEBUG --- PRESSED 4!");
prepare_button(val_6);
while (digitalRead(OUTPUT_PIN) == LOW);
Serial.print("DEBUG --- PRESSED 6!");
prepare_button(val_9);
while (digitalRead(OUTPUT_PIN) == LOW);
Serial.print("DEBUG --- PRESSED 9!");
prepare_button(val_2);
while (digitalRead(OUTPUT_PIN) == LOW);
Serial.print("DEBUG --- PRESSED 2!");
prepare_button(val_ent);
while (digitalRead(OUTPUT_PIN) == LOW);
Serial.print("DEBUG --- PRESSED ENTER!");
// Code entered
Serial.print("DEBUG --- CODE ENTERED!");
}
void prepare_button(uint16_t button){
digitalWrite(CLOCK_PIN, HIGH);
digitalWrite(INPUT_PIN, (int)button);
digitalWrite(CLOCK_PIN, LOW);
digitalWrite(LATCH_PIN, HIGH);
digitalWrite(LATCH_PIN, LOW);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment