Skip to content

Instantly share code, notes, and snippets.

@yutannihilation
Last active August 29, 2015 14:20
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 yutannihilation/6d9621660e8f962015b8 to your computer and use it in GitHub Desktop.
Save yutannihilation/6d9621660e8f962015b8 to your computer and use it in GitHub Desktop.
An example Arudino code of charlieplexing. For details about charlieplexing, read this: http://en.wikipedia.org/wiki/Charlieplexing
// referenced this code: http://www.instructables.com/id/Charlieplexed-Arduino-8x8-LED-Grid-Display-Shield-/step2/Code/
const int UPPERPIN = 13;
const int LOWERPIN = 11;
void setup() {
resetAllPins();
}
void loop() {
for(int i=LOWERPIN;i<=UPPERPIN;i++){
for(int j=LOWERPIN;j<=UPPERPIN;j++){
if (i == j) continue;
pinMode(i, OUTPUT);
pinMode(j, OUTPUT);
digitalWrite(i, HIGH);
digitalWrite(j, LOW);
delay(1000);
resetAllPins();
}
}
}
void resetAllPins(){
for(int i=LOWERPIN;i<=UPPERPIN;i++){
pinMode(i, INPUT);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment