Go Down

Topic: Need help with error code (Read 1 time) previous topic - next topic

arduuinoalan

Feb 18, 2010, 02:59 am Last Edit: Feb 18, 2010, 03:00 am by arduinoalan Reason: 1
I keep getting the error code :error: function definition does not declare parameters. It highlights void setup.

this is my code:
Code: [Select]
int ledpin2 = 2;
int ledpin3 = 3;
int ledpin4 = 4;
int ledpin5 = 5;
int ledpin6 = 6;
int ledpin7 = 7;
int ledpin8 = 8;
int ledpin9 = 9;
int ledpin10 = 10;
int ledpin11 = 11;
int ledpin12 = 12;
int ledpin13 = 13;

void setup {
 pinMode(ledpin2, OUTPUT);
 pinMode(ledpin3, OUTPUT);
 pinMode(ledpin4, OUTPUT);
 pinMode(ledpin5, OUTPUT);
 pinMode(ledpin6, OUTPUT);
 pinMode(ledpin7, OUTPUT);
 pinMode(ledpin8, OUTPUT);
 pinMode(ledpin9, OUTPUT);
 pinMode(ledpin10, OUTPUT);
 pinMode(ledpin11, OUTPUT);
 pinMode(ledpin12, OUTPUT);
 pinMode(ledpin13, OUTPUT);
 
 digitalWrite(ledpin8, HIGH);
 digitalWrite(ledpin9, HIGH);
 digitalWrite(ledpin10, HIGH);
 digitalWrite(ledpin11, HIGH);
 digitalWrite(ledipin12, HIGH);
 digitalWrite(ledoin13, HIGH);
}
void loop{
 digitalWrite(ledpin2, HIGH);
 digitalWrite(ledpin8, LOW);
}


thanks

hari

#1
Feb 18, 2010, 03:16 am Last Edit: Feb 18, 2010, 03:19 am by hwiguna Reason: 1
Just a simple typo:
You need parentheses when defining functions even when they have no parameters, so you need setup() and loop().

There is also a typo on the last two lines of setup(), ledpin12 and ledpin13 are mistyped.  Computers are picky that way. ;-)


Radames

I think you'll have more control if you do like this..

Code: [Select]


#define nleds 12

int ledpin[nleds] ={2,3,4,5,6,7,8,9,10,11,12,13};

void setup {
 for(int i=0;i<nleds;i++){
   pinMode(ledpin[i],OUTPUT);
 }
 for (int i=8;i<nleds;i++){
      digitalWrite(ledpin[i], HIGH);  
 }  
}
void loop{
 digitalWrite(ledpin[0], HIGH);
 digitalWrite(ledpin[6], LOW);
}  







dragon2777

yup loops and matrixies are always awesome

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy