Hi...
I am designing a eye blink alarm by IR sensor. I want when my output of IR Sensor is Blinking with blinking of my eye no output should come, but if i am closing my eye for one second or more output should come.
can any one help?
Hi...
I am designing a eye blink alarm by IR sensor. I want when my output of IR Sensor is Blinking with blinking of my eye no output should come, but if i am closing my eye for one second or more output should come.
can any one help?
Please post your full sketch. If possible you should always post code directly in the forum thread as text using code tags (</> button on the toolbar). This will make it easy for anyone to look at it, which will increase the likelihood of you getting help. If the sketch is longer than the forum will allow then it's ok to add it as an attachment.
Have you managed to get it successfully detecting your eye state via the sensor yet?
void setup() {
pinMode(A0, INPUT);
pinMode(A1, OUTPUT);
}
void loop()
{
while(digitalRead(A0)==HIGH)
delay(1000);
if (digitalRead(A0)==HIGH);{
switch (digitalWrite(A1, HIGH);
}
else
{
digitalWrite(A1, LOW);
}}
I guess you didn't bother to read my reply very carefully.
Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. If your browser doesn't show the posting toolbar then you can just manually add the code tags:
[code]``[color=blue]// your code is here[/color]``[/code]
Using code tags and other important information is explained in the How to use this forum post. Please read it.
Please always do a Tools > Auto Format on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read. If you're using the Arduino Web Editor you will not have access to this useful tool. I recommend you to use the standard IDE instead.
Please remove unnecessary blank lines from your code before posting to the forum. One or two to separate code into logical sections is fine but large spaces for no reason or random blank lines just make for more scrolling when we're trying to read your code.
I'll ask again:
pert:
Have you managed to get it successfully detecting your eye state via the sensor yet?
Tanmay1990:
while(digitalRead(A0)==HIGH)
delay(1000);
if (digitalRead(A0)==HIGH);{
Please take the time to read the reference page for while():
Do you see the problem? The while() loop will continue as long as A0 is HIGH. It will only exit the while() loop when A0 goes low and then you immediately check if it's HIGH, which there is only a microscopic chance it would ever be.
Tanmay1990:
if (digitalRead(A0)==HIGH);{[/code]
Please take the time to read the reference page for if():
https://www.arduino.cc/en/Reference/If
Do you see the problem with that line of code (hint: semicolon)?
Tanmay1990:
switch (digitalWrite(A1, HIGH);
Please take the time to read the reference page for switch():