pulling hair out, cant find solution

I am trying to add a momentary delay into this code and is keep erroring out on me. I want this html button to switch a relay on(1) for less than a second and go back to (0) waiting for the next time the button is pressed. I'm a absolute beginner at this and the code i have came out of a book. i just tried to modify it for my use and now i'm stuck.

I need it on i = 6 as 6 will be going to my relay.

// table with buttons from 2 through 9
// 2 AND 3 are inputs, the other buttons are outputs
client.println(F("<table border='1'>"));
// show the input pins
for (int i = 2; i < 4; i++) { // pins 2,and 3 are inputs
pinMode(i, INPUT);
digitalWrite(i,LOW); // turn on pull-ups
client.print(F("<tr><td>Door Open"));
client.print(i);
//client.print(F(" </td><td>"));
//client.print(F("&nbsp </td><td>"));
//client.print(F(" </td><td>"));
client.print(F("&nbsp </td><td>"));

if(digitalRead(i) == HIGH)
//client.print("HIGH");
printP(led_on);
else
//client.print("LOW");
printP(led_off);
client.println("</td></tr>");
}
// show output pin 6
// note pins 10-13 are used by the ethernet shield
for (int i = 6; i < 7; i++) {
client.print(F("<tr><td>digital output "));
client.print(i);
client.print(F(" </td><td>"));
htmlButton( "Open", "pinD", i, "1");
delay (250);
else
client.print(F(" </td><td>"));
client.print(F(" </td><td>"));
htmlButton("Close", "pinD", i, "0");
client.print(F(" </td><td>"));
if(digitalRead(i) == LOW)
//client.print("Low");
printP(led_off);
else
//client.print("high");
printP(led_on);
client.println(F("</td></tr>"));
}
client.println(F("</table>"));
}

I hope this is enough code, I can add more if needed.

Thanks

You should be posting the full code, preferably one that compiles, and if it doesn't compile, you need to show the errors.

I see an else statement with no preceding if. Proper format would also be very helpful too. :wink:

for (int i = 6; i < 7; i++) {
client.print(F("digital output "));
client.print(i);
client.print(F(" "));
htmlButton( "Open", "pinD", i, "1");
delay (250);
else

digitalWrite(i,LOW); // turn on pull-ups

I don't think you can do that. Isn't the only option for internal resistors on inputs is having them used as pullups by using digitalWrite(x,HIGH) ?

  • Scotty

This code actually came out of the arduino cookbook 2nd edition and that pull-up code is verbatim.

I have now figured out what my problem was. I kept placing a delay after the htmlButton line for pin 6 to activate and that would not work. As soon as I wrote just a basic digitalWrite for pine 6 to go low, delay, then high command, it started working.
I'm a total noob at this, and still learning. There aren't any school around here to teach this, or I would be there.
As for the "else", ya I forgot to remove that before putting up the code.

Thank yall