Pages: [1]   Go Down
Author Topic: 8 Led's to show binary message  (Read 1142 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello all.

Im currently building a project using an Uno board in which i have 8 led's in a row and require them to cycle through a message in binary.

the leds are on pins 2 through 9

so if i wanted to have the leds spell arduino i would want it to cycle through the following (where 0 is off and 1 is on and between each letter a delay) :

01100001
01110010
01100100
01110101
01101001
01101110
01101111

i have searched for a few weeks and cant find anything that does what i need.

any help would be amazing, thanks in advance

Coley
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you want just write "Arduino" you can simple turn on/off each LED and add a delay.

Code:
int led7 = 9;
...
int led0=2;

void setup() {               
  pinMode(led7, OUTPUT);  // initialize the digital pin as an output.
  ...
  pinMode(led0, OUTPUT);
} //End of setup


void loop() {
// 01100001
  digitalWrite(led7, LOW);
  digitalWrite(led6, HIGH);
  digitalWrite(led5, HIGH);
  digitalWrite(led4, LOW);
  ...
  digitalWrite(led0, HIGH);

  delay(1000);   // wait for a second

//and the others

} //End of loop

You can do this also by an Array or very flexible by ASCII-Code from a String.
Logged

Southern California
Offline Offline
Full Member
***
Karma: 0
Posts: 108
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

A few weeks?  I think this is what you want.  Copy the code below and run the sketch.  Enter your text into the serial monitor.  Study this example until you can do it for yourself.

Code:
// LED binary display with 8 LEDs using serial monitor input
// Tom Fangrow, August 5, 2012

int i;                        // counter used to switch pins

void setup() {
  Serial.begin(9600);         // open serial port at 9600 baud
  for(i=2; i<10; i++) {       // for LEDs on pins 2 thru 9
    pinMode(i, OUTPUT);       // set each pin for output
  }
}

void loop() {
  if(Serial.available()) {    // if anything on port
    byte c = Serial.read();   // read character
    for(i=2; i<10; i++) {     // while there is data remaining
      digitalWrite(i, c%2);   // display the least significant bit
      c /= 2;                 // move to next significant bit
    }
    delay(1000);              // look at character for 1 second
  }
}

(code edited slightly a few minutes after posting)
« Last Edit: August 05, 2012, 03:11:34 pm by JavaMan » Logged

0
Offline Offline
Faraday Member
**
Karma: 24
Posts: 3495
20 LEDs are enough
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Basically you attempt with 8 LEDs what I did with 20 LEDs. So maybe you fill find my POV code helpful. http://blog.blinkenlight.net/experiments/basic-effects/pov-reloaded/. It should not be to hard to adapt this to 8 LEDs instead of 20.
Logged

Check out my experiments http://blog.blinkenlight.net

Wisconsin
Offline Offline
Edison Member
*
Karma: 4
Posts: 1001
I LOVE THIS STUFF!!!!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You want "write" arduino on a row of eight leds using binary? I dont quite understand hiw you expect to relay letter infirmation through eight bit binary. You could do it with a minimum of 20 leds if you want to clearly illuminate an led version of the word "arduino".

Could you elaborate a bit more? I'm clearly missing something
Logged

Accelerate to 88 miles per hour.

Offline Offline
Sr. Member
****
Karma: 6
Posts: 429
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If they were arranged like this...
0000
0000
0000
0000
0000
but still would not be a very good display for letters, lots of better ways to do it.
Logged

Pages: [1]   Go Up
Jump to: