programming question on loop

how can i make this code work by the push of the button only from 90 degrees button/contact is press and when the button is pressed the degrees go back to 0.

void loop()
{
  buttonState = digitalRead(buttonPin);   // read the state of the pushbutton value:
  
  if (buttonState == HIGH);               // check if the pushbutton is pressed.
                                          // if it is, the buttonState is HIGH
  
  myservo.write(pos);                     // tell servo to go to position in variable 'pos'
  
  pos = 90;                               // goes from 90 degrees to 0 degrees
  
  delay(2500);                            // delay 2.5s for servo to move
  
  if (buttonState == LOW);                // check if the pushbutton is depressed.
                                          // if it is, the buttonState is LOW
                                          
  digitalWrite(ledPin, buttonState);      // turn LED on when it gets there

  myservo.write(pos);                     // tell servo to go to position in variable 'pos'  

  pos = 0;                                // goes from 0 degrees to 90 degrees
  
  delay(2500);                            // delay 2.5s for servo to move
                                          // turn LED off
}

the good thing about deja vu is you've seen it before!

hahaha thanks AWOL; appreciate a good sarcasim once in a while. lol

yeah i know is that i have so much in my head that i can think of figuring out the second button.

how can i make this code work by the push of the button only from 90 degrees button/contact is press and when the button is pressed the degrees go back to 0.

forgot to squeeze in there the part where the second button is pressed to bring the degrees back to "0"

hmm I'm not AWOL I wonder if he is more upset or me

you win no friends by posting the same question multiple times

maybe you should read the replies a little more carefully

You make even fewer friends by not REMOVING THE SEMICOLONS.

PaulS has told you; I've told you - why don't you do it?

AWOL, PaulS;

the fun part is that IF once again IF i remove the simicolons the prograqm wont work,

i mean there is a reason why im asking for the help. here is my last sketch and it works fine for the ecception of that know i need the program to work with a second button as the second trigger "meaning" the second button is the one that send the signal to the servo to go to the next degrees.

im not ignoring you post im trying them as we post and some of them compile and must of them dont. so bare with me.

the good thing about deja vu is you've seen it before!

hmm I'm not AWOL I wonder if he is more upset or me

you win no friends by posting the same question multiple times

maybe you should read the replies a little more carefull!

sorry about that.

people would be a lot more inclined to help if you a) read the posts carefully b) did what people suggested c) posted the code that you have changed

the semicolons MUST NOT FFS be there please go over each of the posts and read it until you understand every word people are trying very hard to help you you seem to read one word in three then code something else

signed exasperated of Leighton Buzzard

this is the original that im currently using and the servo works when i press the button and it goes to “0” then to “90” degrees and when i let go it will stop. what i would like for it to do is go up/90 degrees one button and goes down/0 degrees when i push the second button which is not on the code below.

/*
  Button_Sweep
 
 Turns on and off a light emitting diode(LED) connected to digital  
 pin 13, when pressing a pushbutton attached to pin 2. 
 
 
 The circuit:
 * LED attached from pin 13 to ground 
 * pushbutton attached to pin 2 from +5V
 * 10K resistor attached to pin 2 from ground
 
 * Note: on most Arduinos there is already an LED on the board
 attached to pin 13.
*/
  #include <Servo.h>

  Servo myservo;                          // create servo object to control a servo 
                                          // a maximum of eight servo objects can be created

                                          // constants won't change. They're used here to 
                                          // set pin numbers:

  int ledPin =  10;                       // the number of the LED pin
  int buttonPin = 2;                      // the number of the pushbutton pin
  int pos = 0;                            // variable to store the servo position

  int buttonState = 0;                    // variable for reading the pushbutton status

void setup() 
{
  pinMode(ledPin, OUTPUT);                // initialize the LED pin as an output:   
  pinMode(buttonPin, INPUT);              // initialize the pushbutton pin as an input:
  myservo.attach(9);                      // attaches the servo on pin 9 to the servo object
}

void loop()
{
  buttonState = digitalRead(buttonPin);   // read the state of the pushbutton value:
  
  if (buttonState == HIGH);               // check if the pushbutton is pressed.
                                          // if it is, the buttonState is HIGH
  
  myservo.write(pos);                     // tell servo to go to position in variable 'pos'
  
  pos = 90;                               // goes from 90 degrees to 0 degrees
  
  delay(5500);                            // delay 5.5s for servo to move
  
  if (buttonState == LOW);                // check if the pushbutton is depressed.
                                          // if it is, the buttonState is LOW
                                          
  digitalWrite(ledPin, buttonState);      // turn LED on when it gets there

  myservo.write(pos);                     // tell servo to go to position in variable 'pos'  
 
  pos = 0;                                // goes from 0 degrees to 90 degrees
  
  delay(500);                            // delay 5/100th of a second for servo to move
                                          // turn LED off
}

people would be a lot more inclined to help if you
a) read the posts carefully
b) did what people suggested
c) posted the code that you have changed

if (buttonState == HIGH);

the semicolons MUST NOT FFS be there

DOES NOTHING BECAUSE THAT’S WHAT YOU TOLD IT TO DO

please go over each of the posts and read it until you understand every word
people are trying very hard to help you
you seem to read one word in three then code something else

signed
exasperated of Leighton Buzzard

the semicolons as you guys are requesting are giving troubleshooting when i remove them thats why i cont to post the codes the way they are.

sorry for any of your inconveniences......

I will try one more time
REMOVE THE GODDAM semicolons

then look at your code

the structure of an IF statement is

IF ( <> )
{
do this
}

when you write IF (<>);
you are saying test the condition then do nothing

the IF stops when it hits the semicolon

so remove the semi colon and put all the things you want to do inside {…}

it will compile
it will work
ignoring us won’t work!

(well it will eventually because we will ignore you!)

ok ppl

<<<>>>

hoo blooming ray

now did you read the rest of the post?

the fun part is that IF once again IF i remove the simicolons the prograqm wont work

I hate to be picky*, but that sentence speaks volumes; programming is about precision and attention to detail.
If you’re not willing to embrace those concepts, give up now - it will save us all a great deal of time.

*I lied - I love to be picky; it pays the bills

hee hee!

It isn't funny. :0

I propose that Arduino C (or all C) be changed from tomorrow onwards to not require semicolons. In fact, I’d go so far as to say that Arduino C should be changed to Arduino Ruby. Then I’d be happy.

[quote author=Ian Tindale link=topic=65750.msg481942#msg481942 date=1309939824] I propose that Arduino C (or all C) be changed from tomorrow onwards to not require semicolons. In fact, I’d go so far as to say that Arduino C should be changed to Arduino Ruby. Then I’d be happy. [/quote] Excellent idea. Now all you have to do is write a compiler that generates AVR machine code from Ruby. Then lots of people will be happy.

While you're at it, could you throw in a Python compiler for me? Ta.