Instantly share code, notes, and snippets.

Embed
What would you like to do?
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