Go Down

Topic: Breadboard POV (Read 4399 times) previous topic - next topic

whosawhatsis

This is a ten-segment POV device I made on a breadboard using a tiny arduino board I designed.





Mike Mc

Neat. Would be nice to see some video of it in action please :)

The_Bongmaster

nice :) what code are you using? :) and got a schematic? :3
B-dui in creation.

whosawhatsis

No schematic really, just leds on pins 3-12 connected to the breadboard's power rail, which is connected to ground through a 330 Ohm resistor, and a button connecting pin 2 to ground. The button wakes the arduino from sleep mode, and it prints its message then goes back to sleep. Here's my code:

Quote
#include <avr/power.h>
#include <avr/sleep.h>

int ledpin[] = {12,11,10,9,4,3,8,7,6,5};
int dotTime = 1;

int _[] = {0b0000000000,
          0b0000000000,
          0b0000000000,
          0b0000000000,
          0b0000000000};
int A[] = {0b1111111100,
          0b0000010010,
          0b0000010001,
          0b0000010010,
          0b1111111100};
int B[] = {0b1111111111,
          0b1000010001,
          0b1000010001,
          0b0100101010,
          0b0011000100};
int C[] = {0b0011111100,
          0b0100000010,
          0b1000000001,
          0b0100000010,
          0b0011001100};
int D[] = {0b1111111111,
          0b1000000001,
          0b1000000001,
          0b0100000010,
          0b0011111100};
int E[] = {0b1111111111,
          0b1000010001,
          0b1000010001,
          0b1000010001,
          0b1000000001};
int F[] = {0b1111111111,
          0b0000010001,
          0b0000010001,
          0b0000010001,
          0b0000000001};
int G[] = {0b0011111100,
          0b0100000010,
          0b1001000001,
          0b0101000010,
          0b1111001100};
int H[] = {0b1111111111,
          0b0000010000,
          0b0000010000,
          0b0000010000,
          0b1111111111};
int I[] = {0b0000000000,
          0b1000000001,
          0b1111111111,
          0b1000000001,
          0b0000000000};
int J[] = {0b0011111111,
          0b0100000001,
          0b1000000001,
          0b0100000000,
          0b0011000000};
int K[] = {0b1111111111,
          0b0000010000,
          0b0000101000,
          0b0001000100,
          0b1110000011};
int L[] = {0b1111111111,
          0b1000000000,
          0b1000000000,
          0b1000000000,
          0b1000000000};
int M[] = {0b1111111100,
          0b0000000011,
          0b0000001100,
          0b0000000011,
          0b1111111100};
int N[] = {0b1111111111,
          0b0000000110,
          0b0000011000,
          0b0001100000,
          0b1111111100};
int O[] = {0b0011111100,
          0b0100000010,
          0b1000000001,
          0b0100000010,
          0b0011111100};
int P[] = {0b1111111111,
          0b0000010001,
          0b0000010001,
          0b0000001010,
          0b0000000100};
int Q[] = {0b0011111100,
          0b0100000010,
          0b1000000001,
          0b0100000010,
          0b1011111100};
int R[] = {0b1111111111,
          0b0000010001,
          0b0000010001,
          0b0000101010,
          0b1111000100};
int S[] = {0b0011000100,
          0b0100001010,
          0b1000010001,
          0b0100100010,
          0b0011001100};
int T[] = {0b0000000001,
          0b0000000001,
          0b1111111111,
          0b0000000001,
          0b0000000001};
int U[] = {0b0111111111,
          0b1000000000,
          0b1000000000,
          0b1000000000,
          0b0111111111};
int V[] = {0b0000011111,
          0b0011100000,
          0b1100000000,
          0b0011100000,
          0b0000011111};
int W[] = {0b0011111111,
          0b1100000000,
          0b0011000000,
          0b1100000000,
          0b0011111111};
int X[] = {0b1100000011,
          0b0011001100,
          0b0000110000,
          0b0011001100,
          0b1100000011};
int Y[] = {0b0000000011,
          0b0000001100,
          0b1111110000,
          0b0000001100,
          0b0000000011};
int Z[] = {0b1100000001,
          0b1011000001,
          0b1000110001,
          0b1000001101,
          0b1000000011};


void setup() {
 Serial.begin(9600);
 for (int i = 0; i < 10; i++) {
   pinMode(ledpin, OUTPUT);
 }
 pinMode(2, INPUT);
 digitalWrite(2, 1);
 digitalWrite(13, 1);
}

