Page 1 of 1

Arduino UNO sketch & push button

PostPosted: Sun Mar 09, 2014 5:05 pm
by Lovetronic
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)

Re: Arduino UNO sketch & push button

PostPosted: Mon Mar 10, 2014 10:09 am
by yonghui
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

Re: Arduino UNO sketch & push button

PostPosted: Fri Jan 09, 2015 6:14 pm
by Blue Moon
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?