touch sensor

in the touch sensor that gives 1 or 0 i want to hold the value of the sensor to make multiple things i have two touch sensors for example if i touch the first one it will do something and if i touch the first one then after that the second one it will do another thing how i can do that ? (i dont want to touch both sensors , touch the first one then the second one ) thanks

When a sensor is touched, record which sensor was touched, and check what the last sensor touched was.

You'll probably also need to time it, so it will reset after a few seconds (see blink without delay and the hundreds of threads on using millis for timing), so touching sensor 2, then going off to the pub for a few hours, and then returning and touching sensor 1, won't count as touching sensor 2 then 1 within a minute or something. Unless of course that's what you want.

and how can i hold the value ?
i searched for that but can’t find how

i mean i want to touch the first sensor then wait few seconds or maybe milliseconds for touching the second sensor to do something but if you touch the first one only or the second one only it will do something else for touching every one alone

and how can i hold the value ?

Do you know how to set the value of a variable ?

I also have a problem with that one

the_beginner_programmer: I also have a problem with that one

Do you mean that you do not know how to do

sensorValue = digitalRead(sensorPin);

thabetwh: i mean i want to touch the first sensor then wait few seconds or maybe milliseconds for touching the second sensor to do something but if you touch the first one only or the second one only it will do something else for touching every one alone

So when you touch only one of them how long are you going to wait before you decide that the other one will not be touched too?

Steve

Record the touch, and record when it happened (use millis() for that).
If the second is touched within a certain time, do whatever you want to do.

Example:

if (sensor1Touched()) {
  touchTime = millis();
}
if (sensor2Touched() && millis() - touchTime < interval) {
  doStuff();
}