Close

Example Project 5 - 3x3x3 LED cube - SW Expansion

A project log for The Atmega Hearth

Lets imagine a cheap core for all your breadboard ┬ÁC Projects.

Stefan-XpStefan-Xp 08/21/2014 at 20:1015 Comments

So after a short revision of the existing code i added two new functions just for fun.

You can find them here:

https://gist.github.com/Stefan-Xp/e0cd595200d31ee6518c (Forked from DaveDarko)

I would love to get some feedback ;)

Next: Create some nice animations :D With a 3x3x3 Cube how many different "frames" could be created before repeating? ;)

Discussions

davedarko wrote 08/21/2014 at 21:28 point
hmm, even if I call full_fading(255, 1, 0); I only get a hard to catch fading :( Was it intend to fade between values?

A cool add-on would be integer arrays instead of boolean arrays, to integrate fading into animations.

  Are you sure? yes | no

Stefan-Xp wrote 08/21/2014 at 22:06 point
Try to increase the slowlieness ;-)
Does it fade to fast or to slow?
What do you mean by "fade between values"?
That would indeed be cool ^^

  Are you sure? yes | no

davedarko wrote 08/21/2014 at 22:40 point
I can see the repetition in call full_fading(255, 1, 0); - I see it ramping, but not from zero. really strange. Serial.print gives me values as expected 0-255 and 255-0. I see a little change in the brightness pulsing in 1 Hertz.

I meant something like fade_between(64,127) and it only fades between 64 and 127 up and down, but I guess that's what you've build. Not sure why it wont work on my board. Atmega8 fail? Looks like the same way my code works... strange.

  Are you sure? yes | no

Stefan-Xp wrote 08/22/2014 at 14:05 point
Perhapps delayMicroseconds does not work properly on Atmega8? Or does your Atmega work much faster?
Try a bigger Steps Value?
Its a bit strange...

BTW... did you see this remark: "A boolean holds one of two values, true or false. (Each boolean variable occupies one byte of memory.)" ? So we could also use Byte instead for animations, which would give up to 254 Brightness Levels.

  Are you sure? yes | no

davedarko wrote 08/22/2014 at 14:42 point
The delay functions work, and my fading works the same way... it's a logical software pwm. But It won't fade to black. My code fades on your cube like mine. Really out of ideas :D

Never noticed that it takes a byte, too. Thought the compiler would do some magic with bits in eight bytes. Well then, why not, lets use byte :D

  Are you sure? yes | no

davedarko wrote 08/22/2014 at 15:07 point
HAH! Found it, you activate the cathodes with high, and I do that with low. Switched that and now it's fading. Since I always mix that up, cathodes are negative, right? I tried my functions again and noticed that all was inverted..

  Are you sure? yes | no

Stefan-Xp wrote 08/22/2014 at 15:30 point
Yepp Cathodes are negative :)
But In my case I'm using npn transistors to drive the layers - so the layer is active when High.

  Are you sure? yes | no

Stefan-Xp wrote 08/22/2014 at 15:32 point
Didn't you use a similar schematic as the link said?
Btw: I just updated the SW.

  Are you sure? yes | no

davedarko wrote 08/22/2014 at 15:42 point
oh dear, I overlooked those transistors :D I run them directly, since its fading only one led at 20mA and the atmegaX8 family should be able to drive 40mA. okay, so then I know that I only have to twist that.

  Are you sure? yes | no

davedarko wrote 08/22/2014 at 15:50 point
Nice.

I changed it a bit to;

byte mode=1;
void loop() {
//// select one
//mode = random(8);
//mode = 1;
mode++;

  Are you sure? yes | no

Stefan-Xp wrote 08/22/2014 at 21:59 point
:-) Well done :D
I calculated 168mA per Layer as worst case.

  Are you sure? yes | no

davedarko wrote 08/22/2014 at 22:05 point
but the animations are led per led... so if we don't "just" fade planes, it should be fine ;) at least it's blinking for 3 hours next to me :)

  Are you sure? yes | no

Stefan-Xp wrote 08/23/2014 at 16:58 point
Thank you for pointing out, that the mode variable has to be a global variable. Otherwise it is reset every time :-(

BTW: http://subethasoftware.com/2013/04/09/arduino-compiler-problem-with-ifdefs-solved/ => Now it works how its supposed.
Perhapps the Cathode High and Low definitions can also go into those #ifdef statements.

And i shrinked the programm from 5.242 Byte to 5130 by replacing the integer Pins with defines.

  Are you sure? yes | no

davedarko wrote 08/23/2014 at 17:04 point
I just thought you used random and haven't noticed it yet...

I don't have any problems switching those values :)

  Are you sure? yes | no

Stefan-Xp wrote 08/24/2014 at 20:30 point
I just added the "50 shades of green" (or in your case grey) mode.
But I think there are some issues with the count of frames...
Feel free to test it ;)

  Are you sure? yes | no