Adruino 14 segment LED board

From Randomdata wiki
Revision as of 12:01, 22 August 2009 by Fish (Talk | contribs)

Jump to: navigation, search

Introduction

For HAR2009 we had build a 14 segment board (max to use on Arduino).
The board was able to retrieve messages from http://www.randomdata.nl/goofy/goofy.php and display the letters piece by piece.
There is still a log of all the messages but the board is now down, probably we will use it on other conference like Brucon

The board and the build

The 14segboard1.jpg
The 14segboard2.jpg
The 14segboard3.jpg

Schema

TBD

The Arduino code

Don't look at my programming skills, it works but it can use some adjustments



/*
 * Blink board at HAR2009, made by Fish, free for use but send me an update or picture.
 */

#include <Ethernet.h>
byte mac[] = { 0x88, 0xED, 0xBE, 0xEF, 0xFE, 0xED }; //the arduino's mac address
byte ip[] = { 87, 76, 53, 182 }; // the arduino's op address
byte server[] = { 0, 0, 0, 0 }; // ip address of server to get the characters
byte gateway[] =  { 87, 76, 52, 1 }; //ip address of the gateway
byte subnet[] = { 255, 255 ,254 ,0 }; //subnetmask

Client client(server, 80 ); //Define the connect to the webserver

int ledPin1 = 18;                // LED connected to digital pin 1
int ledPin2 = 19;                // LED connected to digital pin 2
int ledPin3 = 2;                // LED connected to digital pinntf 3
int ledPin4 = 3;                // LED connected to digital pin 4
int ledPin5 = 4;                // LED connected to digital pin 5
int ledPin6 = 5;                // LED connected to digital pin 6
int ledPin7 = 6;                // LED connected to digital pin 7
int ledPin8 = 7;                // LED connected to digital pin 8
int ledPin9 = 8;                // LED connected to digital pin 9
int ledPin10 = 9;                // LED connected to digital pin 10
int ledPin11 = 14;                // LED connected to digital pin 11
int ledPin12 = 15;                // LED connected to digital pin 12
int ledPin13 = 16;                // LED connected to digital pin 13
int ledPin14 = 17;                // LED connected to digital pin 14
int time = 500;                 // the time a segment should be on
int timeshort = 200;             //time of lights off
int timebreak = 40;            //time te remove all the lights

void setup()                    // run once, when the sketch starts
{
  Ethernet.begin(mac, ip, gateway, subnet); //starting the ethernet
  delay(1000);
  
  Serial.begin(9600); //for debug you can open a serial connection
  if (client.connect()) {
  Serial.println("connected");
  client.println("GET /hitb2600rd.txt HTTP/1.0");
  client.println();

  for (int i=0; i <= 408; i++){
     if (client.available()) {
     char c = client.read(); //skipping the first few characters caused by the HTTP header
     }
  }
  }
  
  pinMode(ledPin1, OUTPUT);      // sets the digital pin as output
  pinMode(ledPin2, OUTPUT);      // sets the digital pin as output
  pinMode(ledPin3, OUTPUT);      // sets the digital pin as output
  pinMode(ledPin4, OUTPUT);      // sets the digital pin as output
  pinMode(ledPin5, OUTPUT);      // sets the digital pin as output
  pinMode(ledPin6, OUTPUT);      // sets the digital pin as output
  pinMode(ledPin7, OUTPUT);      // sets the digital pin as output
  pinMode(ledPin8, OUTPUT);      // sets the digital pin as output
  pinMode(ledPin9, OUTPUT);      // sets the digital pin as output
  pinMode(ledPin10, OUTPUT);      // sets the digital pin as output
  pinMode(ledPin11, OUTPUT);      // sets the digital pin as output
  pinMode(ledPin12, OUTPUT);      // sets the digital pin as output
  pinMode(ledPin13, OUTPUT);      // sets the digital pin as output
  pinMode(ledPin14, OUTPUT);      // sets the digital pin as output
  
}

int ledoff()
{
  delay(time);
  for (int i=0; i <= 9; i++){
      digitalWrite(i, LOW);    // sets the LEDs off
      delay(timebreak);
  }
  for (int i=14; i <= 19; i++){
      digitalWrite(i, LOW);    // sets the LEDs off
  }
}

