/* Demonstrates the use a 2x16 OLED display. The LiquidCrystal library works with all LCD displays that are compatible with the Hitachi HD44780 driver. This sketch prints to the OLED and shows the time since last reset The circuit: * OLED RS pin to digital pin 12 * OLED Enable pin to digital pin 11 * OLED D4 pin to digital pin 5 * OLED D5 pin to digital pin 4 * OLED D6 pin to digital pin 3 * OLED D7 pin to digital pin 2 * OLED R/W pin to ground to digital pin 13 (PB5) * PIR Sensor Output Pin3 to digital pin */ // include the library code: #include #include #include int PIR = 13; //PIR sensor connected to digital pin 13 // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { setTime(15,36,30,14,5,2013); lcd.begin(16, 2); delay(100); // wait for 1/10 second pinMode(PIR, INPUT); // sets the digital pin 13 as input } void loop() { if (digitalRead(13) == HIGH){ lcd.print("CAUTION CAUTION"); lcd.setCursor(0, 1); lcd.print("TRAFFIC TRAFFIC"); lcd.display(); delay(200); lcd.noDisplay(); delay(200); } else { lcd.clear(); lcd.setCursor(0, 0); delay(10); // wait for 1/10 second } }