halo..
how to code when someone give some pressure to pressure sensor, the LED will turn ON and if someone do not give any pressure to pressure sensor, LED will turn off without any delay? ![]()
halo..
how to code when someone give some pressure to pressure sensor, the LED will turn ON and if someone do not give any pressure to pressure sensor, LED will turn off without any delay? ![]()
Well first you need to post a link to the sensor so we can see how it works.
Then you need to post a schematic of the way you have it hooked up so far, along with the code you have tried.
That said:
If your pressure sensor is just a simple on/off switch, then have a look here.
If your sensor is analog, ie a voltage that varies with the pressure, then it's more like this. You will need to decide at what point the led goes off and on and modify the code with an "if" like in the first example, but instead of high and low for the switch, use your threshold value.
This is what I have but it's not working
float val = 0;
void setup()
{
pinMode(12, INPUT); //sensor
pinMode(13, OUTPUT); //LED
Serial.begin(9600); //so I can print to the serial monitor the value
}
void loop()
{
val = digitalRead(12);
if (val > .01)
{
digitalWrite(13,HIGH);
delay(1000);
Serial.print(val);
}
else
{
digitalWrite(13,LOW);
delay(1000);
Serial.print(val);
}
val=0.0;
}
If you give us more information and answer the questions, then you might get better answers.
The code you posted is partially for a sensor and partially for a switch.
Post a link to the sensor you have.
Leo..