help with if/then

should be a simple fix, but we arent sure what's wrong with our programming.

//    Pull-Up Switch
int puReadPin = 3;     // a DIGITAL pin to read Pull Up switch
int puOutPin = 4;      // a DIGITAL pin to light LED indicator
int puVal = 0;

int led5Pin = 5;
int led6Pin = 6;
int led7Pin = 7;
int led8Pin = 8;
int led9Pin = 9;
int led10Pin = 10;
int led11Pin = 11;
int led12Pin = 12;
int led13Pin = 13;


// Setup
void setup() {
 Serial.begin(9600);   // Start up the serial communication

 pinMode(puReadPin, OUTPUT);
 pinMode(puOutPin, OUTPUT);
}

// Loop
void loop() 

{
      




  puVal = digitalRead(puReadPin);
  // Get value of Pull Down Switch


  Serial.print(" | ");
  Serial.print("pull up = 1");   
  Serial.print(0);  

  
if (puVal > 0); {
  
  
  // Do something with the switches
digitalWrite(led5Pin, HIGH);
digitalWrite(led6Pin, HIGH);
digitalWrite(led7Pin, HIGH);
digitalWrite(led8Pin, HIGH);
digitalWrite(led9Pin, HIGH);
digitalWrite(led10Pin, HIGH);
digitalWrite(led11Pin, HIGH);
digitalWrite(led12Pin, HIGH);
digitalWrite(led13Pin, HIGH);
} else {
  
  digitalWrite(led5Pin, LOW);
digitalWrite(led6Pin, LOW);
digitalWrite(led7Pin , LOW);
digitalWrite(led8Pin, LOW);
digitalWrite(led9Pin, LOW);
digitalWrite(led10Pin, LOW);
digitalWrite(led11Pin, LOW);
digitalWrite(led12Pin, LOW);
digitalWrite(led13Pin, LOW);
}

it keeps saying error: else without a previous if.

help?

 if (putval > 0); {

Remove the semicolon ';'

if (puVal > 0); {

Too many semicolons on that line :)

-- The Quick Shield: breakout all 28 pins to quick-connect terminals

okay thanks. Now it says; 'expected } at end of input'. But I believe we have one. Any suggestions?

  puVal = digitalRead(puReadPin);
  // Get value of Pull Down Switch


  Serial.print(" | ");
  Serial.print("pull up = 1");   
  Serial.print(0);  

  
if (puVal > 0) {
  
  
  // Do something with the switches
digitalWrite(led5Pin, HIGH);
digitalWrite(led6Pin, HIGH);
digitalWrite(led7Pin, HIGH);
digitalWrite(led8Pin, HIGH);
digitalWrite(led9Pin, HIGH);
digitalWrite(led10Pin, HIGH);
digitalWrite(led11Pin, HIGH);
digitalWrite(led12Pin, HIGH);
digitalWrite(led13Pin, HIGH);
} else {
  
digitalWrite(led5Pin, LOW);
digitalWrite(led6Pin, LOW);
digitalWrite(led7Pin , LOW);
digitalWrite(led8Pin, LOW);
digitalWrite(led9Pin, LOW);
digitalWrite(led10Pin, LOW);
digitalWrite(led11Pin, LOW);
digitalWrite(led12Pin, LOW);
digitalWrite(led13Pin, LOW);

}

The thing about C/C++ is that an error at line 1 can show up as an error at line 100. You have to post the whole code for us to see where the error might be.

-- The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, light sensor, potentiometers, pushbuttons

sorry

//    Pull-Up Switch
int puReadPin = 3;     // a DIGITAL pin to read Pull Up switch
int puOutPin = 4;      // a DIGITAL pin to light LED indicator
int puVal = 0;

int led5Pin = 5;
int led6Pin = 6;
int led7Pin = 7;
int led8Pin = 8;
int led9Pin = 9;
int led10Pin = 10;
int led11Pin = 11;
int led12Pin = 12;
int led13Pin = 13;


// Setup
void setup() {
 Serial.begin(9600);   // Start up the serial communication

 pinMode(puReadPin, OUTPUT);
 pinMode(puOutPin, OUTPUT);
}

// Loop
void loop() 

{
      




  puVal = digitalRead(puReadPin);
  // Get value of Pull Down Switch


  Serial.print(" | ");
  Serial.print("pull up = 1");   
  Serial.print(0);  

  
if (puVal > 0) {
  
  
  // Do something with the switches
digitalWrite(led5Pin, HIGH);
digitalWrite(led6Pin, HIGH);
digitalWrite(led7Pin, HIGH);
digitalWrite(led8Pin, HIGH);
digitalWrite(led9Pin, HIGH);
digitalWrite(led10Pin, HIGH);
digitalWrite(led11Pin, HIGH);
digitalWrite(led12Pin, HIGH);
digitalWrite(led13Pin, HIGH);
} else {
  
digitalWrite(led5Pin, LOW);
digitalWrite(led6Pin, LOW);
digitalWrite(led7Pin , LOW);
digitalWrite(led8Pin, LOW);
digitalWrite(led9Pin, LOW);
digitalWrite(led10Pin, LOW);
digitalWrite(led11Pin, LOW);
digitalWrite(led12Pin, LOW);
digitalWrite(led13Pin, LOW);
}

You are indeed missing a } at the end. The last one you have matches with the if statement but there is no matching } for the one right below "void loop()".

-- The Quick Shield: breakout all 28 pins to quick-connect terminals

Oops, thank you. We've added the }, yet we still receive a 'problem uploading to board' message. Any suggestions? Also we are unclear of what the puOutPin if for? THanks for your help.

//    Pull-Up Switch
int puReadPin = 3;     // a DIGITAL pin to read Pull Up switch
int puOutPin = 4;      // a DIGITAL pin to light LED indicator
int puVal = 0;

int led5Pin = 5;
int led6Pin = 6;
int led7Pin = 7;
int led8Pin = 8;
int led9Pin = 9;
int led10Pin = 10;
int led11Pin = 11;
int led12Pin = 12;
int led13Pin = 13;


// Setup
void setup() {
 Serial.begin(9600);   // Start up the serial communication

 pinMode(puReadPin, OUTPUT);
 pinMode(puOutPin, OUTPUT);
}

// Loop
void loop() 

{
      




  puVal = digitalRead(puReadPin);
  // Get value of Pull Down Switch


  Serial.print(" | ");
  Serial.print("pull up = 1");   
  Serial.print(0);  

  
if (puVal > 0) {
  
  
  // Do something with the switches
digitalWrite(led5Pin, HIGH);
digitalWrite(led6Pin, HIGH);
digitalWrite(led7Pin, HIGH);
digitalWrite(led8Pin, HIGH);
digitalWrite(led9Pin, HIGH);
digitalWrite(led10Pin, HIGH);
digitalWrite(led11Pin, HIGH);
digitalWrite(led12Pin, HIGH);
digitalWrite(led13Pin, HIGH);
} else {
  
digitalWrite(led5Pin, LOW);
digitalWrite(led6Pin, LOW);
digitalWrite(led7Pin , LOW);
digitalWrite(led8Pin, LOW);
digitalWrite(led9Pin, LOW);
digitalWrite(led10Pin, LOW);
digitalWrite(led11Pin, LOW);
digitalWrite(led12Pin, LOW);
digitalWrite(led13Pin, LOW);
  
}   

}

int puOutPin = 4; // a DIGITAL pin to light LED indicator

That's all we know about that pin. Apparently you're supposed to hook an LED up to it? (make sure you have a series resistor too).

As for uploading to your board....which board? how are you trying to do it? what is the exact error message? who is "we"?

-- The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, light sensor, potentiometers, pushbuttons

sorry to be unclear. Our error message says simply; 'problem uploading to board'. We are hooking Led lights to a bread board in hopes to get our pull up resistor switch to turn them on / off. As of now we (My lab partner and I) don't have anything hooked up to puOutPin, what should be in this pin?

Hi jp7962

1) You should change to INPUT in this line:

 pinMode(puReadPin, OUTPUT);

and activate the pull-up:

A pin may also be configured as an INPUT with pinMode, and subsequently made HIGH with digitalWrite, this will set the internal 20K pullup resistors, which will steer the input pin to a HIGH reading unless it is pulled LOW by external circuitry.

This way a button connected to the pin (no. 3 on your board) will make the pin go LOW when it is pressed.

2) You sould declare all you Led pins as output in void setup().

3) The serial port will be spammed with this message:

Serial.print(" | ");
  Serial.print("pull up = 1");
  Serial.print(0);

every times the program loops. You probaly want the message to be send once the button is pressed.

4)

if (puVal > 0) {

This will make all the ledpins to be on when the button is un-pressed and off when the button is pressed - is that what you want?

Keep up the good work.

-Fletcher

Since the code posted in #7 compiles and uploads OK on my Duemilanove and he says

problem uploading to board

dare I suggest this is no longer to do with the code ?

Do the sketches in the examples upload ?