Arduino UNO sketch & push button

Talk about Arduino board, sheilds. Sharing Arduino projects, program, problems, solutions, suggestions..... many more, all are welcome.

Arduino UNO sketch & push button

Postby Lovetronic » Sun Mar 09, 2014 5:05 pm

CODE: SELECT_ALL_CODE
int Auto=2;
int Manu=3;

int val1;
int val2;
int stateA;
int stateB;

void setup()
{
  pinMode(Auto, INPUT);
  pinMode(Manu, INPUT);
  Serial.begin(9600);
}

void loop()
{
  val1=digitalRead(Auto);
  val2=digitalRead(Manu);

  if (val1!=stateA)
  {
    if (val1==HIGH)
    {

      Serial.println("Auto");
      delay(500);
    }
    else
    {
      Serial.println("button auto released");
      if(val2==stateB)
      {
        delay(500);
        for(int i=0; i<10; i++){

          Serial.println(i);
          Serial.println("man:");
          Serial.println( val2);
          delay(500);
          while(val2==HIGH)

          {

            Serial.println("MAN");
            delay(500);

          }
        }
        Serial.println("button man released");
      }
    }
  }

  stateA=val1;
  stateB=val2;
}


I found that the button state for pin 3 keep its original state when push. My intention here is after pin 2 button is push, it keeps waiting until the pin 3 button is being pushed.
(pull up resistor)
Lovetronic
Greenhorn
 
Posts: 2
Joined: Sat Mar 08, 2014 11:22 pm

Re: Arduino UNO sketch & push button

Postby yonghui » Mon Mar 10, 2014 10:09 am

what is the value of stateA and stateB ? u did not initialize it??

there are so many delay(500) in the loop? what is it for? the delay will cause slow response to the push button
thanks&regards,
yh
yonghui
Moderator
 
Posts: 732
Joined: Mon Sep 28, 2009 3:27 pm

Re: Arduino UNO sketch & push button

Postby Blue Moon » Fri Jan 09, 2015 6:14 pm

Right now i'm working with arduino mega 2560 and SKGPS-53 for my project. I have file in .tiff format(map) that i need to extract it in my arduino and compare with the true coordinate which is I get from my SKGPS-53. anyone have the idea how he coding for this?
Blue Moon
Fledgling
 
Posts: 1
Joined: Fri Jan 09, 2015 6:01 pm


Return to Arduino Based

Who is online

Users browsing this forum: No registered users and 16 guests