int dig1()
{
digitalWrite(ledPin5, HIGH);   // sets the LED on
digitalWrite(ledPin6, HIGH);   // sets the LED on
ledoff();
}
int dig2()
{
digitalWrite(ledPin1, HIGH);   // sets the LED on
digitalWrite(ledPin3, HIGH);   // sets the LED on
digitalWrite(ledPin4, HIGH);   // sets the LED on
digitalWrite(ledPin6, HIGH);   // sets the LED on
digitalWrite(ledPin13, HIGH);   // sets the LED on
digitalWrite(ledPin14, HIGH);   // sets the LED on
ledoff();
}
int dig3()
{
digitalWrite(ledPin1, HIGH);   // sets the LED on
digitalWrite(ledPin4, HIGH);   // sets the LED on
digitalWrite(ledPin5, HIGH);   // sets the LED on
digitalWrite(ledPin6, HIGH);   // sets the LED on
digitalWrite(ledPin13, HIGH);   // sets the LED on
digitalWrite(ledPin14, HIGH);   // sets the LED on
ledoff();
}
int dig4()
{
digitalWrite(ledPin2, HIGH);   // sets the LED on
digitalWrite(ledPin5, HIGH);   // sets the LED on
digitalWrite(ledPin6, HIGH);   // sets the LED on
digitalWrite(ledPin13, HIGH);   // sets the LED on
digitalWrite(ledPin14, HIGH);   // sets the LED on
ledoff();
}
int dig5()
{
digitalWrite(ledPin1, HIGH);   // sets the LED on
digitalWrite(ledPin2, HIGH);   // sets the LED on
digitalWrite(ledPin4, HIGH);   // sets the LED on
digitalWrite(ledPin5, HIGH);   // sets the LED on
digitalWrite(ledPin13, HIGH);   // sets the LED on
digitalWrite(ledPin14, HIGH);   // sets the LED on
ledoff();
}
int dig6()
{
digitalWrite(ledPin1, HIGH);   // sets the LED on
digitalWrite(ledPin2, HIGH);   // sets the LED on
digitalWrite(ledPin3, HIGH);   // sets the LED on
digitalWrite(ledPin4, HIGH);   // sets the LED on
digitalWrite(ledPin5, HIGH);   // sets the LED on
digitalWrite(ledPin13, HIGH);   // sets the LED on
digitalWrite(ledPin14, HIGH);   // sets the LED on
ledoff();
}
int dig7()
{
digitalWrite(ledPin1, HIGH);   // sets the LED on
digitalWrite(ledPin5, HIGH);   // sets the LED on
digitalWrite(ledPin6, HIGH);   // sets the LED on
ledoff();
}
int dig8()
{
digitalWrite(ledPin1, HIGH);   // sets the LED on
digitalWrite(ledPin2, HIGH);   // sets the LED on
digitalWrite(ledPin3, HIGH);   // sets the LED on
digitalWrite(ledPin4, HIGH);   // sets the LED on
digitalWrite(ledPin5, HIGH);   // sets the LED on
digitalWrite(ledPin6, HIGH);   // sets the LED on
digitalWrite(ledPin13, HIGH);   // sets the LED on
digitalWrite(ledPin14, HIGH);   // sets the LED on
ledoff();
}
int dig9()
{
digitalWrite(ledPin1, HIGH);   // sets the LED on
digitalWrite(ledPin2, HIGH);   // sets the LED on
digitalWrite(ledPin4, HIGH);   // sets the LED on
digitalWrite(ledPin5, HIGH);   // sets the LED on
digitalWrite(ledPin6, HIGH);   // sets the LED on
digitalWrite(ledPin13, HIGH);   // sets the LED on
digitalWrite(ledPin14, HIGH);   // sets the LED on
ledoff();
}
int dig0()
{
digitalWrite(ledPin1, HIGH);   // sets the LED on
digitalWrite(ledPin2, HIGH);   // sets the LED on
digitalWrite(ledPin3, HIGH);   // sets the LED on
digitalWrite(ledPin4, HIGH);   // sets the LED on
digitalWrite(ledPin5, HIGH);   // sets the LED on
digitalWrite(ledPin6, HIGH);   // sets the LED on
ledoff();
}
int digA()
{
digitalWrite(ledPin1, HIGH);   // sets the LED on
digitalWrite(ledPin2, HIGH);   // sets the LED on
digitalWrite(ledPin3, HIGH);   // sets the LED on
digitalWrite(ledPin5, HIGH);   // sets the LED on
digitalWrite(ledPin6, HIGH);   // sets the LED on
digitalWrite(ledPin13, HIGH);   // sets the LED on
digitalWrite(ledPin14, HIGH);   // sets the LED on
ledoff();
}
int digB()
{
digitalWrite(ledPin1, HIGH);   // sets the LED on
digitalWrite(ledPin4, HIGH);   // sets the LED on
digitalWrite(ledPin5, HIGH);   // sets the LED on
digitalWrite(ledPin6, HIGH);   // sets the LED on
digitalWrite(ledPin11, HIGH);   // sets the LED on
digitalWrite(ledPin12, HIGH);   // sets the LED on
digitalWrite(ledPin13, HIGH);   // sets the LED on
ledoff();
}
int digC()
{
digitalWrite(ledPin1, HIGH);   // sets the LED on
digitalWrite(ledPin2, HIGH);   // sets the LED on
digitalWrite(ledPin3, HIGH);   // sets the LED on
digitalWrite(ledPin4, HIGH);   // sets the LED on
ledoff();
}
int digD()
{
digitalWrite(ledPin1, HIGH);   // sets the LED on
digitalWrite(ledPin4, HIGH);   // sets the LED on
digitalWrite(ledPin5, HIGH);   // sets the LED on
digitalWrite(ledPin6, HIGH);   // sets the LED on
digitalWrite(ledPin11, HIGH);   // sets the LED on
digitalWrite(ledPin12, HIGH);   // sets the LED on
ledoff();
}
int digE()
{
digitalWrite(ledPin1, HIGH);   // sets the LED on
digitalWrite(ledPin2, HIGH);   // sets the LED on
digitalWrite(ledPin3, HIGH);   // sets the LED on
digitalWrite(ledPin4, HIGH);   // sets the LED on
digitalWrite(ledPin13, HIGH);   // sets the LED on
digitalWrite(ledPin14, HIGH);   // sets the LED on
ledoff();
}
int digF()
{
digitalWrite(ledPin1, HIGH);   // sets the LED on
digitalWrite(ledPin2, HIGH);   // sets the LED on
digitalWrite(ledPin3, HIGH);   // sets the LED on
digitalWrite(ledPin13, HIGH);   // sets the LED on
digitalWrite(ledPin14, HIGH);   // sets the LED on
ledoff();
}
int digG()
{
digitalWrite(ledPin1, HIGH);   // sets the LED on
digitalWrite(ledPin2, HIGH);   // sets the LED on
digitalWrite(ledPin3, HIGH);   // sets the LED on
digitalWrite(ledPin4, HIGH);   // sets the LED on
digitalWrite(ledPin5, HIGH);   // sets the LED on
digitalWrite(ledPin13, HIGH);   // sets the LED on
ledoff();
}
int digH()
{
digitalWrite(ledPin2, HIGH);   // sets the LED on
digitalWrite(ledPin3, HIGH);   // sets the LED on
digitalWrite(ledPin5, HIGH);   // sets the LED on
digitalWrite(ledPin6, HIGH);   // sets the LED on
digitalWrite(ledPin13, HIGH);   // sets the LED on
digitalWrite(ledPin14, HIGH);   // sets the LED on
ledoff();
}
int digI()
{
digitalWrite(ledPin1, HIGH);   // sets the LED on
digitalWrite(ledPin4, HIGH);   // sets the LED on
digitalWrite(ledPin11, HIGH);   // sets the LED on
digitalWrite(ledPin12, HIGH);   // sets the LED on
ledoff();
}
int digJ()
{
digitalWrite(ledPin3, HIGH);   // sets the LED on
digitalWrite(ledPin4, HIGH);   // sets the LED on
digitalWrite(ledPin5, HIGH);   // sets the LED on
digitalWrite(ledPin6, HIGH);   // sets the LED on
ledoff();
}
int digK()
{
digitalWrite(ledPin2, HIGH);   // sets the LED on
digitalWrite(ledPin3, HIGH);   // sets the LED on
digitalWrite(ledPin7, HIGH);   // sets the LED on
digitalWrite(ledPin10, HIGH);   // sets the LED on
digitalWrite(ledPin14, HIGH);   // sets the LED on
ledoff();
}
int digL()
{
digitalWrite(ledPin2, HIGH);   // sets the LED on
digitalWrite(ledPin3, HIGH);   // sets the LED on
digitalWrite(ledPin4, HIGH);   // sets the LED on
ledoff();
}
int digM()
{
digitalWrite(ledPin2, HIGH);   // sets the LED on
digitalWrite(ledPin3, HIGH);   // sets the LED on
digitalWrite(ledPin5, HIGH);   // sets the LED on
digitalWrite(ledPin6, HIGH);   // sets the LED on
digitalWrite(ledPin7, HIGH);   // sets the LED on
digitalWrite(ledPin8, HIGH);   // sets the LED on
ledoff();
}
int digN()
{
digitalWrite(ledPin2, HIGH);   // sets the LED on
digitalWrite(ledPin3, HIGH);   // sets the LED on
digitalWrite(ledPin5, HIGH);   // sets the LED on
digitalWrite(ledPin6, HIGH);   // sets the LED on
digitalWrite(ledPin8, HIGH);   // sets the LED on
digitalWrite(ledPin10, HIGH);   // sets the LED on
ledoff();
}
int digO()
{
digitalWrite(ledPin1, HIGH);   // sets the LED on
digitalWrite(ledPin2, HIGH);   // sets the LED on
digitalWrite(ledPin3, HIGH);   // sets the LED on
digitalWrite(ledPin4, HIGH);   // sets the LED on
digitalWrite(ledPin5, HIGH);   // sets the LED on
digitalWrite(ledPin6, HIGH);   // sets the LED on
ledoff();
}
int digP()
{
digitalWrite(ledPin1, HIGH);   // sets the LED on
digitalWrite(ledPin2, HIGH);   // sets the LED on
digitalWrite(ledPin3, HIGH);   // sets the LED on
digitalWrite(ledPin6, HIGH);   // sets the LED on
digitalWrite(ledPin13, HIGH);   // sets the LED on
digitalWrite(ledPin14, HIGH);   // sets the LED on
ledoff();
}
int digQ()
{
digitalWrite(ledPin1, HIGH);   // sets the LED on
digitalWrite(ledPin2, HIGH);   // sets the LED on
digitalWrite(ledPin3, HIGH);   // sets the LED on
digitalWrite(ledPin4, HIGH);   // sets the LED on
digitalWrite(ledPin5, HIGH);   // sets the LED on
digitalWrite(ledPin6, HIGH);   // sets the LED on
digitalWrite(ledPin10, HIGH);   // sets the LED on
ledoff();
}
int digR()
{
digitalWrite(ledPin1, HIGH);   // sets the LED on
digitalWrite(ledPin2, HIGH);   // sets the LED on
digitalWrite(ledPin3, HIGH);   // sets the LED on
digitalWrite(ledPin6, HIGH);   // sets the LED on
digitalWrite(ledPin10, HIGH);   // sets the LED on
digitalWrite(ledPin13, HIGH);   // sets the LED on
digitalWrite(ledPin14, HIGH);   // sets the LED on
ledoff();
}
int digS()
{
digitalWrite(ledPin1, HIGH);   // sets the LED on
digitalWrite(ledPin2, HIGH);   // sets the LED on
digitalWrite(ledPin4, HIGH);   // sets the LED on
digitalWrite(ledPin5, HIGH);   // sets the LED on
digitalWrite(ledPin13, HIGH);   // sets the LED on
digitalWrite(ledPin14, HIGH);   // sets the LED on
ledoff();
}
int digT()
{
digitalWrite(ledPin1, HIGH);   // sets the LED on
digitalWrite(ledPin11, HIGH);   // sets the LED on
digitalWrite(ledPin12, HIGH);   // sets the LED on
ledoff();
}
int digU()
{
digitalWrite(ledPin2, HIGH);   // sets the LED on
digitalWrite(ledPin3, HIGH);   // sets the LED on
digitalWrite(ledPin4, HIGH);   // sets the LED on
digitalWrite(ledPin5, HIGH);   // sets the LED on
digitalWrite(ledPin6, HIGH);   // sets the LED on
ledoff();
}
int digV()
{
digitalWrite(ledPin2, HIGH);   // sets the LED on
digitalWrite(ledPin3, HIGH);   // sets the LED on
digitalWrite(ledPin7, HIGH);   // sets the LED on
digitalWrite(ledPin9, HIGH);   // sets the LED on
ledoff();
}
int digW()
{
digitalWrite(ledPin2, HIGH);   // sets the LED on
digitalWrite(ledPin3, HIGH);   // sets the LED on
digitalWrite(ledPin5, HIGH);   // sets the LED on
digitalWrite(ledPin6, HIGH);   // sets the LED on
digitalWrite(ledPin9, HIGH);   // sets the LED on
digitalWrite(ledPin10, HIGH);   // sets the LED on
ledoff();
}
int digX()
{
digitalWrite(ledPin7, HIGH);   // sets the LED on
digitalWrite(ledPin8, HIGH);   // sets the LED on
digitalWrite(ledPin9, HIGH);   // sets the LED on
digitalWrite(ledPin10, HIGH);   // sets the LED on
ledoff();
}
int digY()
{
digitalWrite(ledPin2, HIGH);   // sets the LED on
digitalWrite(ledPin6, HIGH);   // sets the LED on
digitalWrite(ledPin12, HIGH);   // sets the LED on
digitalWrite(ledPin13, HIGH);   // sets the LED on
digitalWrite(ledPin14, HIGH);   // sets the LED on
ledoff();
}
int digZ()
{
digitalWrite(ledPin1, HIGH);   // sets the LED on
digitalWrite(ledPin4, HIGH);   // sets the LED on
digitalWrite(ledPin7, HIGH);   // sets the LED on
digitalWrite(ledPin9, HIGH);   // sets the LED on
ledoff();
}
int digspace()
{
digitalWrite(ledPin4, HIGH);   // sets the LED on
ledoff();
}
int digstar()
{
        digitalWrite(ledPin11, HIGH);    // sets the LED on
        delay(40);
        digitalWrite(ledPin11, LOW);    // sets the LED off
        digitalWrite(ledPin8, HIGH);    // sets the LED on
        delay(40);
        digitalWrite(ledPin8, LOW);    // sets the LED off        
        digitalWrite(ledPin14, HIGH);    // sets the LED on
        delay(40);
        digitalWrite(ledPin14, LOW);    // sets the LED off 
        digitalWrite(ledPin9, HIGH);    // sets the LED on
        delay(40);
        digitalWrite(ledPin9, LOW);    // sets the LED off 
        digitalWrite(ledPin12, HIGH);    // sets the LED on
        delay(40);
        digitalWrite(ledPin12, LOW);    // sets the LED off 
        digitalWrite(ledPin10, HIGH);    // sets the LED on
        delay(40);
        digitalWrite(ledPin10, LOW);    // sets the LED off 
        digitalWrite(ledPin13, HIGH);    // sets the LED on
        delay(40);
        digitalWrite(ledPin13, LOW);    // sets the LED off 
        digitalWrite(ledPin7, HIGH);    // sets the LED on
        delay(40);
        digitalWrite(ledPin7, LOW);    // sets the LED off 
}

