Bike POV Beta 3
From Open Source Urbanism
Code for the Arduino Bike POV project
Status: working (use the font.h code from Bike_POV_Beta_2)
Environment: Arduino 0011 (not working on version 12)
Add #include "stdint.h" to get this code to work with Arduino0018
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 // sensor setup int sensorPIN = 0; // define the Arduino sensor pin int mean = 508; // sensor at rest (no magnet) int sensitivity = 100; // sensor sensitivity boolean sensorFlag = false; // stores sensor state 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 loop() { // printing every letter of the textString for (int i=0; i<sizeof(textString); i++){ printLetter(textString[i]); if(sensorFlag){ sensorFlag = false; // reset the sensor flag break; // restart the text string } } // space between strings pauseFrame(timer3); } 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 pauseFrame(timer1); } //clear the LEDs for (int k=0; k<charHeight; k++) { digitalWrite(LEDpins[k], LOW); } // space between letters pauseFrame(timer2); } void pauseFrame(int duration){ int sensVal; // variable to store the value coming from the sensor unsigned long endTime = millis() + duration; // calculate the end time // wait for a while while(millis() < endTime){ // and keep an eye on the sensor sensVal = analogRead(sensorPIN); // read the Hall Effect Sensor if (sensVal > (mean + sensitivity) || sensVal < (mean - sensitivity)) { sensorFlag = true; // set the sensor flag variable break; // exit the pause } } }

