if (750 < value < 900)
{
digitalWrite(6, HIGH);
delay(5);
digitalWrite(6, LOW);
}
i want to work this code when i push the button
if ((buttonState == HIGH) && (750 < value < 900))
{
digitalWrite(6, HIGH);
delay(5);
digitalWrite(6, LOW);
}
but it dosn't work how can i solve this
at excel i do like this =IF(B3=1;A32,05;IF(B3=2;A3 1,3;"")) is this work same as arduino
thank you
if ((buttonstate == HIGH) && ((750 < value) && (value < 900)))
DrAzzy
August 26, 2016, 6:59pm
3
Almost.
This is wrong though:
(750 < value < 900)
that will test if 750 is less than value - if it is, the (750 < value) will be 1 else 0. And either way, 0 or 1 are both lower than 900, so that will always return true.
(750 < value) && (value < 900)
You may have to deal with debouncing the switch (there's lots of material on this around the web), depending on your use case.
thank you for your help
it worked !
this my final codes
int sensorPini = A0;
int olculenIsikDegeri = 0;
int butonPini = 4;
int butonDurumu = 0;
void setup() {
pinMode(4, INPUT);
//Serial.begin(9600);
pinMode(13, OUTPUT);
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
}
void loop() {
butonDurumu = digitalRead(butonPini);
olculenIsikDegeri = analogRead(sensorPini);
if (butonDurumu == LOW)
{
digitalWrite(3, HIGH);
digitalWrite(13, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
delay(1000);
digitalWrite(3, LOW);
digitalWrite(13, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
delay(1000);
}
if ((butonDurumu == HIGH) && ((355 < olculenIsikDegeri) && (olculenIsikDegeri < 500)))
{
digitalWrite(6, HIGH);
delay(1);
digitalWrite(6, LOW);
}
if ((butonDurumu == HIGH) && ((210 < olculenIsikDegeri) && (olculenIsikDegeri < 355)))
{
digitalWrite(5, HIGH);
delay(1);
digitalWrite(5, LOW);
}
if ((butonDurumu == HIGH) && ((110 < olculenIsikDegeri) && (olculenIsikDegeri < 210)))
{
digitalWrite(3, HIGH);
delay(1);
digitalWrite(3, LOW);
}
//if (butonDurumu == HIGH)
{
//Serial.println(olculenIsikDegeri);
}
}