please sir
i need help in my IR sensor program
this is my code and i am facing some problem
please give me some solution.
#include <LiquidCrystal.h>
LiquidCrystal lcd(2,3,5,4,6,11);
void setup() {
pinMode(23,input);
lcd.begin(16,2);
}
void loop() {
int i;
digital read(23);
if{
digital read(i==1);
lcd.print("PURE");
}
else{
digital read(i==0);
lcd.print("NOT PURE");
}
}
i am facing some problem
If you tell us what problems then we can give you some help but expecting us to guess you problem and then fix it is a bit much.
Please read this:-
How to use this forum it will tell you how to ask a question and how to post code.
if{
Is not the way to use an if statement see:- if - Arduino Reference
system
3
I think you mean first to read the pin into the variable i:
i = digitalRead(23);
Then your if will just be
if (i==1)
And the { goes after the if line which should have no ;
INPUT is upper case and digital read is one word digitalRead
So you full code should probably be: (compiled but untested)
#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 5, 4, 6, 11);
void setup()
{
pinMode(23, INPUT);
lcd.begin(16, 2);
}
void loop()
{
int i;
i = digitalRead(23);
if (i == 1)
{
lcd.print("PURE");
}
else
{
lcd.print("NOT PURE");
}
}