int pow(int num, int power) {
 return round(pow((double)num, (double)power));
}

void printLetter(int letter[]) {
 delay(dotTime);
 for (int i = 0; i < 5; i++) {
   for (int j = 0; j < 10; j++) {
     digitalWrite(ledpin[j], (letter & pow(2, j)) ? HIGH : LOW);
     Serial.print((letter & pow(2, j)) ? "O" : " ");
   }
   Serial.print("|\n");
   delay(dotTime);
 }
 Serial.print("\n");
 for (int i = 0; i < 10; i++)
   digitalWrite(ledpin, 0);
 delay(dotTime);
}

void wake() {}

void loop() {
 delay(1);
 printLetter(H);
 printLetter(E);
 printLetter(L);
 printLetter(L);
 printLetter(O);
 printLetter(_);
 
 attachInterrupt(0, wake, LOW);
 delay(1);
 set_sleep_mode(SLEEP_MODE_PWR_DOWN);
 sleep_enable();
 sleep_mode();
 sleep_disable();
 detachInterrupt(0);
}

Note: the led pins are not in numerical order in the array. This is a result of the way I had to route them to get ten consecutive rows on the breadboard connected to digital pins. The same routing will work if you are using a bare atmega (as this board has the same pinout), but for any other board, you will probably want to change that.

the mighty twix

I did something very similar (borrowing from your code) but I am having difficulties with my LEDs not being that bright. Can you (or anyone) elaborate on how those LEDs are wired up.

Quote
just leds on pins 3-12 connected to the breadboard's power rail, which is connected to ground through a 330 Ohm resistor, and a button connecting pin 2 to ground.


I need a bit of clarification...
:P

whosawhatsis

#5
Mar 22, 2010, 07:06 am Last Edit: Mar 22, 2010, 11:56 am by whosawhatsis Reason: 1
The leds are wired in a common-cathode configuration. Each one has its anode connected to a different digital pin, and the cathodes are all wired together. This common cathode is then connected to a single 330 ohm resistor that is wired to the arduino's ground. You may need to adjust the resistor value for your leds. You may get more consistent brightness by giving each led its own resistor (so none of the leds are wired to each each other), but I didn't see a difference with mine, and it made the wiring a lot easier.

The button on pin 2 activates an interrupt to begin displaying the message.

the mighty twix

Ok I did wire it up the same way you did. I am using 7 red LEDs, and they are really dim. I previously did a POV where I wrote out manually every line such as

digitalWrite(ledpin1, HIGH);
thru
digitalWrite(ledpin7, LOW);

and I had no problems with my brightness. I really liked your code so I decided to give it a try. It was good for me because I had to decipher excatly what the bitwise ternary bit was. Maybe I missed something in your code. I will stab at it again.

THX

whosawhatsis

#7
Mar 22, 2010, 04:25 pm Last Edit: Mar 22, 2010, 04:28 pm by whosawhatsis Reason: 1
Really dim, huh? Sounds like you forgot to set the pinMode to OUTPUT. Running off the ~20k internal pullups has that effect.

Ternary bit? I don't recall using base 3 for anything, I'll have to look over my code again...

the mighty twix

Hmm... Well I declared the pinMode to output in a for loop as you did. When I get home tonight I will try them indiviually, see if that does anything.

As for the ternary bit, excuse my programming newness, is the ? in the
Quote
digitalWrite(ledpin[j], (letter & pow(2, j)) ? HIGH  : LOW);


I thought the ? was called that. I googled it and thats the name it spit out. Then I found out the & (who knew it was called ampersand???) and did the bitwise run around. Busted out the calculator with Binary and started fidling.... It is a pretty neat way to do things. I have no idea what base 3 is though.

I will be looking into it more though.

whosawhatsis

Ah, so it is called that. I always just called it an inline conditional expression.

Ternary is also a name for a base 3 number system, just as binary refers to base 2.

Check your loop carefully. A small error in the loop expression could prevent the loop code from running at all. You may want to temporarily add a serial print or blink your pin 13 led within the loop, just to verify that it is running the expected number of times. If that fails, try uploading a different sketch to simply blink the leds to verify that they can even achieve the desired brightness the way they are wired.

Also, if you post your code, I can take a look for you.

the mighty twix

Well you got it right. I declared all of my pinMode outs individually and they come out nice and bright. I have an exam in the morning so figuring out why my for loop didn't work will have to wait.

Thank you for all the help whosawhatsis

jhonray

does this project have a sensors?

Go Up