From 5b1afe32cf7496acea8182278aca83f59e8384e3 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Mon, 11 Feb 2013 22:58:16 +0100 Subject: Make code launchpad/energia compatible Signed-off-by: Florian Pritz --- .../examples/Autoscroll/Autoscroll.ino | 83 ++++++++++++ lib/LiquidCrystal/examples/Blink/Blink.ino | 71 ++++++++++ lib/LiquidCrystal/examples/Cursor/Cursor.ino | 70 ++++++++++ .../examples/CustomCharacter/CustomCharacter.ino | 147 +++++++++++++++++++++ lib/LiquidCrystal/examples/Display/Display.ino | 70 ++++++++++ .../examples/HelloWorld/HelloWorld.ino | 68 ++++++++++ lib/LiquidCrystal/examples/Scroll/Scroll.ino | 95 +++++++++++++ .../examples/SerialDisplay/SerialDisplay.ino | 87 ++++++++++++ .../examples/TextDirection/TextDirection.ino | 97 ++++++++++++++ lib/LiquidCrystal/examples/setCursor/setCursor.ino | 81 ++++++++++++ 10 files changed, 869 insertions(+) create mode 100644 lib/LiquidCrystal/examples/Autoscroll/Autoscroll.ino create mode 100644 lib/LiquidCrystal/examples/Blink/Blink.ino create mode 100644 lib/LiquidCrystal/examples/Cursor/Cursor.ino create mode 100644 lib/LiquidCrystal/examples/CustomCharacter/CustomCharacter.ino create mode 100644 lib/LiquidCrystal/examples/Display/Display.ino create mode 100644 lib/LiquidCrystal/examples/HelloWorld/HelloWorld.ino create mode 100644 lib/LiquidCrystal/examples/Scroll/Scroll.ino create mode 100644 lib/LiquidCrystal/examples/SerialDisplay/SerialDisplay.ino create mode 100644 lib/LiquidCrystal/examples/TextDirection/TextDirection.ino create mode 100644 lib/LiquidCrystal/examples/setCursor/setCursor.ino (limited to 'lib/LiquidCrystal/examples') diff --git a/lib/LiquidCrystal/examples/Autoscroll/Autoscroll.ino b/lib/LiquidCrystal/examples/Autoscroll/Autoscroll.ino new file mode 100644 index 0000000..756d5b5 --- /dev/null +++ b/lib/LiquidCrystal/examples/Autoscroll/Autoscroll.ino @@ -0,0 +1,83 @@ +/* + LiquidCrystal Library - Autoscroll + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch demonstrates the use of the autoscroll() + and noAutoscroll() functions to make new text scroll or not. + + The circuit: + ================================= + LCD pin Connect to + --------------------------------- + 01 - GND GND, pot + 02 - VCC +5V, pot + 03 - Contrast Pot wiper + 04 - RS Pin8 (P2.0) + 05 - R/W GND + 06 - EN Pin9 (P2.1) + 07 - DB0 GND + 08 - DB1 GND + 09 - DB2 GND + 10 - DB3 GND + 11 - DB4 Pin10 (P2.2) + 12 - DB5 Pin11 (P2.3) + 13 - DB6 Pin12 (P2.4) + 14 - DB7 Pin13 (P2.5) + 15 - BL+ +5V + 16 - BL- GND + ================================= + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 22 Nov 2010 + by Tom Igoe + + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/LiquidCrystal + */ + +// include the library code: +#include + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(P2_0, P2_1, P2_2, P2_3, P2_4, P2_5); + +void setup() { + // set up the LCD's number of columns and rows: + lcd.begin(16,2); +} + +void loop() { + // set the cursor to (0,0): + lcd.setCursor(0, 0); + // print from 0 to 9: + for (int thisChar = 0; thisChar < 10; thisChar++) { + lcd.print(thisChar); + delay(500); + } + + // set the cursor to (16,1): + lcd.setCursor(16,1); + // set the display to automatically scroll: + lcd.autoscroll(); + // print from 0 to 9: + for (int thisChar = 0; thisChar < 10; thisChar++) { + lcd.print(thisChar); + delay(500); + } + // turn off automatic scrolling + lcd.noAutoscroll(); + + // clear screen for the next loop: + lcd.clear(); +} + diff --git a/lib/LiquidCrystal/examples/Blink/Blink.ino b/lib/LiquidCrystal/examples/Blink/Blink.ino new file mode 100644 index 0000000..b0d2505 --- /dev/null +++ b/lib/LiquidCrystal/examples/Blink/Blink.ino @@ -0,0 +1,71 @@ +/* + LiquidCrystal Library - Blink + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch prints "Hello World!" to the LCD and makes the + cursor block blink. + + The circuit: + ================================= + LCD pin Connect to + --------------------------------- + 01 - GND GND, pot + 02 - VCC +5V, pot + 03 - Contrast Pot wiper + 04 - RS Pin8 (P2.0) + 05 - R/W GND + 06 - EN Pin9 (P2.1) + 07 - DB0 GND + 08 - DB1 GND + 09 - DB2 GND + 10 - DB3 GND + 11 - DB4 Pin10 (P2.2) + 12 - DB5 Pin11 (P2.3) + 13 - DB6 Pin12 (P2.4) + 14 - DB7 Pin13 (P2.5) + 15 - BL+ +5V + 16 - BL- GND + ================================= + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 22 Nov 2010 + by Tom Igoe + + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/LiquidCrystal + + */ + +// include the library code: +#include + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(P2_0, P2_1, P2_2, P2_3, P2_4, P2_5); + +void setup() { + // set up the LCD's number of columns and rows: + lcd.begin(16, 2); + // Print a message to the LCD. + lcd.print("hello, world!"); +} + +void loop() { + // Turn off the blinking cursor: + lcd.noBlink(); + delay(3000); + // Turn on the blinking cursor: + lcd.blink(); + delay(3000); +} + + diff --git a/lib/LiquidCrystal/examples/Cursor/Cursor.ino b/lib/LiquidCrystal/examples/Cursor/Cursor.ino new file mode 100644 index 0000000..8513ef7 --- /dev/null +++ b/lib/LiquidCrystal/examples/Cursor/Cursor.ino @@ -0,0 +1,70 @@ +/* + LiquidCrystal Library - Cursor + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch prints "Hello World!" to the LCD and + uses the cursor() and noCursor() methods to turn + on and off the cursor. + + The circuit: + ================================= + LCD pin Connect to + --------------------------------- + 01 - GND GND, pot + 02 - VCC +5V, pot + 03 - Contrast Pot wiper + 04 - RS Pin8 (P2.0) + 05 - R/W GND + 06 - EN Pin9 (P2.1) + 07 - DB0 GND + 08 - DB1 GND + 09 - DB2 GND + 10 - DB3 GND + 11 - DB4 Pin10 (P2.2) + 12 - DB5 Pin11 (P2.3) + 13 - DB6 Pin12 (P2.4) + 14 - DB7 Pin13 (P2.5) + 15 - BL+ +5V + 16 - BL- GND + ================================= + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 22 Nov 2010 + by Tom Igoe + + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/LiquidCrystal + */ + +// include the library code: +#include + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(P2_0, P2_1, P2_2, P2_3, P2_4, P2_5); + +void setup() { + // set up the LCD's number of columns and rows: + lcd.begin(16, 2); + // Print a message to the LCD. + lcd.print("hello, world!"); +} + +void loop() { + // Turn off the cursor: + lcd.noCursor(); + delay(500); + // Turn on the cursor: + lcd.cursor(); + delay(500); +} + diff --git a/lib/LiquidCrystal/examples/CustomCharacter/CustomCharacter.ino b/lib/LiquidCrystal/examples/CustomCharacter/CustomCharacter.ino new file mode 100644 index 0000000..23fbe56 --- /dev/null +++ b/lib/LiquidCrystal/examples/CustomCharacter/CustomCharacter.ino @@ -0,0 +1,147 @@ +/* + LiquidCrystal Library - Custom Characters + + Demonstrates how to add custom characters on an LCD display. + The LiquidCrystal library works with all LCD displays that are + compatible with the Hitachi HD44780 driver. There are many of + them out there, and you can usually tell them by the 16-pin interface. + + This sketch prints "I Arduino!" and a little dancing man + to the LCD. + + The circuit: + ================================= + LCD pin Connect to + --------------------------------- + 01 - GND GND, pot + 02 - VCC +5V, pot + 03 - Contrast Pot wiper + 04 - RS Pin8 (P2.0) + 05 - R/W GND + 06 - EN Pin9 (P2.1) + 07 - DB0 GND + 08 - DB1 GND + 09 - DB2 GND + 10 - DB3 GND + 11 - DB4 Pin10 (P2.2) + 12 - DB5 Pin11 (P2.3) + 13 - DB6 Pin12 (P2.4) + 14 - DB7 Pin13 (P2.5) + 15 - BL+ +5V + 16 - BL- GND + ================================= + + created21 Mar 2011 + by Tom Igoe + Based on Adafruit's example at + https://github.com/adafruit/SPI_VFD/blob/master/examples/createChar/createChar.pde + + This example code is in the public domain. + http://www.arduino.cc/en/Tutorial/LiquidCrystal + + Also useful: + http://icontexto.com/charactercreator/ + + */ + +// include the library code: +#include + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(P2_0, P2_1, P2_2, P2_3, P2_4, P2_5); + +// make some custom characters: +byte heart[8] = { + 0b00000, + 0b01010, + 0b11111, + 0b11111, + 0b11111, + 0b01110, + 0b00100, + 0b00000 +}; + +byte smiley[8] = { + 0b00000, + 0b00000, + 0b01010, + 0b00000, + 0b00000, + 0b10001, + 0b01110, + 0b00000 +}; + +byte frownie[8] = { + 0b00000, + 0b00000, + 0b01010, + 0b00000, + 0b00000, + 0b00000, + 0b01110, + 0b10001 +}; + +byte armsDown[8] = { + 0b00100, + 0b01010, + 0b00100, + 0b00100, + 0b01110, + 0b10101, + 0b00100, + 0b01010 +}; + +byte armsUp[8] = { + 0b00100, + 0b01010, + 0b00100, + 0b10101, + 0b01110, + 0b00100, + 0b00100, + 0b01010 +}; +void setup() { + // create a new character + lcd.createChar(0, heart); + // create a new character + lcd.createChar(1, smiley); + // create a new character + lcd.createChar(2, frownie); + // create a new character + lcd.createChar(3, armsDown); + // create a new character + lcd.createChar(4, armsUp); + + // set up the lcd's number of columns and rows: + lcd.begin(16, 2); + // Print a message to the lcd. + lcd.print("I "); + lcd.write(0); + lcd.print(" Arduino! "); + lcd.write(1); + +} + +void loop() { + // read the potentiometer on A0: + int sensorReading = analogRead(A0); + // map the result to 200 - 1000: + int delayTime = map(sensorReading, 0, 1023, 200, 1000); + // set the cursor to the bottom row, 5th position: + lcd.setCursor(4, 1); + // draw the little man, arms down: + lcd.write(3); + delay(delayTime); + lcd.setCursor(4, 1); + // draw him arms up: + lcd.write(4); + delay(delayTime); +} + + + diff --git a/lib/LiquidCrystal/examples/Display/Display.ino b/lib/LiquidCrystal/examples/Display/Display.ino new file mode 100644 index 0000000..31289b4 --- /dev/null +++ b/lib/LiquidCrystal/examples/Display/Display.ino @@ -0,0 +1,70 @@ +/* + LiquidCrystal Library - display() and noDisplay() + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch prints "Hello World!" to the LCD and uses the + display() and noDisplay() functions to turn on and off + the display. + + The circuit: + ================================= + LCD pin Connect to + --------------------------------- + 01 - GND GND, pot + 02 - VCC +5V, pot + 03 - Contrast Pot wiper + 04 - RS Pin8 (P2.0) + 05 - R/W GND + 06 - EN Pin9 (P2.1) + 07 - DB0 GND + 08 - DB1 GND + 09 - DB2 GND + 10 - DB3 GND + 11 - DB4 Pin10 (P2.2) + 12 - DB5 Pin11 (P2.3) + 13 - DB6 Pin12 (P2.4) + 14 - DB7 Pin13 (P2.5) + 15 - BL+ +5V + 16 - BL- GND + ================================= + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 22 Nov 2010 + by Tom Igoe + + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/LiquidCrystal + */ + +// include the library code: +#include + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(12, 11, 5, 4, 3, 2); + +void setup() { + // set up the LCD's number of columns and rows: + lcd.begin(16, 2); + // Print a message to the LCD. + lcd.print("hello, world!"); +} + +void loop() { + // Turn off the display: + lcd.noDisplay(); + delay(500); + // Turn on the display: + lcd.display(); + delay(500); +} + diff --git a/lib/LiquidCrystal/examples/HelloWorld/HelloWorld.ino b/lib/LiquidCrystal/examples/HelloWorld/HelloWorld.ino new file mode 100644 index 0000000..f906cd4 --- /dev/null +++ b/lib/LiquidCrystal/examples/HelloWorld/HelloWorld.ino @@ -0,0 +1,68 @@ +/* + LiquidCrystal Library - Hello World + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch prints "Hello World!" to the LCD + and shows the time. + + The circuit: + ================================= + LCD pin Connect to + --------------------------------- + 01 - GND GND, pot + 02 - VCC +5V, pot + 03 - Contrast Pot wiper + 04 - RS Pin8 (P2.0) + 05 - R/W GND + 06 - EN Pin9 (P2.1) + 07 - DB0 GND + 08 - DB1 GND + 09 - DB2 GND + 10 - DB3 GND + 11 - DB4 Pin10 (P2.2) + 12 - DB5 Pin11 (P2.3) + 13 - DB6 Pin12 (P2.4) + 14 - DB7 Pin13 (P2.5) + 15 - BL+ +5V + 16 - BL- GND + ================================= + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 22 Nov 2010 + by Tom Igoe + + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/LiquidCrystal + */ + +// include the library code: +#include + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(P2_0, P2_1, P2_2, P2_3, P2_4, P2_5); + +void setup() { + // set up the LCD's number of columns and rows: + lcd.begin(16, 2); + // Print a message to the LCD. + lcd.print("hello, world!"); +} + +void loop() { + // set the cursor to column 0, line 1 + // (note: line 1 is the second row, since counting begins with 0): + lcd.setCursor(0, 1); + // print the number of seconds since reset: + lcd.print(millis()/1000); +} + diff --git a/lib/LiquidCrystal/examples/Scroll/Scroll.ino b/lib/LiquidCrystal/examples/Scroll/Scroll.ino new file mode 100644 index 0000000..0da976d --- /dev/null +++ b/lib/LiquidCrystal/examples/Scroll/Scroll.ino @@ -0,0 +1,95 @@ +/* + LiquidCrystal Library - scrollDisplayLeft() and scrollDisplayRight() + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch prints "Hello World!" to the LCD and uses the + scrollDisplayLeft() and scrollDisplayRight() methods to scroll + the text. + + The circuit: + ================================= + LCD pin Connect to + --------------------------------- + 01 - GND GND, pot + 02 - VCC +5V, pot + 03 - Contrast Pot wiper + 04 - RS Pin8 (P2.0) + 05 - R/W GND + 06 - EN Pin9 (P2.1) + 07 - DB0 GND + 08 - DB1 GND + 09 - DB2 GND + 10 - DB3 GND + 11 - DB4 Pin10 (P2.2) + 12 - DB5 Pin11 (P2.3) + 13 - DB6 Pin12 (P2.4) + 14 - DB7 Pin13 (P2.5) + 15 - BL+ +5V + 16 - BL- GND + ================================= + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 22 Nov 2010 + by Tom Igoe + + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/LiquidCrystal + */ + +// include the library code: +#include + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(P2_0, P2_1, P2_2, P2_3, P2_4, P2_5); + +void setup() { + // set up the LCD's number of columns and rows: + lcd.begin(16, 2); + // Print a message to the LCD. + lcd.print("hello, world!"); + delay(1000); +} + +void loop() { + // scroll 13 positions (string length) to the left + // to move it offscreen left: + for (int positionCounter = 0; positionCounter < 13; positionCounter++) { + // scroll one position left: + lcd.scrollDisplayLeft(); + // wait a bit: + delay(150); + } + + // scroll 29 positions (string length + display length) to the right + // to move it offscreen right: + for (int positionCounter = 0; positionCounter < 29; positionCounter++) { + // scroll one position right: + lcd.scrollDisplayRight(); + // wait a bit: + delay(150); + } + + // scroll 16 positions (display length + string length) to the left + // to move it back to center: + for (int positionCounter = 0; positionCounter < 16; positionCounter++) { + // scroll one position left: + lcd.scrollDisplayLeft(); + // wait a bit: + delay(150); + } + + // delay at the end of the full loop: + delay(1000); + +} + diff --git a/lib/LiquidCrystal/examples/SerialDisplay/SerialDisplay.ino b/lib/LiquidCrystal/examples/SerialDisplay/SerialDisplay.ino new file mode 100644 index 0000000..f76d23d --- /dev/null +++ b/lib/LiquidCrystal/examples/SerialDisplay/SerialDisplay.ino @@ -0,0 +1,87 @@ +/* + LiquidCrystal Library - Serial Input + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch displays text sent over the serial port + (e.g. from the Serial Monitor) on an attached LCD. + + The circuit: + ================================= + LCD pin Connect to + --------------------------------- + 01 - GND GND, pot + 02 - VCC +5V, pot + 03 - Contrast Pot wiper + 04 - RS Pin8 (P2.0) + 05 - R/W GND + 06 - EN Pin9 (P2.1) + 07 - DB0 GND + 08 - DB1 GND + 09 - DB2 GND + 10 - DB3 GND + 11 - DB4 Pin10 (P2.2) + 12 - DB5 Pin11 (P2.3) + 13 - DB6 Pin12 (P2.4) + 14 - DB7 Pin13 (P2.5) + 15 - BL+ +5V + 16 - BL- GND + ================================= + + 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) + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 22 Nov 2010 + by Tom Igoe + + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/LiquidCrystal + */ + +// include the library code: +#include + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(P2_0, P2_1, P2_2, P2_3, P2_4, P2_5); + +void setup(){ + // set up the LCD's number of columns and rows: + lcd.begin(16, 2); + // initialize the serial communications: + Serial.begin(9600); +} + +void loop() +{ + // when characters arrive over the serial port... + if (Serial.available()) { + // wait a bit for the entire message to arrive + delay(100); + // clear the screen + lcd.clear(); + // read all the available characters + while (Serial.available() > 0) { + // display each character to the LCD + lcd.write(Serial.read()); + } + } +} diff --git a/lib/LiquidCrystal/examples/TextDirection/TextDirection.ino b/lib/LiquidCrystal/examples/TextDirection/TextDirection.ino new file mode 100644 index 0000000..9114197 --- /dev/null +++ b/lib/LiquidCrystal/examples/TextDirection/TextDirection.ino @@ -0,0 +1,97 @@ + /* + LiquidCrystal Library - TextDirection + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch demonstrates how to use leftToRight() and rightToLeft() + to move the cursor. + + The circuit: + ================================= + LCD pin Connect to + --------------------------------- + 01 - GND GND, pot + 02 - VCC +5V, pot + 03 - Contrast Pot wiper + 04 - RS Pin8 (P2.0) + 05 - R/W GND + 06 - EN Pin9 (P2.1) + 07 - DB0 GND + 08 - DB1 GND + 09 - DB2 GND + 10 - DB3 GND + 11 - DB4 Pin10 (P2.2) + 12 - DB5 Pin11 (P2.3) + 13 - DB6 Pin12 (P2.4) + 14 - DB7 Pin13 (P2.5) + 15 - BL+ +5V + 16 - BL- GND + ================================= + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 22 Nov 2010 + by Tom Igoe + + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/LiquidCrystal + + */ + +// include the library code: +#include + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(P2_0, P2_1, P2_2, P2_3, P2_4, P2_5); + +int thisChar = 'a'; + +void setup() { + // set up the LCD's number of columns and rows: + lcd.begin(16, 2); + // turn on the cursor: + lcd.cursor(); + Serial.begin(9600); +} + +void loop() { + // reverse directions at 'm': + if (thisChar == 'm') { + // go right for the next letter + lcd.rightToLeft(); + } + // reverse again at 's': + if (thisChar == 's') { + // go left for the next letter + lcd.leftToRight(); + } + // reset at 'z': + if (thisChar > 'z') { + // go to (0,0): + lcd.home(); + // start again at 0 + thisChar = 'a'; + } + // print the character + lcd.write(thisChar); + // wait a second: + delay(1000); + // increment the letter: + thisChar++; +} + + + + + + + + diff --git a/lib/LiquidCrystal/examples/setCursor/setCursor.ino b/lib/LiquidCrystal/examples/setCursor/setCursor.ino new file mode 100644 index 0000000..131e810 --- /dev/null +++ b/lib/LiquidCrystal/examples/setCursor/setCursor.ino @@ -0,0 +1,81 @@ +/* + LiquidCrystal Library - setCursor + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch prints to all the positions of the LCD using the + setCursor(0 method: + + The circuit: + ================================= + LCD pin Connect to + --------------------------------- + 01 - GND GND, pot + 02 - VCC +5V, pot + 03 - Contrast Pot wiper + 04 - RS Pin8 (P2.0) + 05 - R/W GND + 06 - EN Pin9 (P2.1) + 07 - DB0 GND + 08 - DB1 GND + 09 - DB2 GND + 10 - DB3 GND + 11 - DB4 Pin10 (P2.2) + 12 - DB5 Pin11 (P2.3) + 13 - DB6 Pin12 (P2.4) + 14 - DB7 Pin13 (P2.5) + 15 - BL+ +5V + 16 - BL- GND + ================================= + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 22 Nov 2010 + by Tom Igoe + + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/LiquidCrystal + */ + +// include the library code: +#include + +// these constants won't change. But you can change the size of +// your LCD using them: +const int numRows = 2; +const int numCols = 16; + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(P2_0, P2_1, P2_2, P2_3, P2_4, P2_5); + +void setup() { + // set up the LCD's number of columns and rows: + lcd.begin(numCols,numRows); +} + +void loop() { + // loop from ASCII 'a' to ASCII 'z': + for (int thisLetter = 'a'; thisLetter <= 'z'; thisLetter++) { + // loop over the columns: + for (int thisCol = 0; thisCol < numRows; thisCol++) { + // loop over the rows: + for (int thisRow = 0; thisRow < numCols; thisRow++) { + // set the cursor position: + lcd.setCursor(thisRow,thisCol); + // print the letter: + lcd.write(thisLetter); + delay(200); + } + } + } +} + + -- cgit v1.2.3-24-g4f1b