Please help me find the error in this simple led sketch(Changed to lcd proggram)

Before the code here is the error...
sketch_aug09a:-1: error: expected unqualified-id before numeric constant
sketch_aug09a:5: error: expected ',' or ';' before 'int'
sketch_aug09a.cpp: In function 'void loop()':
sketch_aug09a:31: error: expected ',' or ';' before 'if'
sketch_aug09a:35: error: expected ',' or ';' before 'if'
sketch_aug09a:39: error: 'end' was not declared in this scope
sketch_aug09a:86: error: 'else' without a previous 'if'
sketch_aug09a:140: error: expected `}' at end of input
Code:

/* digital pins 1-9*/
int a = 1
int b = 2 
int c = 3
int d = 4
int e = 5
int f = 6
int g = 7
int h = 8
int i = 9


void setup() {                
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(1, OUTPUT);
pinMode(2, OUTPUT);   
pinMode(3, OUTPUT);   
pinMode(4, OUTPUT);   
pinMode(5, OUTPUT);   
pinMode(6, OUTPUT);   
pinMode(7, OUTPUT);   
pinMode(8, OUTPUT);   
pinMode(9, OUTPUT);   
}

void loop() {
int ran = random(1,2) // 1 = Random pixels 2 = shapes
  if (ran == 1) ;
    delay(5);
              int randd = random(1,9)
     
              if (randd == 1); //a
              digitalWrite(1, HIGH);
             delay(1000);
              digitalWrite(1,LOW);
              end;
              
              if (randd == 2); //b
              digitalWrite(2, HIGH);
             delay(1000);
              digitalWrite(2,LOW);
              end;
             
              if (randd == 3);
              digitalWrite(3,HIGH);
              delay(1000);
              digitalWrite(3,LOW);
              end;
                            if (randd == 4); //a
              digitalWrite(4, HIGH);
             delay(1000);
              digitalWrite(4,LOW);
              end;
              
              if (randd == 5); //b
              digitalWrite(5, HIGH);
             delay(1000);
              digitalWrite(5,LOW);
              end;
             
              if (randd == 6);
              digitalWrite(6,HIGH);
              delay(1000);
              digitalWrite(6,LOW);
              end;
                            if (randd == 7); //a
              digitalWrite(7, HIGH);
             delay(1000);
              digitalWrite(7,LOW);
              end;
              
              if (randd == 8); //b
              digitalWrite(8, HIGH);
             delay(1000);
              digitalWrite(8,LOW);
              end;
             
              if (randd == 9);
              digitalWrite(9,HIGH);
              delay(1000);
              digitalWrite(9,LOW);
              end;
    else ;
        digitalWrite(1,HIGH);
        delay(500);
        digitalWrite(2,HIGH);
        delay(500);
        digitalWrite(1,LOW);
        digitalWrite(3,HIGH);
       delay(500);
        digitalWrite(2,LOW);
        digitalWrite(4,HIGH);
        delay(500);
        digitalWrite(3,LOW);
        digitalWrite(5,HIGH);
        delay(500);
        digitalWrite(4,LOW);
        digitalWrite(6,HIGH);
        delay(500);
        digitalWrite(5,LOW);
        digitalWrite(7,HIGH);       
        delay(500);
        digitalWrite(6,LOW);
        digitalWrite(8,HIGH);
        delay(500);
        digitalWrite(7,LOW);
        digitalWrite(9,HIGH);
        delay(500);
        digitalWrite(8,LOW);
        digitalWrite(1,HIGH);
         delay(500);
        digitalWrite(2,HIGH);
        digitalWrite(9,LOW);
        delay(500);
        digitalWrite(1,LOW);
        digitalWrite(3,HIGH);
       delay(500);
        digitalWrite(2,LOW);
        digitalWrite(4,HIGH);
        delay(500);
        digitalWrite(3,LOW);
        digitalWrite(5,HIGH);
        delay(500);
        digitalWrite(4,LOW);
        digitalWrite(6,HIGH);
        delay(500);
        digitalWrite(5,LOW);
        digitalWrite(7,HIGH) ;       
        delay(500);
        digitalWrite(6,LOW);
        digitalWrite(8,HIGH);
        delay(500);
        digitalWrite(7,LOW);
        digitalWrite(9,HIGH);
        delay(500);
        digitalWrite(8,LOW);       
        end;

Lines 2-10 all miss semicolons, line 29 misses a semicolon, line 30 should not have a semicolon, line 32 misses a semicolon, line 38, 44, 50, 55, ... (the "end"s) don't make sense -- This is C and not one of the various languages that use "end" as closing parentheses -- Lines 34, 40, 46, ... should not have a semicolon...

Instead of:

  int randd = random(1,9)
     
              if (randd == 1); //a
              digitalWrite(1, HIGH);
             delay(1000);
              digitalWrite(1,LOW);
              end;
              
              if (randd == 2); //b
              digitalWrite(2, HIGH);
             delay(1000);
              digitalWrite(2,LOW);
              end;
             
              if (randd == 3);
              digitalWrite(3,HIGH);
              delay(1000);
              digitalWrite(3,LOW);
              end;
                            if (randd == 4); //a
              digitalWrite(4, HIGH);
             delay(1000);
              digitalWrite(4,LOW);
              end;
              
              if (randd == 5); //b
              digitalWrite(5, HIGH);
             delay(1000);
              digitalWrite(5,LOW);
              end;
             
              if (randd == 6);
              digitalWrite(6,HIGH);
              delay(1000);
              digitalWrite(6,LOW);
              end;
                            if (randd == 7); //a
              digitalWrite(7, HIGH);
             delay(1000);
              digitalWrite(7,LOW);
              end;
              
              if (randd == 8); //b
              digitalWrite(8, HIGH);
             delay(1000);
              digitalWrite(8,LOW);
              end;
             
              if (randd == 9);
              digitalWrite(9,HIGH);
              delay(1000);
              digitalWrite(9,LOW);
              end;

How about:

int randd = random (1,9);

digitalWrite (randd, HIGH);
delay (1000);
digitalWrite (randd, LOW);

Saves a fair bit of effort.

Plus everything dominikh said.

Wow... Nice.... And can you all help me with programming a LCD... I cant figure it out because no one explains it

Try this, I cleaned up the code and corrected the syntax so that it compiles. I cannot verify it on an Arduino as mine was ordered today and will not be here until next weekend.

/* digital pins 1-9*/
int a = 1;
int b = 2;
int c = 3;
int d = 4;
int e = 5;
int f = 6;
int g = 7;
int h = 8;
int i = 9;


void setup() {                
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(1, OUTPUT);
  pinMode(2, OUTPUT);   
  pinMode(3, OUTPUT);   
  pinMode(4, OUTPUT);   
  pinMode(5, OUTPUT);   
  pinMode(6, OUTPUT);   
  pinMode(7, OUTPUT);   
  pinMode(8, OUTPUT);   
  pinMode(9, OUTPUT);   
}

void loop() {
  int ran = random(1,2); // 1 = Random pixels 2 = shapes
  if (ran == 1) {
    delay(5);
    int randd = random(1,9);

    if (randd == 1) { //a
      digitalWrite(1, HIGH);
      delay(1000);
      digitalWrite(1,LOW);
    }

    if (randd == 2) { //b
      digitalWrite(2, HIGH);
      delay(1000);
      digitalWrite(2,LOW);
    }

    if (randd == 3) {
      digitalWrite(3,HIGH);
      delay(1000);
      digitalWrite(3,LOW);
    }

    if (randd == 4) { //a
      digitalWrite(4, HIGH);
      delay(1000);
      digitalWrite(4,LOW);
    }

    if (randd == 5) { //b
      digitalWrite(5, HIGH);
      delay(1000);
      digitalWrite(5,LOW);
    }

    if (randd == 6) {
      digitalWrite(6,HIGH);
      delay(1000);
      digitalWrite(6,LOW);
    }

    if (randd == 7) { //a
      digitalWrite(7, HIGH);
      delay(1000);
      digitalWrite(7,LOW);
    }

    if (randd == 8) { //b
      digitalWrite(8, HIGH);
      delay(1000);
      digitalWrite(8,LOW);
    }

    if (randd == 9) {
      digitalWrite(9,HIGH);
      delay(1000);
      digitalWrite(9,LOW);
    }
  }
  digitalWrite(1,HIGH);
  delay(500);
  digitalWrite(2,HIGH);
  delay(500);
  digitalWrite(1,LOW);
  digitalWrite(3,HIGH);
  delay(500);
  digitalWrite(2,LOW);
  digitalWrite(4,HIGH);
  delay(500);
  digitalWrite(3,LOW);
  digitalWrite(5,HIGH);
  delay(500);
  digitalWrite(4,LOW);
  digitalWrite(6,HIGH);
  delay(500);
  digitalWrite(5,LOW);
  digitalWrite(7,HIGH);       
  delay(500);
  digitalWrite(6,LOW);
  digitalWrite(8,HIGH);
  delay(500);
  digitalWrite(7,LOW);
  digitalWrite(9,HIGH);
  delay(500);
  digitalWrite(8,LOW);
  digitalWrite(1,HIGH);
  delay(500);
  digitalWrite(2,HIGH);
  digitalWrite(9,LOW);
  delay(500);
  digitalWrite(1,LOW);
  digitalWrite(3,HIGH);
  delay(500);
  digitalWrite(2,LOW);
  digitalWrite(4,HIGH);
  delay(500);
  digitalWrite(3,LOW);
  digitalWrite(5,HIGH);
  delay(500);
  digitalWrite(4,LOW);
  digitalWrite(6,HIGH);
  delay(500);
  digitalWrite(5,LOW);
  digitalWrite(7,HIGH) ;       
  delay(500);
  digitalWrite(6,LOW);
  digitalWrite(8,HIGH);
  delay(500);
  digitalWrite(7,LOW);
  digitalWrite(9,HIGH);
  delay(500);
  digitalWrite(8,LOW);       
}

Awsomdk:
Wow... Nice.... And can you all help me with programming a LCD... I cant figure it out because no one explains it

No-one explains it? Time to do a bit of research ...

I got started with LCDs reading this very nice tutorial:

http://www.ladyada.net/learn/lcd/charlcd.html

An excellent tutorial. Got me started in no time.

I added some code to my test file to make using my 16 x 4 LCD a bit easier.

#include <LiquidCrystal.h>    // include the library code:
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);

void setup() {

  lcd.begin(16, 4);
  lcd.print("hello, world!");

}

void LCDpos(int Lcol, int Lrow) {
  lcd.setCursor(Lcol, Lrow);
  if(Lrow > 1) lcd.setCursor(Lcol + 16, Lrow - 2);
}

void loop() {

  LCDpos(0,1); lcd.print(millis()/1000);
  LCDpos(0,2); lcd.print(millis()/500);
  LCDpos(0,3); 
  lcd.print(millis()/2000);
  lcd.write(0);

}

:slight_smile: thanks dude ... thats just so epic... hate to be a bother to anyone but what is the simplest way to print time to the lcd?

Well, first you have to know the time, that's the trickiest part arguably.
How you print it to the LCD depends on what format the time is in.
If it is UNIX type time it needs to be broken down into a date/hours/minutes/seconds, if it's coming out of a RTC it may already be in that format.

There are a bazillion different options, really.

If i am not crazy ( i had an old computer make your own game) UNIX is the time from like 1970? lol
Whatever is easiest is what i need for now ( I am taking a class later in the year for programming and this is kinda a head start for me

The Arduino doesn't know the time per se. You have to connect up some sort of clock chip (which is why Bobnova said it is the tricky bit). You could use the inbuilt timer (accessed via millis() ) but that is just the number of milliseconds since it powered up, not since 1970. And even that overflows roughly every 50 days.

Could I manually set the time it is then just use millis()/1000 to get the time since boot + the time i set then do some standered functions to get the current time? or would that cause an overflow kinda soon?

Sure you can manually set the time at boot. I had a lengthy whine about that a while back, because that is exactly what my electric blanket does. If it loses power for a second, it also "forgets" the time, and you have to reprogram it. It also forgets the heat you had it set to (which is less forgivable, because it could store that in EEPROM).

... would that cause an overflow kinda soon?

Well do you call 50 days "kinda soon"? In any case you can compensate for that. For example, if you only care about the time and not the date (like my electric blanket) you just reset the timer every 24 hours (or compensate with arithmetic).

Nice... Electric Blanket + arduino? sounds cool...
50 days won't be an issue because i will probbally mess with the programming often...
Can you give an example code?

If you have the board hooked up to your USB, you could set the time by sending the time via the Serial Monitor :

So you would type something like : 09:14:45 Set Time

int incomingByte = 0;	// for incoming serial data
String ReadString;

void setup() {
  Serial.begin(9600);
}

void loop() {

  if (Serial.available() > 0) {
      char c = Serial.read();
      ReadString += c;
      if(ReadString.indexOf('~') > 0) {
        ReadString = "";
        Serial.println("Cleared String");
      }
    Serial.print("I received: ");
    Serial.println(ReadString);
    if(ReadString == "Set Time"){
		//
		// convert ReadString to a variable to hold the supplied time	
		//	
    }
  }
}

well ... i don't have my board yet just getting it... finally just payed and decided to start early and get some prodject ideas out of the box... thanks just give me a bit to decode that...

Now what do i have to do to send the data to the arduino? just upload that and leave the usb or do i need to do something else

Once you have the board, connect via UCB to your PC.

Open the Arduino software, paste the sketch, set the com port and baud speed, upload ( at this point you'll see if there are any coding errors ).

The code will then run on the board.

Open the "Serial Monitor" ( toolbar or Tools > Serial Monitor ).

Anything in the code that follows Serial.print will appear in the serial monitor window - a great tool for debugging and checking the flow of a sketch.

The Serial Monitor also has a small text box at the top. Type in 09:14:45 Set Time and Click on Send.
The serial display should show :
I received: 09:14:45 Set Time

Also with the code, if you type & send a ~ character, it clears the ReadString buffer.

so can you say that in newb terms? and how would I send that to the board?

Once you've got your board, start here ( http://arduino.cc/en/Guide/HomePage ) and all the pieces should easily fall into place.