What is wrong with this simple code?

People, what did i do ? this is all the code has to do, blink some lights, i don't know how to use millis but i don't have to. so what is wrong?

sketch.ino (766 Bytes)

If possible you should always post code directly in the forum thread as text using code tags (</> button on the toolbar). This will make it easy for anyone to look at it, which will increase the likelihood of you getting help. If the sketch is longer than the forum will allow then it's ok to add it as an attachment but in this case it's a short sketch so there's absolutely no reason to use an attachment.

Please always do a Tools > Auto Format on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read. If you're using the Arduino Web Editor then you will not have access to this useful tool. I recommend using the standard Arduino IDE instead.

Please remove unnecessary blank lines from your code before posting to the forum. One or two to separate code into logical sections is fine but large spaces for no reason or random blank lines just make for more scrolling when we're trying to read your code.

TraianGrg:
so what is wrong?

Why don't you tell us? Is is not compiling? If so, then post the full error message. Is it not working as expected? If so, then explain exactly what you intend the code to do and what it's doing instead.

Hi,

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

And a picture of your project so we can see you component layout.

Thanks.. Tom.. :slight_smile:

void loop()
int Green1 = 2;

What does the code block that belongs to a function always start with ?

How many functions with the same name can you have in a program ?

Where is Green1 declared ?

I don't see anything wrong and the compiler doesn't give any errors or warnings.

const int Green1 = 2;
const int Blue1 = 3;
const int Green2 = 4;
const int Blue2 = 5;
const int Green3 = 6;
const int Blue3 = 7;
const int gravity = 800;
const int motor = 2300;
const int dif = 1500;

void setup() {
  Serial.begin(9600);
  pinMode(Green1, OUTPUT);
  pinMode(Blue1, OUTPUT);
  pinMode(Green2, OUTPUT);
  pinMode(Blue2, OUTPUT);
  pinMode(Green3, OUTPUT);
  pinMode(Blue3, OUTPUT);
}

void loop() {
  digitalWrite(Green1, LOW);
  digitalWrite(Blue1, HIGH);
  digitalWrite(Green2, HIGH);
  delay(gravity);
  digitalWrite(Blue1, LOW);
  delay(dif);
  digitalWrite(Green2, LOW);
  digitalWrite(Blue2, HIGH);
  digitalWrite(Green3, HIGH);
  delay(gravity);
  digitalWrite(Blue2, LOW);
  delay(dif);
  digitalWrite(Green3, LOW);
  digitalWrite(Blue3, HIGH);
  digitalWrite(Green1, HIGH);
  delay(gravity);
  digitalWrite(Blue3, LOW);
  delay(dif);
}

The fact that the code is so simple and it "doesn't work" probably means your wiring is wrong. Did you use current limiting resistors with your LEDs? Are they wired the right way around?

I don't see anything wrong and the compiler doesn't give any errors or warnings.

I am not sure what happened, but when I downloaded it there were problems with the code when I pasted it into the IDE but I am not sure what I did to cause them. Sorry for any confusion caused.

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom... :slight_smile:

This motor int global variable never used it.