/* 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 * 10K resistor: * ends to +5V and ground * wiper to LCD VO pin (pin 3) * piezo etc to pin 13 and ground * 2 leds, to pins 9, 8 and ground ---------------------------------------- Write by Arttu Mahlakaato 04.16.2012 This example code is in the public domain. http://www.koti.mbnet.fi/arttu97/share/bomb.ino */ #include int timer=120; LiquidCrystal lcd(12, 11, 5, 4, 3, 2); int detonatorPin = 13; int ledPin = 9; int resetPin = 8; void setup() { pinMode(detonatorPin, OUTPUT); pinMode(ledPin, OUTPUT); pinMode(resetPin, OUTPUT); lcd.begin(20, 4); lcd.print("#########################"); lcd.setCursor(0,1); lcd.print("#########################"); lcd.setCursor(0,2); lcd.print("#########################"); lcd.setCursor(0,3); lcd.print("#########################"); delay(1000); lcd.clear(); lcd.print("Starting..."); digitalWrite(ledPin, HIGH); delay(2000); lcd.clear(); lcd.print("Loading core..."); lcd.setCursor(1,1); lcd.print("#############"); delay(1000); lcd.clear(); lcd.setCursor(0,0); lcd.print("Loading core..."); lcd.setCursor(1,1); lcd.print("*############"); delay(1000); lcd.clear(); lcd.setCursor(0,0); lcd.print("Loading core..."); lcd.setCursor(1,1); lcd.print("****#########"); delay(1000); lcd.clear(); lcd.setCursor(0,0); lcd.print("Loading core..."); lcd.setCursor(1,1); lcd.print("********#####"); delay(1000); lcd.clear(); lcd.setCursor(0,0); lcd.print("Loading core..."); lcd.setCursor(1,1); lcd.print("*************"); delay(2000); lcd.setCursor(2,2); lcd.print("Core Loaded!"); delay(5000); lcd.clear(); lcd.setCursor(0,0); lcd.print("Status:Connected."); delay(1000); lcd.setCursor(6,1); lcd.print("Armed"); delay(1000); lcd.setCursor(0,2); lcd.print("*******READY********"); digitalWrite(resetPin, HIGH); delay(5000); digitalWrite(detonatorPin, HIGH); delay(150); digitalWrite(detonatorPin, LOW); delay(500); digitalWrite(detonatorPin, HIGH); delay(150); digitalWrite(detonatorPin, LOW); lcd.clear(); lcd.setCursor(0,0); lcd.print("Self-destruction in:"); } void loop if (timer<=0) { lcd.clear(); delay(2000); lcd.setCursor(6,0); lcd.print("KABOOM!"); lcd.setCursor(4,1); lcd.print("KABOOM!"); lcd.setCursor(06,2); lcd.print("KABOOM!"); lcd.setCursor(3,3); lcd.print("KABOOM!"); digitalWrite(resetPin, HIGH); digitalWrite(detonatorPin, HIGH); delay(2000); digitalWrite(detonatorPin, LOW); } else{ lcd.setCursor(8, 1); } while(timer>=0) { lcd.print(timer); lcd.setCursor(8, 1); timer--; digitalWrite(ledPin, LOW); digitalWrite(detonatorPin, LOW); delay(1000); digitalWrite(detonatorPin, HIGH); digitalWrite(ledPin, HIGH); if (timer<=100){ lcd.clear(); lcd.setCursor(0,0); lcd.print("Self-destruction in:"); lcd.setCursor(3,2); lcd.print(" Defuse faster!"); lcd.setCursor(8,1); } if (timer<=60) { lcd.clear(); lcd.setCursor(0,0); lcd.print("You may escape now!"); lcd.setCursor(2,2); lcd.print("Time's almost up"); lcd.setCursor(8,1); } if (timer<=10) { lcd.clear(); lcd.setCursor(1,0); lcd.print(" Goodbye"); lcd.setCursor(8,1); // } } }