// // fa_led_array Charlieplex FabKit LED array // Blair Evans // // adapted from hello.array.44.c // // Charlieplex LED array hello-world // // Neil Gershenfeld // 11/13/10 // // (c) Massachusetts Institute of Technology 2010 // Permission granted for experimental and personal use; // license for commercial sale available from MIT. // const int led_delay = 1000; // LED delay of 1 ms /* SV2 */ const byte A = 3; // row 1 const byte B = 4; // row 2 const byte C = 5; // row 3 const byte D = 6; // row 4 const byte E = 7; // row 5 /* SV1 const byte A = 9; // row 1 const byte B = 10; // row 2 const byte C = 11; // row 3 const byte D = 12; // row 4 const byte E = 13; // row 5 */ void flash(uint8_t from, uint8_t to, uint8_t delay) { // // source from, sink to, flash // static int i; digitalWrite(from,HIGH); //set(led_port,from); digitalWrite(to,LOW); //clear(led_port,to); pinMode(from,OUTPUT); //output(led_direction,from); pinMode(to,OUTPUT); //output(led_direction,to); for (i = 0; i < delay; ++i) delayMicroseconds(led_delay); pinMode(from,INPUT); //input(led_direction,from); pinMode(to,INPUT); // input(led_direction,to); } void led_cycle(int number, int delay) { // // cycle through LEDs // int i; for (i = 0; i < number; ++i) { flash(B,A,delay); flash(C,A,delay); flash(D,A,delay); flash(E,A,delay); flash(A,B,delay); flash(C,B,delay); flash(D,B,delay); flash(E,B,delay); flash(A,C,delay); flash(B,C,delay); flash(D,C,delay); flash(E,C,delay); flash(A,D,delay); flash(B,D,delay); flash(C,D,delay); flash(E,D,delay); flash(A,E,delay); flash(B,E,delay); flash(C,E,delay); flash(D,E,delay); } } void setup() { pinMode(A,INPUT); pinMode(B,INPUT); pinMode(C,INPUT); pinMode(D,INPUT); pinMode(E,INPUT); } void loop() { led_cycle(1,100); led_cycle(3,20); led_cycle(100,1); }