int digsstar()
{
        digitalWrite(ledPin11, HIGH);    // sets the LED on
        delay(40);
        digitalWrite(ledPin8, HIGH);    // sets the LED on
        delay(40);
        digitalWrite(ledPin14, HIGH);    // sets the LED on
        delay(40);
        digitalWrite(ledPin9, HIGH);    // sets the LED on
        delay(40);
        digitalWrite(ledPin12, HIGH);    // sets the LED on
        delay(40);
        digitalWrite(ledPin10, HIGH);    // sets the LED on
        delay(40);
        digitalWrite(ledPin13, HIGH);    // sets the LED on
        delay(40);
        digitalWrite(ledPin7, HIGH);    // sets the LED on
        delay(40);

        digitalWrite(ledPin11, LOW);    // sets the LED on
        delay(40);
        digitalWrite(ledPin8, LOW);    // sets the LED on
        delay(40);
        digitalWrite(ledPin14, LOW);    // sets the LED on
        delay(40);
        digitalWrite(ledPin9, LOW);    // sets the LED on
        delay(40);
        digitalWrite(ledPin12, LOW);    // sets the LED on
        delay(40);
        digitalWrite(ledPin10, LOW);    // sets the LED on
        delay(40);
        digitalWrite(ledPin13, LOW);    // sets the LED on
        delay(40);
        digitalWrite(ledPin7, LOW);    // sets the LED on
        delay(40);

}

