Sunday, 12 December 2010

Weird how the power dips when I press the button so the LCD fades, but the logic works, atleast on the old NG, not sure it likes sharing with the speakJet Shield...
// adapted from SIMON MONKS Project 17 - LCD message board

#include

// LiquidCrystal display with:
// rs on pin 12
// rw on pin 11
// enable on pin 10
// d4-7 on pins 5-2
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

const int buttonPin = 7; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin

// variables will change:
int buttonState = 0;
void setup()
{
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
Serial.begin(9600);
lcd.begin(2, 20);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Evil Genius");
lcd.setCursor(0,1);
lcd.print("Rules");
}



void loop()
{
buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
lcd.clear();
lcd.setCursor(0,1);
lcd.print("HI!/
/
/");
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}


if (Serial.available())
{
char ch = Serial.read();
if (ch == '#')
{
lcd.clear();
}
else if (ch == '/')
{
lcd.clear();
lcd.setCursor(0,1);
lcd.print("Rules");
}
else
{
lcd.write(ch);
}
}
}

No comments:

Post a Comment