program wont work??

Please can anyone help me, and tell why this program will not work, it downloads fine.

const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
unsigned long time;
unsigned long current_time;
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
int set_pressed = 0;

void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
digitalWrite(ledPin, LOW);

}

void loop(){

// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH && set_pressed == LOW )
set_pressed == HIGH;
time = millis();

{
current_time = millis();
if ((current_time - time) >= 1000 && set_pressed == HIGH)
digitalWrite(ledPin,HIGH);

} // turn it on when its been running for a second

{
current_time = millis();
if ((current_time - time) >= 4000 && set_pressed == HIGH)
set_pressed == LOW;
digitalWrite(ledPin,LOW);

} // turn it off when its been running for 4seconds

}

What should it do ?
What does it do ?

set_pressed == HIGH;oops

  if (buttonState == HIGH && set_pressed == LOW )
    set_pressed == HIGH;
  time = millis();

I note that you set time to the current value of millis() on each iteration of loop(). I assume that is a mistake

Hi,
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom.. :slight_smile: