Hi guys i have built an two pir sensor arduino program that will turn the leds.Now i want to connect the LCD AS WEL..
I WANT TO MAKE 4 BITS ARDUINO LCD PROGRAM.I have made this program as show below.When the Button pin 1 will activate it will turn on led 1 and lcd will show "motion detected" for 2 seconds .And when button pin 2 will activate it will show same for 2 seconds.
I am using 16X2 pin Lcd.
I could not how to make the void loop of this program.Any help guys or any basic program if u can make.i will realy appreciate that.thanks
const int buttonPin1 = 2; // the number of the pushbutton pin 2
const int buttonPin2 = 3; // the number of the pushbutton pin 3
const int ledPin1 = 13; // the number of the LED pin
const int ledPin2 = 12;
// variables will change:
int buttonState1= 0; // variable for reading the pushbutton status
int buttonState2= 0;
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin1, INPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin2, INPUT);
}
void loop(){
// read the state of the pushbutton value:
buttonState1 = digitalRead(buttonPin1);
// read the state of the pushbutton value:
buttonState2= digitalRead(buttonPin2);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState1 == HIGH) {
// turn LED on:
digitalWrite(ledPin1, HIGH);
delay(1000);
digitalWrite(ledPin2, LOW);
delay(1000);
if
(buttonState2 == HIGH) {
// turn LED on:
digitalWrite(ledPin2, HIGH);
delay(1000);
digitalWrite(ledPin1, LOW);
delay(1000);
}
}
}