Pages: [1]   Go Down
Author Topic: Need help with error code  (Read 1199 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I keep getting the error code :error: function definition does not declare parameters. It highlights void setup.

this is my code:
Code:
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
« Last Edit: February 17, 2010, 09:00:26 pm by arduinoalan » Logged

Lincoln, NE
Offline Offline
Full Member
***
Karma: 0
Posts: 105
Having lots of fun with Arduino. Thanks everyone!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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. ;-)
« Last Edit: February 17, 2010, 09:19:32 pm by hwiguna » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks
Logged

Sao Paulo - Brazil
Offline Offline
Sr. Member
****
Karma: 0
Posts: 268
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:

#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);
}  






Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 10
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

yup loops and matrixies are always awesome
Logged

Pages: [1]   Go Up
Jump to: