Please help me out

I have doubt in program regarding vehicle accident prevention...in the project I want to read my input and if the input is high for 5secs,output should appear..please let me know as soon as possible Thank you

Wow, just wow

  • No code
  • Poor title
  • Typical XY-problem

Should I go on? Please have a look at How to use this forum or at least try and Google before you post ;)

#include <accidentPrevention.h>
CarType magicCar;
float thatOne = random(0,pi);
float otherOne = random(e, 4);
void setup(){
pinMode (thatOne, INPUT_PULLRIGHT);
pinMode (otherOne, OUTPUT);
}

void loop(){
int readTehPin = digitalRead (otherOne);
if (readTehPin is high for 5secs){
output should appear};
}

pinMode (thatOne, INPUT_PULLRIGHT);

That is NOT going to work. The switch needs to be wired in the PULLLEFT configuration.

Hold-on - that is true only in the Northern Hemisphere and if you drive on the right side of the road otherwise it's indeed a PULLRIGHT; (coriolis force also needs to be reinforced)

I guess the OP forgot that small piece of critical information there... is the driving wheel on the left or right side of the car? Until we know i guess we can't help...

I am only familiar with PULL_UP resistors.

I suppose if you have wings it could work in both hemispheres..

is the driving wheel on the left or right side of the car? Until we know i guess we can't help...

So, my trike would use PULLCENTER wiring?

PaulS: So, my trike would use PULLCENTER wiring?

Obviously a trike would make use of tristate, so it wouldn't use any pulls :)

PaulS: So, my trike would use PULLCENTER wiring?

Works OK with my Unicycel :)

Deeshna: please let me know as soon as possible

When is the assignment due?

Thanks for the replies... actually my project title is vehicle accident prevention using eyeblink sensor... Where input to the arduino is IR sensor and output is LCD and buzzer...whenever the person closes eye,IR sensor gives logic1...so if the person sleeps for 5secs(input is high for 5secs),output to LCD and buzzer has to go high...

[quote author=Nick Gammon link=msg=2982696 date=1477958987] When is the assignment due? [/quote]

UNO that already

Interesting. I always thought the I in IR stood for Infrared, not Iball.

You are using an IR sensor to detect eyeblinks? Holy hot eyeballs, Batman.

But in answer to your question:

If the input is low, put “input is low” into variable, turn off output

Otherwise:

  1. if input was low, then if has just turned high. Put “input is high” into variable, put input time into variable
  2. Check when input became high by looking at high time variable. If more than 5 sec ago, then make output high.

Boardburner2: UNO that already

Yesterday?

@Deeshna - look, you are going to learn more if you make an attempt to solve this yourself. This isn't a code-writing service. Try to write some code that reads a sensor, and turns on an LED. Then work out how to see if the sensor has been on for 5 seconds. Post your code if you are having problems with it.

[quote author=Nick Gammon link=msg=2982848 date=1477979295] Yesterday? [/quote]

I actually found the "UNO that already" quite a smart and funny answer :)

The faster the OP posts his initial progress and code, the faster we'll help. But OP must realise we won't write his code and do his assignment for him.

To get started, read about ... millis() digitalRead() then once you have detected your sensor state, move on with the rest.

Okay...I got the output ..Thanks everyone..

OP, forum etiquette suggests you might post your solution - so that other newbies can learn from your experience.