I am in desperate need of help with a 3x3x3 LED cube. I want to confirm that the pins i need are the digital pins and also any help with prgramming would be appreciated
Ideally you would connect up 12 pins to this, with the anodes connected in columns and cathodes connected in rows/layers.
Spread the anodes across a couple of ports so you don't exceed the port current ratings of section 29 of the datasheet.
Code would drive the anodes, sink from one cathode for 2mS, turn off.
Repeat for next layer.
Repeat for next layer.
Back to first layer.
Chewy,
Crossroads has supplied you with a circuit diagram and here is a link to a young guy that shows you how to construct a cube on YouTube. If you firstly construct a cube like these examples, I know that someone will help you with some code to start out with.
Pedro
Thanks Pedro and Cross roads. I have the cube built but i am just unsure which of the 12 pins i use. Is it only digital pins or a mixture of digital and analog?
All pins can be used as digital pins.
A0 to A5 are D14 to D19.
Chewy,
here is some code that I modified to use in my cube.
/* Code by Pedro147 inspired by this -
http://www.abrushfx.com/Arduino/ledcube3.html
*/
int ledRow[] = { 11, 12, 13 };
int ledCol[]= { 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int timer= 10;
void setup()
{
for( int i = 0; i < 3; i++)
{
pinMode( ledRow[i],OUTPUT);
}
{
for(int j = 0; j < 9; j++)
{
pinMode( ledCol[j],OUTPUT);
}
}
}
void onLED(int ledRow, int ledCol){
digitalWrite(ledRow, HIGH);
digitalWrite(ledCol, HIGH);
}
void offLED(int ledRow, int ledCol)
{
digitalWrite(ledRow, LOW);
digitalWrite(ledCol, LOW);
}
void allOff()
{
for(int i = 3; i--;)
{
for(int j = 9; j--;)
{
offLED(ledRow[i],ledCol[j]);
}
}
}
void oneToNine_ColsOn()
{
for(int j = 9; j--;)
{
for(int i = 3; i--;)
{
digitalWrite(ledRow[i], HIGH);
delay(10);
digitalWrite(ledCol[j], HIGH);
}
}
}
void everySecond_ColsOn1()
{
for(int j = 0; j < 9; j+=2)
{
for(int i = 3; i--;)
{
digitalWrite(ledRow[i], HIGH);
delay(10);
digitalWrite(ledCol[j], HIGH);
}
}
}
void everySecond_ColsOn_2()
{
for(int j = 1; j < 9; j+=2)
{
for(int i = 3; i--;)
{
digitalWrite(ledRow[i], HIGH);
delay(10);
digitalWrite(ledCol[j], HIGH);
}
}
}
void lhWall_fToR()
{
for(int j = 0; j < 9; j+=3)
{
for(int i = 3; i--;)
{
digitalWrite(ledRow[i], HIGH);
delay(10);
digitalWrite(ledCol[j], HIGH);
}
}
}
void rhWall_fToR()
{
for(int j = 2; j < 9; j+=3)
{
for(int i = 3; i--;)
{
digitalWrite(ledRow[i], HIGH);
delay(10);
digitalWrite(ledCol[j], HIGH);
}
}
}
void frontWall_LtoR()
{
for(int j = 0; j < 3; j++)
{
for(int i = 3; i--;)
{
digitalWrite(ledRow[i], HIGH);
delay(10);
digitalWrite(ledCol[j], HIGH);
}
}
}
void rearWall_LtoR()
{
for(int j = 6; j <9; j++)
{
for(int i = 3; i--;)
{
digitalWrite(ledRow[i], HIGH);
delay(10);
digitalWrite(ledCol[j], HIGH);
}
}
}
void centreWall_LtoR()
{
for(int j = 3; j < 6; j++)
{
for(int i = 3; i--;)
{
digitalWrite(ledRow[i], HIGH);
delay(timer);
digitalWrite(ledCol[j], HIGH);
}
}
}
void centreWall_fToR()
{
for(int j = 1; j < 9; j+=3)
{
for(int i = 3; i--;)
{
digitalWrite(ledRow[i], HIGH);
delay(timer);
digitalWrite(ledCol[j], HIGH);
}
}
}
void diagWall_LtoR()
{
for(int j = 0; j < 9; j+=4)
{
for(int i = 3; i--;)
{
digitalWrite(ledRow[i], HIGH);
delay(timer);
digitalWrite(ledCol[j], HIGH);
}
}
}
void diagWall_RtoL()
{
for(int j = 2; j < 8; j+=2)
{
for(int i = 3; i--;)
{
digitalWrite(ledRow[i], HIGH);
delay(timer);
digitalWrite(ledCol[j], HIGH);
}
}
}
void rowPaneFigure8()
{
for (int i = 0; i < 3; i++)
{
for(int j = 0; j < 3; j++) // light LED's 1 - 3 on/off on top level
{
onLED(ledRow[i],ledCol[j]); // 7 8 9
delay(timer); // 4 5 6
offLED(ledRow[i],ledCol[j]); // 1 2 3
}
for(int j = 5; j > 2; j--) // light LED's 6 - 4 on/off on top level
{
onLED(ledRow[i],ledCol[j]);
delay(timer);
offLED(ledRow[i],ledCol[j]);
}
for(int j = 6; j < 9; j++) // light LED's 7 - 9 on/off on top level
{
onLED(ledRow[i],ledCol[j]);
delay(timer);
offLED(ledRow[i],ledCol[j]);
}
for(int j = 5; j > 2; j--) // light LED's 6 - 4 on/off on top level
{
onLED(ledRow[i],ledCol[j]);
delay(timer);
offLED(ledRow[i],ledCol[j]);
}
}
}
void frontTorear_flash1()
{
for(int j = 0; j < 9; j+=3)
for(int i = 3; i--;)
{
digitalWrite(ledRow[i], HIGH);
delay(20);
digitalWrite(ledCol[j], HIGH);
}
}
void frontTorear_flash2()
{
for(int j = 1; j < 9; j+=3)
for(int i = 3; i--;)
{
digitalWrite(ledRow[i], HIGH);
delay(20);
digitalWrite(ledCol[j], HIGH);
}
}
void frontTorear_flash3()
{
for(int j = 2; j < 9; j+=3)
for(int i = 3; i--;)
{
digitalWrite(ledRow[i], HIGH);
delay(20);
digitalWrite(ledCol[j], HIGH);
}
}
void randomColumnsOnOff()
{
int colmax = 9;
int stCol = random(0,colmax);
{
digitalWrite(ledRow[0], HIGH);
digitalWrite(ledCol[stCol], HIGH);
digitalWrite(ledRow[1], HIGH);
digitalWrite(ledCol[stCol], HIGH);
digitalWrite(ledRow[2], HIGH);
digitalWrite(ledCol[stCol], HIGH);
delay(timer);
allOff();
}
}
void loop()
{
oneToNine_ColsOn();
delay(10);
allOff();
delay(10);
everySecond_ColsOn1();
delay(10);
allOff();
delay(10);
everySecond_ColsOn_2();
delay(10);
oneToNine_ColsOn();
delay(10);
allOff();
delay(10);
everySecond_ColsOn1();
delay(10);
allOff();
delay(10);
everySecond_ColsOn_2();
delay(10);
lhWall_fToR();
delay(100);
allOff();
centreWall_fToR();
delay(100);
allOff();
rhWall_fToR();
delay(100);
allOff();
frontWall_LtoR();
delay(100);
allOff();
centreWall_LtoR();
delay(100);
allOff();
rearWall_LtoR();
delay(100);
allOff();
rowPaneFigure8();
centreWall_LtoR();
allOff();
diagWall_LtoR();
allOff();
centreWall_fToR();
allOff();
diagWall_RtoL();
allOff();
frontTorear_flash1();
delay (timer);
allOff();
frontTorear_flash2();
delay (timer);
allOff();
frontTorear_flash3();
delay (timer);
allOff();
randomColumnsOnOff();
randomColumnsOnOff();
randomColumnsOnOff();
}
Connect the layers to digital pins 11, 12 and 13 and the columns to digital pins 2 through to 10. This is what it looks like
Good luck Pedro.
Pedro. Without sounding gay. I love you for your help. Thank you so much
I have now learnt a very useful lesson. Don't try something out of my league for a school assessment ever again
You are welcome Chewy. Just out of interest did you manage to get your cube going ok?
I am going to finish construction after some lunch hopefully.
so that script you gave. that is right to just put straight into the arduino programmer? and then up load it?
Should be all good to go as long as you
Connect the layers to digital pins 11, 12 and 13 and the columns to digital pins 2 through to 10
and have the circuit constructed as per Crossroads diagram. Keep us posted as to progress 8)
So I went to program the chip and i got this error:
avrdude: stk500_getsync(): not in sync: resp=0x00
Any ideas?
I am certainly no expert but as far as I am aware this is a lack of communication between your Arduino board and the computer. Firstly check that you have the correct board selected in tools in the IDE (See Pic 1) Also if using a PC, go to start button > control panel > administrative tools > computer management > device manager and see if the Arduino board is showing up in the expanded Ports entry (Pic 2)
Have a look at this thread on the forum
Overall i am not sure which board to select as i have had to do it cheaply. I have built a bare bones version. I have selected the Arduino Pro or mini... like this website has said. I also checked the port in device manager and that registered as com3, so i really dont know
it says this further down.
Unfortunately you are going to hope that someone else here can help you. Seeing as you are also needing to burn the boot loader onto the chip i would suspect that maybe this has not been successfully done yet, but as i said from the start I am certainly no expert.
Also I am trying to use a cp2102 5 pin programmer if that means anything
ok well thanks for the help any way
cp2102 can be used for serial download after you have a bootloader installed.
Many cp2102 bring the chip's reset line out to the header. Instead you need to bring out its DTR connection so that the software can create a reset to the '328 as part of programming. If you got a decent 2102 module the DTR pin is brought out to a hole you can access - if not, some have had luck soldering a wire on to the chip itself.
Is your bare part bootloaded> Do you have another arduino that you can use as a bootload installer?
He mentioned a five pin module - which generally have neither the RST pin - useless as that may be without the modification - or the modem control lines evident as plated-through holes. Not what you refer to as a "decent" module.
Will just have to do the reset manually as soon as you see the successful compilation message in the Arduino IDE.
I have been doing just that for the last couple of days, away from home and using a UNO (clone) on a Windoze 7 netbook instead of my Linux machine at home where the auto-reset works perfectly - I am sure it did on the same board.
Haven't seen this problem mentioned recently.
Checked a bunch of 5-pinners, looks like +5, +3.3, Rx, Tx, Gnd.
And leadless parts wrapped in plastic to, so DTR access would be very difficult.
Manual reset going to be needed.