A simple, one color, LED cube that does work.
To make the experience fit your profile, pick a username and tell us what interests you.
We found and based on your interests.
_4mal4ledcube.inoFirst code (doesn't work)ino - 3.16 kB - 05/10/2019 at 20:17 |
|
Here is the completed working code for a random pattern. Nothing special, not efficient or fast at all. But it needed to be done quick since it's a gift for my fathers birthday which is now...
#define MOS1 8
#define MOS2 9
#define MOS3 10
#define MOS4 11
#define DAT1 0
#define DAT2 1
#define DAT3 2
#define DAT4 3
#define DAT5 4
#define DAT6 5
#define DAT7 6
#define DAT8 7
#define OE1 A0
#define OE2 A1
#define LE1 A2
#define LE2 A3
void setup() {
// mosfets
pinMode(MOS1, OUTPUT);
pinMode(MOS2, OUTPUT);
pinMode(MOS3, OUTPUT);
pinMode(MOS4, OUTPUT);
// data
pinMode(DAT1, OUTPUT);
pinMode(DAT2, OUTPUT);
pinMode(DAT3, OUTPUT);
pinMode(DAT4, OUTPUT);
pinMode(DAT5, OUTPUT);
pinMode(DAT6, OUTPUT);
pinMode(DAT7, OUTPUT);
pinMode(DAT8, OUTPUT);
// latch
pinMode(LE1, OUTPUT);
pinMode(LE2, OUTPUT);
// disable outpputs
pinMode(OE1, OUTPUT);
pinMode(OE2, OUTPUT);
digitalWrite(OE1, HIGH);
digitalWrite(OE2, HIGH);
}
int data1[] = {0, 0, 0, 0};
int data2[] = {0, 0, 0, 0};
void loop() {
// make new random data
for (int i = 0; i < 4; i++) {
data1[i] = int(random(256));
data2[i] = int(random(256));
}
for (int x = 0; x < 10; x++) {
for (int i = 0; i < 4; i++) {
// enable outpputs
digitalWrite(OE1, LOW);
digitalWrite(OE2, LOW);
// load data1
if (data1[i] % 2 == 0) {
digitalWrite(DAT1, HIGH);
}
if (data1[i] % 3 == 0) {
digitalWrite(DAT2, HIGH);
}
if (data1[i] % 4 == 0) {
digitalWrite(DAT3, HIGH);
}
if (data1[i] % 5 == 0) {
digitalWrite(DAT4, HIGH);
}
if (data1[i] % 6 == 0) {
digitalWrite(DAT5, HIGH);
}
if (data1[i] % 7 == 0) {
digitalWrite(DAT6, HIGH);
}
if (data1[i] % 8 == 0) {
digitalWrite(DAT7, HIGH);
}
if (data1[i] % 9 == 0) {
digitalWrite(DAT8, HIGH);
}
// latch
digitalWrite(LE1, HIGH);
delay(1);
digitalWrite(LE1, LOW);
// reset
digitalWrite(DAT1, LOW);
digitalWrite(DAT2, LOW);
digitalWrite(DAT3, LOW);
digitalWrite(DAT4, LOW);
digitalWrite(DAT5, LOW);
digitalWrite(DAT6, LOW);
digitalWrite(DAT7, LOW);
digitalWrite(DAT8, LOW);
// load data2
if (data2[i] % 2 == 0) {
digitalWrite(DAT1, HIGH);
}
if (data2[i] % 3 == 0) {
digitalWrite(DAT2, HIGH);
}
if (data2[i] % 4 == 0) {
digitalWrite(DAT3, HIGH);
}
if (data2[i] % 5 == 0) {
digitalWrite(DAT4, HIGH);
}
if (data2[i] % 6 == 0) {
digitalWrite(DAT5, HIGH);
}
if (data2[i] % 7 == 0) {
digitalWrite(DAT6, HIGH);
}
if (data2[i] % 8 == 0) {
digitalWrite(DAT7, HIGH);
}
if (data2[i] % 9 == 0) {
digitalWrite(DAT8, HIGH);
}
// latch
digitalWrite(LE2, HIGH);
delay(1);
digitalWrite(LE2, LOW);
// reset
digitalWrite(DAT1, LOW);
digitalWrite(DAT2, LOW);
digitalWrite(DAT3, LOW);
digitalWrite(DAT4, LOW);
digitalWrite(DAT5, LOW);
digitalWrite(DAT6, LOW);
digitalWrite(DAT7, LOW);
digitalWrite(DAT8, LOW);
// enable mosfet
if (i == 0) {
digitalWrite(MOS1, HIGH);
delay(1);
digitalWrite(MOS1, LOW);
} else if (i == 1) {
digitalWrite(MOS2, HIGH);
delay(1);
digitalWrite(MOS2, LOW);
} else if (i == 2) {
digitalWrite(MOS3, HIGH);
delay(1);
digitalWrite(MOS3, LOW);
} else if (i == 3) {
digitalWrite(MOS4, HIGH);
delay(1);
digitalWrite(MOS4, LOW);
}
// disable outpputs
digitalWrite(OE1, HIGH);
digitalWrite(OE2, HIGH);
}
delay(1);
}
}
If you want only one led to light up, you have to use modulo with prime numbers. Like this, when modulo 4 is zero, modulo 2 will always be zero too.
Create an account to leave a comment. Already have an account? Log In.
Haha, that's because they are. I have no idea what they are called. I got them like 5 years ago from my father when we cleaned our old hobby room. And he propably got them when he was young. I can' even read the label of the bag anymore :)
They look kinda like some I inherited from my grandfather, except the can is gold plated on those. I can read the label but haven't been able to identify them anyway.
Hey, I got a bag of those LED's... Now you are making me feel old. :)
I actually first clicked on this project just because your tagline said "that doesn't work". Reverse psychology? Well, you got me now..
I changed the title right after I got it to work. I was about to give up but my brother encouraged me to finish it. He also built a base for it.
Become a member to follow this project and never miss any updates
What kind of LEDs(?) did you use here, they kinda look ancient :)