Newbie and don't know where to begin, also please help with this thingie

First, sorry if this is in the wrong place. I'm an absolute beginner. I have a basic electronics knowledge from my time in the service. I can read a schematic. I have built a previous project using an uno where I just copied, pasted, and uploaded the code to complete a working project. (Remote control 110 v switch box). I build small circuits I copy online using 555 timers and 4017 IC's. All that to give you an idea where my skill level is. First, I would like to ask if anyone can recommend a good book to get started with Arduino. I prefer books over electronic media, so I would greatly appreciate a good book suggestion.

Also, I'm trying like crazy to make an LED cube. I built a 3x3x3 cube with a 555 timer and 4020 IC. It works but the effects are meh. So I wanted to build one ran by an Arduino or Raspberry Pi. I found a post here and I built the 2x2x2 cube and tried to upload the code posted in that forum. It has errors and needless to say, I don't know how to fix them. So until I get my book, in the meantime would anybody maybe fix that code for me so I can upload it and show my kids this little cube when they get home from school? I don't know much but it looks like whatever the errors are, they seem to be a simple fix for someone who knows what they're doing. That person is not me.

Thank you in advance for your suggestions and help and I'm happy to be a new part of this forum.

  • Always show us a good schematic of your proposed circuit.
    Show us good images of your ‘actual’ wiring.

  • In the Arduino IDE, use Ctrl T or CMD T to format your code then copy the complete sketch.
    Use the < CODE / > icon from the ‘posting menu’ to attach the copied sketch.

  • Master this book.

  • Here is your homework . . .

That code from that topic compiles without error, so please post the errors you are getting, to resolve them first.

  • This might be of interest to you.

Here's the errors. I actually just solved it by removing the last couple lines. I don't know if that's right, but it worked.

