i have 5 push button, and each push button can only be HIGH one at a time..
when push button 1 is HIGH,
the loop run 1 times only and pause until other push button is HIGH(push button 1 is now LOW).
what should i do?? i have no idea ..
i have 5 push button, and each push button can only be HIGH one at a time..
when push button 1 is HIGH,
the loop run 1 times only and pause until other push button is HIGH(push button 1 is now LOW).
what should i do?? i have no idea ..
ryled:
i have no idea ..
Neither have I because you have not posted your program
And please post your program using the code button </> so it looks like this
. See How to use the Forum
...R
i am new to the arduino world..
push button that i mentioned at the beginning of post = range
void loop(){
int x,y,z;
const int sensorMin=-200;
const int sensorMax=180 ;
adxl.readAccel(&x, &y, &z); //read the accelerometer values and store them in variables x,y,z
int sensorReading=x;
int range = map(sensorReading, sensorMin, sensorMax,0,12);
int xxx=map(range,0,12,20,0);
Serial.print(xxx);
Serial.print(" ");
Serial.println(range);
if(range<=0)
{
digitalWrite(inApin[0], HIGH);
digitalWrite(inBpin[0], LOW);
analogWrite(pwmpin[0], 255);
delay(100);
while(xxx>=20)
{
digitalWrite(inApin[0], LOW);
digitalWrite(inBpin[0], LOW);
analogWrite(pwmpin[0], 0);
delay(10);
}
}
else if(range>=12)
digitalWrite(inApin[0], LOW);
digitalWrite(inBpin[0], HIGH);
analogWrite(pwmpin[0], 255);
delay(100);
while(xxx<=0)
{
digitalWrite(inApin[0], LOW);
digitalWrite(inBpin[0], LOW);
analogWrite(pwmpin[0], 0);
delay(10);
}
delay(1);
}
Please post the complete program. Problems are usually in the other part.
...R
It may also help to post the program that deals with the push buttons you asked about in your first post, not a program that deals with an accelerometer. There is no reference whatsoever to reading a push button in this piece of code.
If, as you say, the push button = "range" (why?) then your problem may be that your if statements are comparing the push button pin number and not a value read from the pin...at least that seems to be a very common error. Where is the rest of the code so we can check?
Steve