/* Instructable Arduino LED Shoes By TechKiwi 8 Jan 2016 These LED Shoes use an Arduino Mini Pro todrive an Array of 8x8 LEDs to drive interactive LED sequencing. There is a tilt switch and a push switch input on the circuit Row-Column Scanning an 8x8 LED matrix with X-Y input V1 - LED test on first Shoe produced V2 - Slow down effect V4 - Display all LEDs on full time using routines V5 - Develop Four Display Options 1. All LEDs on COMPLETE 2. Front to Back COMPLETE V6 3. Top to bottom V10 - Add sequence push button to select which of 3 effects required V11 - Add tilt switch ` */ // 2-dimensional array of row pin numbers: const int row[8] = { 2,3,4,5,6,7,8,9 }; // Equates to D1-D9 on Arduino Mini Pro driving the -ve side of LED Array (Cathode via 150 ohm resistor) // 2-dimensional array of column pin numbers: const int col[8] = { 10,11,12,13,14,15,16,17 }; // Equates to D9-D13, A0-A3 on Arduino Mini Pro driving the +ve side of LED Array (Anode) // 2-dimensional array of pixels: int pixels[8][8]; // Brightness delay determines how many Milliseconds each LED is allowed to be lit int brightness = 60; // Delay between samples in terms of Milliseconds int sampledelay = 10; // Delay between each row display mS int stepdelay = 100; // Startup flag determines that just powered on int startup = 0; void setup() { // initialize the I/O pins as outputs pinMode(5, INPUT); // Sequence Press Button pinMode(4, INPUT); // Mercury Tilt Switch Input // iterate over the pins: for (int thisPin = 0; thisPin < 8; thisPin++) { // initialize the output pins: pinMode(col[thisPin], OUTPUT); pinMode(row[thisPin], OUTPUT); // take the col pins (i.e. the cathodes) high to ensure that // the LEDS are off: digitalWrite(col[thisPin], LOW); } // initialize the pixel matrix: for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { pixels[x][y] = LOW; } } } void loop() { //Sequence Button Pushed change sequence Read Analogue Pin if(digitalRead(19) == LOW){ delay(100); // Deboubnce by waiting then checking again if(digitalRead(19) == LOW){ startup = startup + 1; if (startup > 5) { startup = 0; } } delay(100); } // turn all LEDs on if (startup == 0) { allon(); } // Front to back if (startup == 1) { fronttoback(); } // Top to bottom effect // Front to back if (startup == 2) { toptobottom(); } // Tilt Switch ativated then turn all LEDs on if (startup == 3) { if(digitalRead(18) == LOW){ delay(100); // Deboubnce by waiting then checking again if(digitalRead(18) == LOW){ for (int t = 0; t < 100; t++) { allon(); } } } delay(100); } // Front to back // Tilt Switch ativated then Front to back sequence if (startup == 4) { if(digitalRead(18) == LOW){ delay(100); // Deboubnce by waiting then checking again if(digitalRead(18) == LOW){ // for (int t = 0; t < 10; t++) { fronttoback(); // } } } delay(100); } //if (startup == 4) { // fronttoback(); //} // Top to bottom effect // Tilt Switch ativated then Front to back sequence if (startup == 5) { if(digitalRead(18) == LOW){ delay(100); // Deboubnce by waiting then checking again if(digitalRead(18) == LOW){ // for (int t = 0; t < 10; t++) { toptobottom(); // } } } delay(100); } //if (startup == 5) { // toptobottom(); //} } void allon() { refreshScreen(); row0(); row1(); row2(); row3(); row4(); row5(); row6(); row7(); refreshScreen(); drow0(); drow1(); drow2(); drow3(); drow4(); drow5(); drow6(); drow7(); refreshScreen(); } void fronttoback() { // f1 for (int t = 0; t < stepdelay; t++) { f1(); f2(); refreshScreen(); } df1(); df2(); refreshScreen(); delay(sampledelay); // f3 for (int t = 0; t < stepdelay; t++) { f3(); refreshScreen(); } df3(); refreshScreen(); delay(sampledelay); // // f4 for (int t = 0; t < stepdelay; t++) { f4(); f5(); refreshScreen(); } df4(); df5(); refreshScreen(); delay(sampledelay); // // f6 for (int t = 0; t < stepdelay; t++) { f6(); refreshScreen(); } df6(); refreshScreen(); delay(sampledelay); // // f7 for (int t = 0; t < stepdelay; t++) { f7(); refreshScreen(); } df7(); refreshScreen(); delay(sampledelay); // // f8 for (int t = 0; t < stepdelay; t++) { f8(); refreshScreen(); } df8(); refreshScreen(); delay(sampledelay); // // f9 for (int t = 0; t < stepdelay; t++) { f9(); refreshScreen(); } df9(); refreshScreen(); delay(sampledelay); // // f10 for (int t = 0; t < stepdelay; t++) { f10(); refreshScreen(); } df10(); refreshScreen(); delay(sampledelay); // // f11 for (int t = 0; t < stepdelay; t++) { f11(); refreshScreen(); } df11(); refreshScreen(); delay(sampledelay); // // f12 for (int t = 0; t < stepdelay; t++) { f12(); refreshScreen(); } df12(); refreshScreen(); delay(sampledelay); // } void toptobottom() { // t1 for (int t = 0; t < stepdelay; t++) { t1(); refreshScreen(); } dt1(); refreshScreen(); delay(sampledelay); // // t2 for (int t = 0; t < stepdelay; t++) { t2(); refreshScreen(); } dt2(); refreshScreen(); delay(sampledelay); // // t3 for (int t = 0; t < stepdelay; t++) { t3(); refreshScreen(); } dt3(); refreshScreen(); delay(sampledelay); // // t4 for (int t = 0; t < stepdelay; t++) { t4(); refreshScreen(); } dt4(); refreshScreen(); delay(sampledelay); // // t5 for (int t = 0; t < stepdelay; t++) { t5(); refreshScreen(); } dt5(); refreshScreen(); delay(sampledelay); // } void refreshScreen() { // This routine writes the Array Data in Pixels[x],[y] to the Digital outputs. When the row is HIGH and the col is LOW the LED where they meet turns on: // iterate over the rows (anodes): for (int thisRow = 0; thisRow < 8; thisRow++) { // take the row pin (anode) LOW: digitalWrite(row[thisRow], LOW); // iterate over the cols (Anoides): for (int thisCol = 0; thisCol < 8; thisCol++) { // get the state of the current pixel; int thisPixel = pixels[thisRow][thisCol]; // when the row is LOW and the col is HIGH, // the LED where they meet turns on: digitalWrite(col[thisCol], thisPixel); // turn the pixel off: if (thisPixel == HIGH) { // Delay to make LEDs Brighter delayMicroseconds(brightness); // Delay to make LEDs Brighter digitalWrite(col[thisCol], LOW); } } // take the row pin HIGH to turn off the whole row: digitalWrite(row[thisRow], HIGH); } } // Drivers for allon option 1 void row0() { // Personalised Name Text Block pixels[0][0]=HIGH; pixels[0][1]=HIGH; pixels[0][2]=HIGH; pixels[0][3]=HIGH; pixels[0][4]=HIGH; pixels[0][5]=HIGH; pixels[0][6]=HIGH; pixels[0][7]=HIGH; } void drow0() { // Personalised Name Text Block pixels[0][0]=LOW; pixels[0][1]=LOW; pixels[0][2]=LOW; pixels[0][3]=LOW; pixels[0][4]=LOW; pixels[0][5]=LOW; pixels[0][6]=LOW; pixels[0][7]=LOW; } void row1() { // Personalised Name Text Block pixels[1][0]=HIGH; pixels[1][1]=HIGH; pixels[1][2]=HIGH; pixels[1][3]=HIGH; pixels[1][4]=HIGH; pixels[1][5]=HIGH; pixels[1][6]=HIGH; pixels[1][7]=HIGH; } void drow1() { // Personalised Name Text Block pixels[1][0]=LOW; pixels[1][1]=LOW; pixels[1][2]=LOW; pixels[1][3]=LOW; pixels[1][4]=LOW; pixels[1][5]=LOW; pixels[1][6]=LOW; pixels[1][7]=LOW; } void row2() { // Personalised Name Text Block pixels[2][0]=HIGH; pixels[2][1]=HIGH; pixels[2][2]=HIGH; pixels[2][3]=HIGH; pixels[2][4]=HIGH; pixels[2][5]=HIGH; pixels[2][6]=HIGH; pixels[2][7]=HIGH; } void drow2() { // Personalised Name Text Block pixels[2][0]=LOW; pixels[2][1]=LOW; pixels[2][2]=LOW; pixels[2][3]=LOW; pixels[2][4]=LOW; pixels[2][5]=LOW; pixels[2][6]=LOW; pixels[2][7]=LOW; } void row3() { // Personalised Name Text Block pixels[3][0]=HIGH; pixels[3][1]=HIGH; pixels[3][2]=HIGH; pixels[3][3]=HIGH; pixels[3][4]=HIGH; pixels[3][5]=HIGH; pixels[3][6]=HIGH; pixels[3][7]=HIGH; } void drow3() { // Personalised Name Text Block pixels[3][0]=LOW; pixels[3][1]=LOW; pixels[3][2]=LOW; pixels[3][3]=LOW; pixels[3][4]=LOW; pixels[3][5]=LOW; pixels[3][6]=LOW; pixels[3][7]=LOW; } void row4() { // Personalised Name Text Block pixels[4][0]=HIGH; pixels[4][1]=HIGH; pixels[4][2]=HIGH; pixels[4][3]=HIGH; pixels[4][4]=HIGH; pixels[4][5]=HIGH; pixels[4][6]=HIGH; pixels[4][7]=HIGH; } void drow4() { // Personalised Name Text Block pixels[4][0]=LOW; pixels[4][1]=LOW; pixels[4][2]=LOW; pixels[4][3]=LOW; pixels[4][4]=LOW; pixels[4][5]=LOW; pixels[4][6]=LOW; pixels[4][7]=LOW; } void row5() { // Personalised Name Text Block pixels[5][0]=HIGH; pixels[5][1]=HIGH; pixels[5][2]=HIGH; pixels[5][3]=HIGH; pixels[5][4]=HIGH; pixels[5][5]=HIGH; pixels[5][6]=HIGH; pixels[5][7]=HIGH; } void drow5() { // Personalised Name Text Block pixels[5][0]=LOW; pixels[5][1]=LOW; pixels[5][2]=LOW; pixels[5][3]=LOW; pixels[5][4]=LOW; pixels[5][5]=LOW; pixels[5][6]=LOW; pixels[5][7]=LOW; } void row6() { // Personalised Name Text Block pixels[6][0]=HIGH; pixels[6][1]=HIGH; pixels[6][2]=HIGH; pixels[6][3]=HIGH; pixels[6][4]=HIGH; pixels[6][5]=HIGH; pixels[6][6]=HIGH; pixels[6][7]=HIGH; } void drow6() { // Personalised Name Text Block pixels[6][0]=LOW; pixels[6][1]=LOW; pixels[6][2]=LOW; pixels[6][3]=LOW; pixels[6][4]=LOW; pixels[6][5]=LOW; pixels[6][6]=LOW; pixels[6][7]=LOW; } void row7() { // Personalised Name Text Block pixels[7][0]=HIGH; pixels[7][1]=HIGH; pixels[7][2]=HIGH; pixels[7][3]=HIGH; pixels[7][4]=HIGH; pixels[7][5]=HIGH; pixels[7][6]=HIGH; pixels[7][7]=HIGH; } void drow7() { // Personalised Name Text Block pixels[7][0]=LOW; pixels[7][1]=LOW; pixels[7][2]=LOW; pixels[7][3]=LOW; pixels[7][4]=LOW; pixels[7][5]=LOW; pixels[7][6]=LOW; pixels[7][7]=LOW; } // Drivers for fronttoback option 2 void f1() { // Front to back first LED on tip of shoe pixels[7][4]=HIGH; } void df1() { // Front to back first LED on tip of shoe pixels[7][4]=LOW; } void f2() { // Front to back 2nd LED on tip of shoe pixels[7][3]=HIGH; pixels[7][5]=HIGH; } void df2() { // Front to back 2nd LED on tip of shoe pixels[7][3]=LOW; pixels[7][5]=LOW; } void f3() { // Front to back 3rd LED on tip of shoe pixels[7][0]=HIGH; pixels[7][7]=HIGH; pixels[7][1]=HIGH; } void df3() { // Front to back 3rd LED on tip of shoe pixels[7][0]=LOW; pixels[7][7]=LOW; pixels[7][1]=LOW; } void f4() { // Front to back 4th LED on tip of shoe pixels[7][6]=HIGH; pixels[7][2]=HIGH; } void df4() { // Front to back 4th LED on tip of shoe pixels[7][6]=LOW; pixels[7][2]=LOW; } void f5() { // Front to back 5th LED on tip of shoe pixels[6][1]=HIGH; pixels[3][0]=HIGH; } void df5() { // Front to back 5th LED on tip of shoe pixels[6][1]=LOW; pixels[3][0]=LOW; } void f6() { // Front to back 6th LED on tip of shoe pixels[6][7]=HIGH; pixels[6][5]=HIGH; pixels[3][3]=HIGH; pixels[3][2]=HIGH; } void df6() { // Front to back 6th LED on tip of shoe pixels[6][7]=LOW; pixels[6][5]=LOW; pixels[3][3]=LOW; pixels[3][2]=LOW; } void f7() { // Front to back 7th LED on tip of shoe pixels[6][6]=HIGH; pixels[5][5]=HIGH; pixels[5][6]=HIGH; pixels[3][4]=HIGH; pixels[2][2]=HIGH; pixels[2][3]=HIGH; } void df7() { // Front to back 7th LED on tip of shoe pixels[6][6]=LOW; pixels[5][5]=LOW; pixels[5][6]=LOW; pixels[3][4]=LOW; pixels[2][2]=LOW; pixels[2][3]=LOW; } void f8() { // Front to back 8th LED on tip of shoe pixels[4][5]=HIGH; pixels[5][4]=HIGH; pixels[6][4]=HIGH; pixels[2][0]=HIGH; pixels[2][4]=HIGH; pixels[3][7]=HIGH; } void df8() { // Front to back 8th LED on tip of shoe pixels[4][5]=LOW; pixels[5][4]=LOW; pixels[6][4]=LOW; pixels[2][0]=LOW; pixels[2][4]=LOW; pixels[3][7]=LOW; } void f9() { // Front to back 8th LED on tip of shoe pixels[4][6]=HIGH; pixels[5][1]=HIGH; pixels[6][2]=HIGH; pixels[1][2]=HIGH; pixels[2][6]=HIGH; pixels[3][6]=HIGH; } void df9() { // Front to back 8th LED on tip of shoe pixels[4][6]=LOW; pixels[5][1]=LOW; pixels[6][2]=LOW; pixels[1][2]=LOW; pixels[2][6]=LOW; pixels[3][6]=LOW; } void f10() { // Front to back 8th LED on tip of shoe pixels[4][0]=HIGH; pixels[0][5]=HIGH; pixels[5][3]=HIGH; pixels[6][3]=HIGH; pixels[1][3]=HIGH; pixels[1][0]=HIGH; pixels[2][7]=HIGH; pixels[3][5]=HIGH; } void df10() { // Front to back 8th LED on tip of shoe pixels[4][0]=LOW; pixels[0][5]=LOW; pixels[5][3]=LOW; pixels[6][3]=LOW; pixels[1][3]=LOW; pixels[1][0]=LOW; pixels[2][7]=LOW; pixels[3][5]=LOW; } void f11() { // Front to back 8th LED on tip of shoe pixels[4][1]=HIGH; pixels[0][1]=HIGH; pixels[5][2]=HIGH; pixels[5][0]=HIGH; pixels[6][0]=HIGH; pixels[1][4]=HIGH; pixels[0][3]=HIGH; pixels[0][0]=HIGH; pixels[2][5]=HIGH; pixels[3][1]=HIGH; } void df11() { // Front to back 8th LED on tip of shoe pixels[4][1]=LOW; pixels[0][1]=LOW; pixels[5][2]=LOW; pixels[5][0]=LOW; pixels[6][0]=LOW; pixels[1][4]=LOW; pixels[0][3]=LOW; pixels[0][0]=LOW; pixels[2][5]=LOW; pixels[3][1]=LOW; } void f12() { // Front to back 8th LED on tip of shoe pixels[4][7]=HIGH; pixels[4][4]=HIGH; pixels[0][7]=HIGH; pixels[5][7]=HIGH; pixels[1][6]=HIGH; pixels[1][7]=HIGH; pixels[0][4]=HIGH; pixels[2][1]=HIGH; } void df12() { // Front to back 8th LED on tip of shoe pixels[4][7]=LOW; pixels[4][4]=LOW; pixels[0][7]=LOW; pixels[5][7]=LOW; pixels[1][6]=LOW; pixels[1][7]=LOW; pixels[0][4]=LOW; pixels[2][1]=LOW; } void t1() { // Top to bottom effect on shoe pixels[4][7]=HIGH; pixels[4][4]=HIGH; pixels[4][3]=HIGH; pixels[4][2]=HIGH; pixels[1][1]=HIGH; pixels[1][5]=HIGH; pixels[1][7]=HIGH; pixels[1][6]=HIGH; } void dt1() { // Top to bottom effect on shoe pixels[4][7]=LOW; pixels[4][4]=LOW; pixels[4][3]=LOW; pixels[4][2]=LOW; pixels[1][1]=LOW; pixels[1][5]=LOW; pixels[1][7]=LOW; pixels[1][6]=LOW; } void t2() { // Top to bottom effect on shoe pixels[4][0]=HIGH; pixels[0][1]=HIGH; pixels[0][6]=HIGH; pixels[0][7]=HIGH; pixels[0][4]=HIGH; pixels[0][2]=HIGH; pixels[0][3]=HIGH; pixels[1][3]=HIGH; } void dt2() { // Top to bottom effect on shoe pixels[4][0]=LOW; pixels[0][1]=LOW; pixels[0][6]=LOW; pixels[0][7]=LOW; pixels[0][4]=LOW; pixels[0][2]=LOW; pixels[0][3]=LOW; pixels[1][3]=LOW; } void t3() { // Top to bottom effect on shoe pixels[4][6]=HIGH; pixels[0][5]=HIGH; pixels[5][2]=HIGH; pixels[5][7]=HIGH; pixels[1][2]=HIGH; pixels[1][0]=HIGH; pixels[0][0]=HIGH; pixels[2][1]=HIGH; } void dt3() { // Top to bottom effect on shoe pixels[4][6]=LOW; pixels[0][5]=LOW; pixels[5][2]=LOW; pixels[5][7]=LOW; pixels[1][2]=LOW; pixels[1][0]=LOW; pixels[0][0]=LOW; pixels[2][1]=LOW; } void t4() { // Top to bottom effect on shoe pixels[5][0]=HIGH; pixels[5][3]=HIGH; pixels[5][1]=HIGH; pixels[5][4]=HIGH; pixels[5][6]=HIGH; pixels[6][5]=HIGH; pixels[2][5]=HIGH; pixels[2][7]=HIGH; pixels[2][6]=HIGH; pixels[2][4]=HIGH; pixels[2][2]=HIGH; pixels[3][2]=HIGH; pixels[7][6]=HIGH; pixels[7][7]=HIGH; pixels[7][2]=HIGH; } void dt4() { // Top to bottom effect on shoe pixels[5][0]=LOW; pixels[5][3]=LOW; pixels[5][1]=LOW; pixels[5][4]=LOW; pixels[5][6]=LOW; pixels[6][5]=LOW; pixels[2][5]=LOW; pixels[2][7]=LOW; pixels[2][6]=LOW; pixels[2][4]=LOW; pixels[2][2]=LOW; pixels[3][2]=LOW; pixels[7][6]=LOW; pixels[7][7]=LOW; pixels[7][2]=LOW; } void t5() { // Top to bottom effect on shoe pixels[7][4]=HIGH; pixels[7][5]=HIGH; pixels[7][1]=HIGH; pixels[6][1]=HIGH; pixels[6][7]=HIGH; pixels[6][6]=HIGH; pixels[6][4]=HIGH; pixels[6][2]=HIGH; pixels[6][3]=HIGH; pixels[6][0]=HIGH; pixels[3][1]=HIGH; pixels[3][5]=HIGH; pixels[3][6]=HIGH; pixels[3][7]=HIGH; pixels[3][4]=HIGH; pixels[3][3]=HIGH; pixels[3][0]=HIGH; pixels[7][0]=HIGH; pixels[7][3]=HIGH; } void dt5() { // Top to bottom effect on shoe pixels[7][4]=LOW; pixels[7][5]=LOW; pixels[7][1]=LOW; pixels[6][1]=LOW; pixels[6][7]=LOW; pixels[6][6]=LOW; pixels[6][4]=LOW; pixels[6][2]=LOW; pixels[6][3]=LOW; pixels[6][0]=LOW; pixels[3][1]=LOW; pixels[3][5]=LOW; pixels[3][6]=LOW; pixels[3][7]=LOW; pixels[3][4]=LOW; pixels[3][3]=LOW; pixels[3][0]=LOW; pixels[7][0]=LOW; pixels[7][3]=LOW; }