int dighash()
{
        digitalWrite(ledPin2, HIGH);    // sets the LED on
        delay(40);
        digitalWrite(ledPin2, LOW);    // sets the LED off
        digitalWrite(ledPin3, HIGH);    // sets the LED on
        delay(40);
        digitalWrite(ledPin3, LOW);    // sets the LED off
        digitalWrite(ledPin4, HIGH);    // sets the LED on
        delay(40);
        digitalWrite(ledPin4, LOW);    // sets the LED off
        digitalWrite(ledPin5, HIGH);    // sets the LED on
        delay(40);
        digitalWrite(ledPin5, LOW);    // sets the LED off
        digitalWrite(ledPin6, HIGH);    // sets the LED on
        delay(40);
        digitalWrite(ledPin6, LOW);    // sets the LED off
        digitalWrite(ledPin1, HIGH);    // sets the LED on
        delay(40);
        digitalWrite(ledPin1, LOW);    // sets the LED off
}

int digiq()
{
        digitalWrite(ledPin2, HIGH);    // sets the LED on
        delay(400);
        digitalWrite(ledPin1, HIGH);    // sets the LED on
        delay(400);
        digitalWrite(ledPin6, HIGH);    // sets the LED on
        delay(400);
        digitalWrite(ledPin13, HIGH);    // sets the LED on
        delay(400);
        digitalWrite(ledPin12, HIGH);    // sets the LED on
        delay(400);

        digitalWrite(ledPin2, LOW);    // sets the LED on
        delay(400);
        digitalWrite(ledPin1, LOW);    // sets the LED on
        delay(400);
        digitalWrite(ledPin6, LOW);    // sets the LED on
        delay(400);
        digitalWrite(ledPin13, LOW);    // sets the LED on
        delay(400);
        digitalWrite(ledPin12, LOW);    // sets the LED on
        delay(400);
}


