// C++ code
//
/*
Button
Turns on and off a light emitting diode(LED)
connected to digital pin 13, when pressing a
pushbutton attached to pin 2.
The circuit:
* LED attached from pin 13 to ground
* pushbutton attached to pin 2 from +5V
* 10K resistor attached to pin 2 from ground
* Note: on most Arduinos there is already an LED
on the board attached to pin 13.
created 2005 by DojoDave <http://www.0j0.org>
modified 30 Aug 2011 by Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/Button
*/
int buttonState = 0;
#include <LiquidCrystal_I2C.h> /*include LCD I2C Library*/
LiquidCrystal_I2C lcd(0x27,16,2); /*I2C scanned address defined + I2C screen size*/
void setup(){
pinMode(5, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(2, INPUT);
pinMode(4, OUTPUT);
lcd.init(); /*LCD display initialized*/
lcd.clear(); /*Clear LCD Display*/
lcd.backlight(); /*Turn ON LCD Backlight*/
lcd.setCursor(2,0); /*Set cursor to Row 1*/
lcd.print("Smart Tester"); /*print text on LCD*/
lcd.setCursor(1,1); /*set cursor on row 2*/
lcd.print("BY Diki Pradana"); /*print message on LCD*/
delay(1000);
}
void loop()
{
lcd.init(); /*LCD display initialized*/
lcd.clear(); /*Clear LCD Display*/
lcd.backlight(); /*Turn ON LCD Backlight*/
lcd.setCursor(14,0); /*Set cursor to Row 1*/
lcd.print("OK"); /*print text on LCD*/
lcd.setCursor(14,1); /*set cursor on row 2*/
lcd.print("NG");
if(digitalRead(5) == LOW){
lcd.setCursor(0,0);
lcd.print("1");
}if(digitalRead(3) == LOW){
lcd.setCursor(1,0);
lcd.print("2");
}if(digitalRead(3) == HIGH){
lcd.setCursor(1,1);
lcd.print("2");
}if(digitalRead(5) == HIGH){
lcd.setCursor(0,1);
lcd.print("1");
}
// read the state of the pushbutton value
buttonState = digitalRead(2);
// check if pushbutton is pressed. if it is, the
// buttonState is HIGH
if (buttonState == HIGH) {
// turn LED on
digitalWrite(4, HIGH);
Serial.println("LED ON 10 Detik");
delay(5000);
} else {
// turn LED off
digitalWrite(4, LOW);
}
}