Bike POV Beta 2
From Open Source Urbanism
Code for the Arduino Bike POV project
Status: working
Environment: Arduino 0011 (not working on version 12)
This code has been superseded. Get the latest version here.
//============================================================ // Arduino Bike POV // // by Scott Mitchell // www.openobject.org // Open Source Urbanism // // // Copyright (C) 2008 Scott Mitchell 12-10-2008 // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // A copy of the GNU General Public License // can be found at <http://www.gnu.org/licenses/>. // // Last Modified: October 12, 2008 //============================================================ // defining the alphabet #include "font.h" // define the Arduino LED pins in use int LEDpins[] = { 7,6,5,4,3,2,1}; // number of LEDs int charHeight = sizeof(LEDpins); int charWidth = 5; // customizable parameters int timer1 = 1; // time between columns int timer2 = 3; // time between letters int timer3 = 10; // time between strings char textString[] = "OPEN SOURCE URBANISM"; void setup() { for (int i = 0; i < charHeight; i++) pinMode(LEDpins[i], OUTPUT); // set each pin as an output } void printLetter(char ch) { byte letter[5]; // make sure the character is within the alphabet bounds (defined by the font.h file) // if it's not, make it a blank character if (ch < 32 || ch > 126){ ch = 32; } // subtract the space character (converts the ASCII number to the font index number) ch -= 32; // step through each byte of the character array for (int i=0; i<charWidth; i++) { byte b = font[ch][i]; // bit shift through the byte and output it to the pin for (int j=0; j<charHeight; j++) { digitalWrite(LEDpins[j], !!(b & (1 << j))); } // space between columns delay(timer1); } //clear the LEDs for (int k=0; k<charHeight; k++) { digitalWrite(LEDpins[k], LOW); } // space between letters delay(timer2); } void loop() { // printing every letter of the textString for (int i=0; i<sizeof(textString); i++){ printLetter(textString[i]); } // space between strings delay(timer3); }
The alphabet for the dot matrix display is defined in the following header file. Save the following code as a plain text file named "font.h" then attach the file to the program using the 'Sketch > Add File...' menu option in the Arduino programming environment.
NOTE: There are errors in the font definition. For a revised version see Bike_POV_Beta_4
//============================================================ // Arduino Bike POV // font.h // // by Scott Mitchell // www.openobject.org // Open Source Urbanism // // Copyright (C) 2008 Scott Mitchell 12-10-2008 // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // A copy of the GNU General Public License // can be found at <http://www.gnu.org/licenses/>. // // Last Modified: October 12, 2008 //============================================================ // defining the alphabet // ascii 7x5 side-feeding characters for led modules // taken from http://www.sxlist.com/TECHREF/datafile/charset/7x5.htm by Alice Campbell const byte font[][5] = { { 0 , 0 , 0 , 0 , 0 } // blank 32 ,{ 0 , 0 , 61 , 0 , 0 } // ! 33 ,{ 0 , 48 , 0 , 48 , 0 } // " 34 ,{ 0 , 60 , 16 , 60 , 0 } // # 35 ,{ 8 , 18 , 51 , 18 , 4 } // $ 36 ,{ 25 , 2 , 12 , 16 , 38 } // % 37 ,{ 22 , 41 , 41 , 17 , 7 } // & 38 ,{ 0 , 0 , 0 , 48 , 0 } // ' 39 ,{ 12 , 18 , 33 , 0 , 0 } // ( 40 ,{ 0 , 0 , 33 , 18 , 12 } // ) 41 ,{ 33 , 18 , 12 , 18 , 33 } // * 42 ,{ 0 , 0 , 30 , 0 , 0 } // + 43 ,{ 0 , 0 , 1 , 2 , 0 } // , 44 ,{ 0 , 0 , 0 , 0 , 0 } // - 45 ,{ 0 , 0 , 0 , 3 , 3 } // . 46 ,{ 2 , 4 , 0 , 8 , 16 } // / 47 ,{ 63 , 35 , 33 , 49 , 63 } // 0 48 ,{ 0 , 17 , 63 , 1 , 0 } // 1 49 ,{ 19 , 37 , 33 , 41 , 17 } // 2 50 ,{ 18 , 33 , 33 , 33 , 30 } // 3 51 ,{ 4 , 4 , 12 , 20 , 63 } // 4 52 ,{ 57 , 33 , 33 , 33 , 6 } // 5 53 ,{ 14 , 17 , 33 , 1 , 6 } // 6 54 ,{ 19 , 36 , 32 , 40 , 48 } // 7 55 ,{ 18 , 45 , 33 , 45 , 18 } // 8 56 ,{ 16 , 43 , 36 , 32 , 24 } // 9 57 ,{ 0 , 0 , 30 , 0 , 0 } // : 58 ,{ 0 , 2 , 20 , 0 , 0 } // } // 59 ,{ 0 , 12 , 18 , 33 , 0 } // < 60 ,{ 12 , 12 , 12 , 12 , 12 } // = 61 ,{ 0 , 33 , 18 , 12 , 0 } // > 62 ,{ 16 , 32 , 37 , 32 , 24 } // ? 63 ,{ 24 , 36 , 58 , 50 , 58 } // @ 64 ,{ 15 , 16 , 32 , 16 , 15 } // A 65 ,{ 63 , 33 , 33 , 33 , 31 } // B 66 ,{ 30 , 33 , 33 , 33 , 33 } // C 67 ,{ 63 , 33 , 33 , 33 , 30 } // D 68 ,{ 63 , 33 , 33 , 33 , 33 } // E 69 ,{ 63 , 32 , 32 , 32 , 32 } // F 70 ,{ 30 , 33 , 33 , 33 , 22 } // G 71 ,{ 63 , 0 , 0 , 0 , 63 } // H 72 ,{ 0 , 33 , 63 , 33 , 0 } // I 73 ,{ 2 , 1 , 1 , 1 , 62 } // J 74 ,{ 63 , 8 , 8 , 20 , 35 } // K 75 ,{ 63 , 1 , 1 , 1 , 1 } // L 76 ,{ 63 , 16 , 8 , 16 , 63 } // M 77 ,{ 63 , 16 , 8 , 4 , 63 } // N 78 ,{ 30 , 33 , 33 , 33 , 30 } // O 79 ,{ 63 , 32 , 32 , 32 , 24 } // P 80 ,{ 14 , 33 , 33 , 35 , 31 } // Q 81 ,{ 63 , 32 , 36 , 34 , 25 } // R 82 ,{ 25 , 33 , 33 , 33 , 38 } // S 83 ,{ 32 , 32 , 63 , 32 , 32 } // T 84 ,{ 62 , 1 , 1 , 1 , 62 } // U 85 ,{ 56 , 4 , 3 , 4 , 56 } // V 86 ,{ 63 , 2 , 7 , 2 , 63 } // W 87 ,{ 51 , 12 , 0 , 12 , 51 } // 1 88 ,{ 48 , 8 , 7 , 8 , 48 } // Y 89 ,{ 35 , 37 , 33 , 41 , 49 } // Z 90 ,{ 0 , 63 , 33 , 33 , 0 } // [ 91 ,{ 16 , 8 , 0 , 4 , 2 } // \ 92 ,{ 0 , 33 , 33 , 63 , 0 } // ] 93 ,{ 8 , 16 , 32 , 16 , 8 } // ^ 94 ,{ 1 , 1 , 1 , 1 , 1 } // _ 95 ,{ 32 , 16 , 0 , 0 , 0 } // ` 96 ,{ 2 , 5 , 1 , 1 , 7 } // a 97 ,{ 63 , 1 , 1 , 1 , 6 } // b 98 ,{ 6 , 1 , 1 , 1 , 0 } // c 99 ,{ 6 , 1 , 1 , 1 , 63 } // d 100 ,{ 6 , 3 , 5 , 5 , 5 } // e 101 ,{ 0 , 31 , 32 , 32 , 0 } // f 102 ,{ 24 , 35 , 33 , 63 , 32 } // g 103 ,{ 63 , 0 , 0 , 7 , 0 } // h 104 ,{ 0 , 0 , 23 , 0 , 0 } // i 105 ,{ 2 , 1 , 46 , 0 , 0 } // j 106 ,{ 31 , 6 , 5 , 1 , 0 } // k 107 ,{ 33 , 63 , 1 , 0 , 0 } // l 108 ,{ 7 , 0 , 4 , 0 , 7 } // m 109 ,{ 7 , 0 , 0 , 4 , 3 } // n 110 ,{ 6 , 1 , 1 , 6 , 0 } // o 111 ,{ 7 , 12 , 12 , 8 , 0 } // p 112 ,{ 4 , 8 , 12 , 7 , 0 } // q 113 ,{ 0 , 15 , 0 , 0 , 0 } // r 114 ,{ 5 , 5 , 3 , 2 , 0 } // s 115 ,{ 0 , 15 , 1 , 1 , 0 } // t 116 ,{ 6 , 1 , 1 , 7 , 0 } // u 117 ,{ 4 , 2 , 3 , 4 , 0 } // v 118 ,{ 7 , 1 , 6 , 1 , 7 } // w 119 ,{ 1 , 6 , 6 , 1 , 0 } // x 120 ,{ 9 , 1 , 6 , 12 , 0 } // y 121 ,{ 1 , 3 , 5 , 1 , 0 } // z 122 ,{ 0 , 31 , 33 , 32 , 0 } // { 123 ,{ 0 , 0 , 63 , 0 , 0 } // | 124 ,{ 0 , 0 , 33 , 63 , 0 } // } 125 ,{ 56 , 32 , 16 , 8 , 56 } // ~ 126 ,{ 63 , 63 , 63 , 63 , 63 } // 128 ,{ 8 , 16 , 47 , 16 , 8 } // arrow up--needs reassigned ascii code ,{ 4 , 2 , 61 , 2 , 4 } // arrow down--needs reassigned ascii code };