C:\Users\email\AppData\Local\Temp\.arduinoIDE-unsaved2026111-21288-fhzn88.8agx\sketch_feb11a\sketch_feb11a.ino: In function 'void setup()':
C:\Users\email\AppData\Local\Temp\.arduinoIDE-unsaved2026111-21288-fhzn88.8agx\sketch_feb11a\sketch_feb11a.ino:260:8: error: redefinition of 'void setup()'
  }void setup() {
        ^~~~~
C:\Users\email\AppData\Local\Temp\.arduinoIDE-unsaved2026111-21288-fhzn88.8agx\sketch_feb11a\sketch_feb11a.ino:3:6: note: 'void setup()' previously defined here
 void setup ()
      ^~~~~
C:\Users\email\AppData\Local\Temp\.arduinoIDE-unsaved2026111-21288-fhzn88.8agx\sketch_feb11a\sketch_feb11a.ino: In function 'void loop()':
C:\Users\email\AppData\Local\Temp\.arduinoIDE-unsaved2026111-21288-fhzn88.8agx\sketch_feb11a\sketch_feb11a.ino:265:6: error: redefinition of 'void loop()'
 void loop() {
      ^~~~
C:\Users\email\AppData\Local\Temp\.arduinoIDE-unsaved2026111-21288-fhzn88.8agx\sketch_feb11a\sketch_feb11a.ino:14:6: note: 'void loop()' previously defined here
 void loop()
      ^~~~
exit status 1

Compilation error: redefinition of 'void setup()'

Thank you very much for all of that. Bookmarked the post, I'm ordering that book. Really appreciate it.

Looks like you copied the program twice.

I probably did.

  • Note, the error message identifies the problem.

Hello,

I found the cookbook a complete waste of time. (As a beginner).

I’m sure it’s fine if you already know what you are doing.

I did manage to purchase it second hand.

Try your local library.

Yeah, I saw that and went to the errors. Originally there was a v missing on void. It was trying to figure out what "oid" was. So I fixed that first, then got that part and I didn't have a clue where to begin to know how to fix that (quickly anyway). So I took a chance and deleted those last couple of lines. Then it told me it expected a } at the end. So I put that back and tried it. It worked. I solved the problem but not really sure what I actually did. I saw it said "previously defined" and redefinition and all that. So I figured it was conflicting with something earlier and I wasn't sure how to fix that. So I deleted that section and it worked.

  • Sometimes the errors are difficult to understand.

  • You can copy the error and ask an AI to explain.

Have fun.

1 Like

Ahh, never thought of that. Thank you!

I understand books are terrific for referencing other pages, and web sites are a distraction, but If you do not mind a readable web site, rather than listening to a video, DroneBotWorkShop.com writes about all Arduinos and peripherals, and he uses that text as his script in his videos. He is thorough.

Wokwi.com is a great place to practice "thingie" sketches... like these...

p.s. Link in Post #1 works and produces patterns on 2x2 LEDs.

The Arduino Cookbook is designed for users of all skill levels, from beginners to more experienced makers, offering over a hundred tips and techniques for various projects. It provides solutions to common problems and questions Arduino users encounter, making it accessible for anyone interested in experimenting with the Arduino platform.

Apparently you need something more basic.

Hi @doesntwork.

When you create a new sketch in Arduino IDE, it is pre-filled with the code for a minimal "skeleton" of a program:

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

This is useful in the case where you are writing your own sketch, in which case you will add your own code into that skeleton. For example:

 void setup() {
-  // put your setup code here, to run once:
-
+  Serial.begin(9600);
 }

 void loop() {
-  // put your main code here, to run repeatedly:
-
+  Serial.println("hello");
+  delay(1000);
 }

However, in the case where you are copy/pasting an existing sketch, you must make sure to completely replace that pre-filled skeleton code. The error you encountered was likely caused by you pasting the code from that forum post into a new sketch alongside the skeleton code. So you ended up with this invalid code:

/*Code provided by Brian W. Cordes 2013*/

int ledpins[] = { 3, 5, 6, 9 };
int groundpins[] = { 12, 13 };
void setup() {
  for (int i = 0; i < 4; i++) {
    pinMode(ledpins[i], OUTPUT);
  }
  for (int i = 0; i < 2; i++) {
    pinMode(groundpins[i], OUTPUT);
  }
}

void loop() {
  twist();
  drop();
  diagonal();
}

void twist() {
  int delaytime = 100;
  digitalWrite(groundpins[0], HIGH);
  delay(100);
  digitalWrite(ledpins[0], HIGH);
  delay(delaytime);
  digitalWrite(ledpins[1], HIGH);
  delay(delaytime);
  digitalWrite(ledpins[2], HIGH);
  delay(delaytime);
  digitalWrite(ledpins[3], HIGH);
  delay(delaytime);

  digitalWrite(ledpins[0], LOW);
  delay(delaytime);
  digitalWrite(ledpins[1], LOW);
  delay(delaytime);
  digitalWrite(ledpins[2], LOW);
  delay(delaytime);
  digitalWrite(ledpins[3], LOW);
  delay(delaytime);
  digitalWrite(groundpins[0], LOW);


  digitalWrite(groundpins[1], HIGH);
  delay(100);
  digitalWrite(ledpins[1], HIGH);
  delay(delaytime);
  digitalWrite(ledpins[2], HIGH);
  delay(delaytime);
  digitalWrite(ledpins[3], HIGH);
  delay(delaytime);
  digitalWrite(ledpins[0], HIGH);
  delay(delaytime);

  digitalWrite(ledpins[1], LOW);
  delay(delaytime);
  digitalWrite(ledpins[2], LOW);
  delay(delaytime);
  digitalWrite(ledpins[3], LOW);
  delay(delaytime);
  digitalWrite(ledpins[0], LOW);
  delay(delaytime);
  digitalWrite(groundpins[1], LOW);


  digitalWrite(groundpins[0], HIGH);
  delay(100);
  digitalWrite(ledpins[2], HIGH);
  delay(delaytime);
  digitalWrite(ledpins[3], HIGH);
  delay(delaytime);
  digitalWrite(ledpins[0], HIGH);
  delay(delaytime);
  digitalWrite(ledpins[1], HIGH);
  delay(delaytime);

  digitalWrite(ledpins[2], LOW);
  delay(delaytime);
  digitalWrite(ledpins[3], LOW);
  delay(delaytime);
  digitalWrite(ledpins[0], LOW);
  delay(delaytime);
  digitalWrite(ledpins[1], LOW);
  delay(delaytime);
  digitalWrite(groundpins[0], LOW);

  digitalWrite(groundpins[1], HIGH);
  delay(100);
  digitalWrite(ledpins[3], HIGH);
  delay(delaytime);
  digitalWrite(ledpins[0], HIGH);
  delay(delaytime);
  digitalWrite(ledpins[1], HIGH);
  delay(delaytime);
  digitalWrite(ledpins[2], HIGH);
  delay(delaytime);

  digitalWrite(ledpins[3], LOW);
  delay(delaytime);
  digitalWrite(ledpins[0], LOW);
  delay(delaytime);
  digitalWrite(ledpins[1], LOW);
  delay(delaytime);
  digitalWrite(ledpins[2], LOW);
  delay(delaytime);
  digitalWrite(groundpins[1], LOW);
}

void drop() {
  int dtime = 75;
  digitalWrite(groundpins[0], HIGH);
  digitalWrite(ledpins[0], HIGH);
  delay(dtime);
  digitalWrite(groundpins[0], LOW);
  digitalWrite(groundpins[1], HIGH);
  delay(dtime);
  digitalWrite(groundpins[1], LOW);
  digitalWrite(ledpins[0], LOW);

  digitalWrite(groundpins[0], HIGH);
  digitalWrite(ledpins[1], HIGH);
  delay(dtime);
  digitalWrite(groundpins[0], LOW);
  digitalWrite(groundpins[1], HIGH);
  delay(dtime);
  digitalWrite(groundpins[1], LOW);
  digitalWrite(ledpins[1], LOW);

  digitalWrite(groundpins[0], HIGH);
  digitalWrite(ledpins[2], HIGH);
  delay(dtime);
  digitalWrite(groundpins[0], LOW);
  digitalWrite(groundpins[1], HIGH);
  delay(dtime);
  digitalWrite(groundpins[1], LOW);
  digitalWrite(ledpins[2], LOW);

  digitalWrite(groundpins[0], HIGH);
  digitalWrite(ledpins[3], HIGH);
  delay(dtime);
  digitalWrite(groundpins[0], LOW);
  digitalWrite(groundpins[1], HIGH);
  delay(dtime);
  digitalWrite(groundpins[1], LOW);
  digitalWrite(ledpins[3], LOW);


  //second time down
  digitalWrite(groundpins[0], HIGH);
  digitalWrite(ledpins[0], HIGH);
  delay(dtime);
  digitalWrite(groundpins[0], LOW);
  digitalWrite(groundpins[1], HIGH);
  delay(dtime);
  digitalWrite(groundpins[1], LOW);
  digitalWrite(ledpins[0], LOW);

  digitalWrite(groundpins[0], HIGH);
  digitalWrite(ledpins[1], HIGH);
  delay(dtime);
  digitalWrite(groundpins[0], LOW);
  digitalWrite(groundpins[1], HIGH);
  delay(dtime);
  digitalWrite(groundpins[1], LOW);
  digitalWrite(ledpins[1], LOW);

  digitalWrite(groundpins[0], HIGH);
  digitalWrite(ledpins[2], HIGH);
  delay(dtime);
  digitalWrite(groundpins[0], LOW);
  digitalWrite(groundpins[1], HIGH);
  delay(dtime);
  digitalWrite(groundpins[1], LOW);
  digitalWrite(ledpins[2], LOW);

  digitalWrite(groundpins[0], HIGH);
  digitalWrite(ledpins[3], HIGH);
  delay(dtime);
  digitalWrite(groundpins[0], LOW);
  digitalWrite(groundpins[1], HIGH);
  delay(dtime);
  digitalWrite(groundpins[1], LOW);
  digitalWrite(ledpins[3], LOW);
}

void diagonal() {
  int dtime = 100;
  //bottom pin 0 on
  digitalWrite(groundpins[1], HIGH);
  digitalWrite(ledpins[0], HIGH);
  delay(dtime);
  //bottom pin 0 off
  digitalWrite(groundpins[1], LOW);
  digitalWrite(ledpins[0], LOW);
  delay(dtime);
  //top pin 1 on
  digitalWrite(groundpins[0], HIGH);
  digitalWrite(ledpins[1], HIGH);
  delay(dtime);
  //top pin 1 off
  digitalWrite(groundpins[0], LOW);
  digitalWrite(ledpins[1], LOW);
  //bottom pin 2 on
  digitalWrite(groundpins[1], HIGH);
  digitalWrite(ledpins[2], HIGH);
  delay(dtime);
  //bottom pin 2 off
  digitalWrite(groundpins[1], LOW);
  digitalWrite(ledpins[2], LOW);
  //top pin 3 on
  digitalWrite(groundpins[0], HIGH);
  digitalWrite(ledpins[3], HIGH);
  delay(dtime);
  //top pin 3 off
  digitalWrite(groundpins[0], LOW);
  digitalWrite(ledpins[3], LOW);


  //top pin 0 on
  digitalWrite(groundpins[0], HIGH);
  digitalWrite(ledpins[0], HIGH);
  delay(dtime);
  //top pin 0 off
  digitalWrite(groundpins[0], LOW);
  digitalWrite(ledpins[0], LOW);
  delay(dtime);
  //bottom pin 1 on
  digitalWrite(groundpins[1], HIGH);
  digitalWrite(ledpins[1], HIGH);
  delay(dtime);
  //bottom pin 1 off
  digitalWrite(groundpins[1], LOW);
  digitalWrite(ledpins[1], LOW);
  //top pin 2 on
  digitalWrite(groundpins[0], HIGH);
  digitalWrite(ledpins[2], HIGH);
  delay(dtime);
  //top pin 2 off
  digitalWrite(groundpins[0], LOW);
  digitalWrite(ledpins[2], LOW);
  //bottom pin 3 on
  digitalWrite(groundpins[1], HIGH);
  digitalWrite(ledpins[3], HIGH);
  delay(dtime);
  //bottom pin 3 off
  digitalWrite(groundpins[1], LOW);
  digitalWrite(ledpins[3], LOW);
}void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

Do you see how that skeleton code is still present at the end of the LED cube code? This is wrong.

Well, as they say, one mans meat is another mans poison.
A lot of people might disagree with your assessment.
Learning is often about seeing something a different way.
Personally, I've always liked to have physical textbooks, and go back a long way when written text was the only way to learn.
As I've said several times before, if I had to pick just one book on using Arduino, it would be Arduino Cookbook.
I hope you progress enough to appreciate it on a second look.

1 Like

This is the only that stuck out to me, I didn’t even read the rest :joy:

I have never seen that as someone’s username before.

If you’re just getting started, I’d recommend beginning with the Arduino Starter Kit tutorials to learn basic components and code structure. Once you’re comfortable, try breaking your project into small steps — like blinking an LED first — before moving to bigger ideas. It really helps make things less overwhelming!