openobject.org

Bike POV Beta 1

From Open Source Urbanism

Code for the Arduino Bike POV project

28th September, 2008

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
// taken from http://heim.ifi.uio.no/haakoh/avr/
byte A[] = {
  0x3f, 0x48, 0x48, 0x48, 0x3f};
byte B[] = {
  0x7f, 0x49, 0x49, 0x49, 0x36};
byte C[] = {
  0x3e, 0x41, 0x41, 0x41, 0x22};
byte D[] = {
  0x7f, 0x41, 0x41, 0x22, 0x1c};
byte E[] = {
  0x7f, 0x49, 0x49, 0x49, 0x41};
byte F[] = {
  0x7f, 0x48, 0x48, 0x48, 0x40};
byte G[] = {
  0x3e, 0x41, 0x49, 0x49, 0x2e};
byte H[] = {
  0x7f, 0x08, 0x08, 0x08, 0x7f};
byte I[] = {
  0x00, 0x41, 0x7f, 0x41, 0x00};
byte J[] = {
  0x06, 0x01, 0x01, 0x01, 0x7e};
byte K[] = {
  0x7f, 0x08, 0x14, 0x22, 0x41};
byte L[] = {
  0x7f, 0x01, 0x01, 0x01, 0x01};
byte M[] = {
  0x7f, 0x20, 0x10, 0x20, 0x7f};
byte N[] = {
  0x7f, 0x10, 0x08, 0x04, 0x7f};
byte O[] = {
  0x3e, 0x41, 0x41, 0x41, 0x3e};
byte P[] = {
  0x7f, 0x48, 0x48, 0x48, 0x30};
byte Q[] = {
  0x3e, 0x41, 0x45, 0x42, 0x3d};
byte R[] = {
  0x7f, 0x48, 0x4c, 0x4a, 0x31};
byte S[] = {
  0x31, 0x49, 0x49, 0x49, 0x46};
byte T[] = {
  0x40, 0x40, 0x7f, 0x40, 0x40};
byte U[] = {
  0x7e, 0x01, 0x01, 0x01, 0x7e};
byte V[] = {
  0x7c, 0x02, 0x01, 0x02, 0x7c};
byte W[] = {
  0x7f, 0x02, 0x04, 0x02, 0x7f};
byte X[] = {
  0x63, 0x14, 0x08, 0x14, 0x63};
byte Y[] = {
  0x60, 0x10, 0x0f, 0x10, 0x60};
byte Z[] = {
  0x43, 0x45, 0x49, 0x51, 0x61};
byte num0[] = {
  0x3e, 0x45, 0x49, 0x51, 0x3e};
byte num1[] = {
  0x00, 0x10, 0x20, 0x7f, 0x00};
byte num2[] = {
  0x47, 0x49, 0x49, 0x49, 0x31};
byte num3[] = {
  0x42, 0x49, 0x59, 0x69, 0x46};
byte num4[] = {
  0x08, 0x18, 0x28, 0x7f, 0x08};
byte num5[] = {
  0x71, 0x49, 0x49, 0x49, 0x46};
byte num6[] = {
  0x3e, 0x49, 0x49, 0x49, 0x06};
byte num7[] = {
  0x40, 0x47, 0x48, 0x50, 0x60};
byte num8[] = {
  0x36, 0x49, 0x49, 0x49, 0x36};
byte num9[] = {
  0x30, 0x49, 0x49, 0x49, 0x3e};
byte alt0[] = {
  0x7f, 0x41, 0x41, 0x41, 0x7f};
byte alt1[] = {
  0x00, 0x00, 0x00, 0x00, 0x7f};
byte alt2[] = {
  0x4f, 0x49, 0x49, 0x49, 0x79};
byte alt3[] = {
  0x49, 0x49, 0x49, 0x49, 0x7f};
byte alt4[] = {
  0x78, 0x08, 0x08, 0x08, 0x7f};
byte alt5[] = {
  0x79, 0x49, 0x49, 0x49, 0x4f};
byte alt6[] = {
  0x7f, 0x49, 0x49, 0x49, 0x4f};
byte alt7[] = {
  0x40, 0x40, 0x40, 0x40, 0x7f};
byte alt8[] = {
  0x7f, 0x49, 0x49, 0x49, 0x7f};
byte alt9[] = {
  0x79, 0x49, 0x49, 0x49, 0x7f};

// 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 = 3;			// time between columns
int timer2 = 15;		// time between letters
int timer3 = 50;		// time between words

void setup()
{
  int i;
  for (i = 0; i < charHeight; i++)
    pinMode(LEDpins[i], OUTPUT);	// set each pin as an output
}

void printLetter(byte letter[])
{
  int i,j;

  // step through each byte of the letter array
  for (i=0; i<charWidth; i++) {
    byte b = letter[i];

    // bit shift through the byte and output it to the pin
    for (j=0; j<charHeight; j++) {
      digitalWrite(LEDpins[j], !!(b & (1 << j)));
    }

    // space between columns
    delay(timer1);
  }

  //clear the LEDs
  for (j=0; j<charHeight; j++) {
    digitalWrite(LEDpins[j], LOW);
  }

  // space between letters
  delay(timer2);
}

void loop()
{
  // printing some letters
  printLetter(O);
  printLetter(P);
  printLetter(E);
  printLetter(N);
  
  // space between words
  delay(timer3);
}