dan ternyata ane masih emerasa gampang dengan arduino … so ini koding acak2an baru2 coba aja …
jangan di ketawain ya .. ini anak teka baru belajar … kolding2an … heheh
mohon pencerahannya … berbagi itu indah loh .. 😀
/*
The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* LCD VSS pin to ground
* LCD VCC pin to 5V
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
*/
// include the library code:
#include// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int buttonPin = 0; // the number of the pushbutton pin
const int buttonPin1 = 1; // the number of the pushbutton pin
const int ledPin = 7;
const int ledPin1 = 8; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
int buttonState1 = 0;
void setup() {
// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);
lcd.print(“LED1 : STATUS “);// Print a message to the LCD.
lcd.setCursor(0, 1);
lcd.print(“LED2 : STATUS”);// Print a message to the LCD.
lcd.display();
delay(5000);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
pinMode(ledPin1, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
pinMode(buttonPin1, INPUT);
}
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, LOW);
lcd.begin(16, 2);
lcd.print(“LED1 : OFF”);// Print a message to the LCD.
} else {
// turn LED off:
digitalWrite(ledPin, HIGH);
lcd.begin(16, 2);
lcd.print(“LED1 : ON”);// Print a message to the LCD.
}
buttonState1 = digitalRead(buttonPin1);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState1 == HIGH) {
// turn LED on:
digitalWrite(ledPin1, LOW);
lcd.setCursor(0, 1);
lcd.print(“LED2 : OFF”);// Print a message to the LCD.
} else {
// turn LED off:
digitalWrite(ledPin1, HIGH);
lcd.setCursor(0, 1);
lcd.print(“LED2 : ON”);// Print a message to the LCD.
}
lcd.display();
delay(1000);}