299Views3Replies

Author Options:

Arduino crash sensor single pulse? Answered

I'm trying to get a crash sensor to output a single 800ms pulse when depressed and held down until it is released and repeat when depressed again, I have had this working before but cant seem to achieve it again. It either continually loops while depressed or wont output at all until it's released. Any help is greatly appreciated :)

Tags:Arduino

3 Replies

user
iceng (author)2015-05-27
user
KentB2 (author)2015-05-27

I'm not sure whats going on it's not reacting how i would expect it to.

Why do i have a delay before and after switch input?

Here is the basic code I'm struggling with :/

int relayPin = 13;
int inputPin = 3;
void setup() {
pinMode(relayPin, OUTPUT);
pinMode(inputPin, INPUT);
}
void loop(){
int val = digitalRead(inputPin);
if (val == HIGH)

digitalWrite(relayPin, LOW);
delay(800);
digitalWrite(relayPin, HIGH);

}

Select as Best AnswerUndo Best Answer

user
mpilchfamily (author)2015-05-27

Can't help if you don't post your code.

Select as Best AnswerUndo Best Answer