Hi guys how can i put a timer in my capacitive sensor? When the sensor detects or reach the value of my trigger. It will take 5 minutes to activate again. Thank you in advance
is your sensor programmable? do you want a hardware or a software solution?
you can get you Arduino to do this if you want a software solution
Yes. My sensor is programmable im using the capsense library in arduino. And i want a software solution. Thank you
Resonance1214:
Yes. My sensor is programmable im using the capsense library in arduino.
link to your sensor? is it the sensor which is programmable or is it the Arduino that can talk to your sensor and decide what to do?
implementing a delay after detecting a trigger is not too complicated.
wait for the trigger
- when it happens, record the time*
- compare this to last time it was triggered*
- if too soon don't do anything else take action*
Its the arduino that is commanding my sensor Here is my Arduino sketch
#include <CapacitiveSensor.h>
CapacitiveSensor cs_4_2 = CapacitiveSensor(7, 6);
void setup()
{
cs_4_2.set_CS_AutocaL_Millis(3000);
Serial.begin(9600);
}
void loop()
{
long start = millis();
long total1 = cs_4_2.capacitiveSensor(30);
if (total1 > 430) {
digitalWrite(11, HIGH);
} else {
digitalWrite(11, LOW);
}
Serial.print(millis() - start);
Serial.print("\t");
Serial.println(total1);
Serial.print("\t");
delay(100);
Please correct your post above and add code tags around your code:
[code]`` [color=blue]// your code is here[/color] ``[/code]
.
It should look like this:// your code is here
(Also press ctrl-T (PC) or cmd-T (Mac) in the IDE before copying to indent your code properly)
seems it won't do what you want, right?
try to write in plain english and with great details what needs to happen. Then you can go to code
Deepest apologize about that im new here and arduino. Okay i have a sensor and if the value exceeds 430 it will trigger a relay and when it triggers it will have a delay before it will activate again lets say 3 mins so if you touch the sensor again nothing will happen unless 3 minutes have passed
Thx - I wanted to drive you to express the needs in a way closer to how a computer works to help you build the structure of your code.
something like
initialize environment
repeat forever
- collect sensor value
- if sensor value greater than 430
- if relay not been triggered in the past 3 minutes
- activate relay
- remember activation time
...
Starting with a clear view of what your code needs to do will help you get there. there will be question to answer like when does the relay turns off? etc
I want to have like a timer that if total1>420 pin 11 will be high for 5 seconds and after the triggering it will take 5 minutes for the sensor to work again. Thanks
We don't write code for the others here... you need to get there and we help along the way...
To do so I suggest you define what the algorithm needs to look like, so decompose very precisely the steps you need and then program that....
there are basic ways of doing this if your code does not need to do other things while waiting
loop()
wait for condition
trigger
wait for 5 minutes