Go Down

Topic: 8 Led's to show binary message (Read 1 time) previous topic - next topic

Coley

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

TransWarp

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

Code: [Select]
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.

JavaMan

#2
Aug 05, 2012, 09:52 pm Last Edit: Aug 05, 2012, 10:11 pm by JavaMan Reason: 1
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: [Select]
// 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)

Udo Klein

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.
Check out my experiments http://blog.blinkenlight.net

funkyguy4000

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
Accelerate to 88 miles per hour.

Lakes

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.

Go Up