void loop()                     // run over and over again, check if the character matches and run the dig# loop
{
  
if (client.available()) {
for (int i=0; i <= 100; i++){
char c = client.read();
if (c == 'A')  digA();
if (c == 'B')  digB();
if (c == 'C')  digC();
if (c == 'D')  digD();
if (c == 'E')  digE();
if (c == 'F')  digF();
if (c == 'G')  digG();
if (c == 'H')  digH();
if (c == 'I')  digI();
if (c == 'J')  digJ();
if (c == 'K')  digK();
if (c == 'L')  digL();
if (c == 'M')  digM();
if (c == 'N')  digN();
if (c == 'O')  digO();
if (c == 'P')  digP();
if (c == 'Q')  digQ();
if (c == 'R')  digR();
if (c == 'S')  digS();
if (c == 'T')  digT();
if (c == 'U')  digU();
if (c == 'V')  digV();
if (c == 'W')  digW();
if (c == 'X')  digX();
if (c == 'Y')  digY();
if (c == 'Z')  digZ();
if (c == '0')  dig0();
if (c == '1')  dig1();
if (c == '2')  dig2();
if (c == '3')  dig3();
if (c == '4')  dig4();
if (c == '5')  dig5();
if (c == '6')  dig6();
if (c == '7')  dig7();
if (c == '8')  dig8();
if (c == '9')  dig9();
if (c == ' ')  digspace();
if (c == '*')  digstar();
if (c == '@')  digsstar();
if (c == '.')  dighash();
if (c == '?')  digiq();


Serial.print(c);
}
} 
else 
{
digstar();
digstar();
digstar();
asm volatile ("  jmp 0"); //reset the board after loop is finished
}
}