Run new astyle formatter against all the examples

This commit is contained in:
Federico Fissore
2013-10-21 09:58:40 +02:00
parent 998f9ce164
commit e0a4493868
10 changed files with 144 additions and 144 deletions

View File

@@ -1,14 +1,14 @@
/* /*
LiquidCrystal Library - Autoscroll LiquidCrystal Library - Autoscroll
Demonstrates the use a 16x2 LCD display. The LiquidCrystal Demonstrates the use a 16x2 LCD display. The LiquidCrystal
library works with all LCD displays that are compatible with the library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you Hitachi HD44780 driver. There are many of them out there, and you
can usually tell them by the 16-pin interface. can usually tell them by the 16-pin interface.
This sketch demonstrates the use of the autoscroll() This sketch demonstrates the use of the autoscroll()
and noAutoscroll() functions to make new text scroll or not. and noAutoscroll() functions to make new text scroll or not.
The circuit: The circuit:
* LCD RS pin to digital pin 12 * LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11 * LCD Enable pin to digital pin 11
@@ -20,16 +20,16 @@
* 10K resistor: * 10K resistor:
* ends to +5V and ground * ends to +5V and ground
* wiper to LCD VO pin (pin 3) * wiper to LCD VO pin (pin 3)
Library originally added 18 Apr 2008 Library originally added 18 Apr 2008
by David A. Mellis by David A. Mellis
library modified 5 Jul 2009 library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net) by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009 example added 9 Jul 2009
by Tom Igoe by Tom Igoe
modified 22 Nov 2010 modified 22 Nov 2010
by Tom Igoe by Tom Igoe
This example code is in the public domain. This example code is in the public domain.
http://arduino.cc/en/Tutorial/LiquidCrystalAutoscroll http://arduino.cc/en/Tutorial/LiquidCrystalAutoscroll
@@ -43,8 +43,8 @@
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() { void setup() {
// set up the LCD's number of columns and rows: // set up the LCD's number of columns and rows:
lcd.begin(16,2); lcd.begin(16, 2);
} }
void loop() { void loop() {
@@ -52,12 +52,12 @@ void loop() {
lcd.setCursor(0, 0); lcd.setCursor(0, 0);
// print from 0 to 9: // print from 0 to 9:
for (int thisChar = 0; thisChar < 10; thisChar++) { for (int thisChar = 0; thisChar < 10; thisChar++) {
lcd.print(thisChar); lcd.print(thisChar);
delay(500); delay(500);
} }
// set the cursor to (16,1): // set the cursor to (16,1):
lcd.setCursor(16,1); lcd.setCursor(16, 1);
// set the display to automatically scroll: // set the display to automatically scroll:
lcd.autoscroll(); lcd.autoscroll();
// print from 0 to 9: // print from 0 to 9:
@@ -67,7 +67,7 @@ void loop() {
} }
// turn off automatic scrolling // turn off automatic scrolling
lcd.noAutoscroll(); lcd.noAutoscroll();
// clear screen for the next loop: // clear screen for the next loop:
lcd.clear(); lcd.clear();
} }

View File

@@ -1,14 +1,14 @@
/* /*
LiquidCrystal Library - Blink LiquidCrystal Library - Blink
Demonstrates the use a 16x2 LCD display. The LiquidCrystal Demonstrates the use a 16x2 LCD display. The LiquidCrystal
library works with all LCD displays that are compatible with the library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you Hitachi HD44780 driver. There are many of them out there, and you
can usually tell them by the 16-pin interface. can usually tell them by the 16-pin interface.
This sketch prints "Hello World!" to the LCD and makes the This sketch prints "Hello World!" to the LCD and makes the
cursor block blink. cursor block blink.
The circuit: The circuit:
* LCD RS pin to digital pin 12 * LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11 * LCD Enable pin to digital pin 11
@@ -20,20 +20,20 @@
* 10K resistor: * 10K resistor:
* ends to +5V and ground * ends to +5V and ground
* wiper to LCD VO pin (pin 3) * wiper to LCD VO pin (pin 3)
Library originally added 18 Apr 2008 Library originally added 18 Apr 2008
by David A. Mellis by David A. Mellis
library modified 5 Jul 2009 library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net) by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009 example added 9 Jul 2009
by Tom Igoe by Tom Igoe
modified 22 Nov 2010 modified 22 Nov 2010
by Tom Igoe by Tom Igoe
This example code is in the public domain. This example code is in the public domain.
http://arduino.cc/en/Tutorial/LiquidCrystalBlink http://arduino.cc/en/Tutorial/LiquidCrystalBlink
*/ */
// include the library code: // include the library code:
@@ -43,7 +43,7 @@
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() { void setup() {
// set up the LCD's number of columns and rows: // set up the LCD's number of columns and rows:
lcd.begin(16, 2); lcd.begin(16, 2);
// Print a message to the LCD. // Print a message to the LCD.
lcd.print("hello, world!"); lcd.print("hello, world!");
@@ -53,7 +53,7 @@ void loop() {
// Turn off the blinking cursor: // Turn off the blinking cursor:
lcd.noBlink(); lcd.noBlink();
delay(3000); delay(3000);
// Turn on the blinking cursor: // Turn on the blinking cursor:
lcd.blink(); lcd.blink();
delay(3000); delay(3000);
} }

View File

@@ -1,15 +1,15 @@
/* /*
LiquidCrystal Library - Cursor LiquidCrystal Library - Cursor
Demonstrates the use a 16x2 LCD display. The LiquidCrystal Demonstrates the use a 16x2 LCD display. The LiquidCrystal
library works with all LCD displays that are compatible with the library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you Hitachi HD44780 driver. There are many of them out there, and you
can usually tell them by the 16-pin interface. can usually tell them by the 16-pin interface.
This sketch prints "Hello World!" to the LCD and This sketch prints "Hello World!" to the LCD and
uses the cursor() and noCursor() methods to turn uses the cursor() and noCursor() methods to turn
on and off the cursor. on and off the cursor.
The circuit: The circuit:
* LCD RS pin to digital pin 12 * LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11 * LCD Enable pin to digital pin 11
@@ -21,13 +21,13 @@
* 10K resistor: * 10K resistor:
* ends to +5V and ground * ends to +5V and ground
* wiper to LCD VO pin (pin 3) * wiper to LCD VO pin (pin 3)
Library originally added 18 Apr 2008 Library originally added 18 Apr 2008
by David A. Mellis by David A. Mellis
library modified 5 Jul 2009 library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net) by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009 example added 9 Jul 2009
by Tom Igoe by Tom Igoe
modified 22 Nov 2010 modified 22 Nov 2010
by Tom Igoe by Tom Igoe
@@ -44,7 +44,7 @@
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() { void setup() {
// set up the LCD's number of columns and rows: // set up the LCD's number of columns and rows:
lcd.begin(16, 2); lcd.begin(16, 2);
// Print a message to the LCD. // Print a message to the LCD.
lcd.print("hello, world!"); lcd.print("hello, world!");
@@ -54,7 +54,7 @@ void loop() {
// Turn off the cursor: // Turn off the cursor:
lcd.noCursor(); lcd.noCursor();
delay(500); delay(500);
// Turn on the cursor: // Turn on the cursor:
lcd.cursor(); lcd.cursor();
delay(500); delay(500);
} }

View File

@@ -1,14 +1,14 @@
/* /*
LiquidCrystal Library - Custom Characters LiquidCrystal Library - Custom Characters
Demonstrates how to add custom characters on an LCD display. Demonstrates how to add custom characters on an LCD display.
The LiquidCrystal library works with all LCD displays that are The LiquidCrystal library works with all LCD displays that are
compatible with the Hitachi HD44780 driver. There are many of compatible with the Hitachi HD44780 driver. There are many of
them out there, and you can usually tell them by the 16-pin interface. them out there, and you can usually tell them by the 16-pin interface.
This sketch prints "I <heart> Arduino!" and a little dancing man This sketch prints "I <heart> Arduino!" and a little dancing man
to the LCD. to the LCD.
The circuit: The circuit:
* LCD RS pin to digital pin 12 * LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11 * LCD Enable pin to digital pin 11
@@ -21,18 +21,18 @@
* ends to +5V and ground * ends to +5V and ground
* wiper to LCD VO pin (pin 3) * wiper to LCD VO pin (pin 3)
* 10K poterntiometer on pin A0 * 10K poterntiometer on pin A0
created21 Mar 2011 created21 Mar 2011
by Tom Igoe by Tom Igoe
Based on Adafruit's example at Based on Adafruit's example at
https://github.com/adafruit/SPI_VFD/blob/master/examples/createChar/createChar.pde https://github.com/adafruit/SPI_VFD/blob/master/examples/createChar/createChar.pde
This example code is in the public domain. This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystal http://www.arduino.cc/en/Tutorial/LiquidCrystal
Also useful: Also useful:
http://icontexto.com/charactercreator/ http://icontexto.com/charactercreator/
*/ */
// include the library code: // include the library code:
@@ -104,14 +104,14 @@ void setup() {
// create a new character // create a new character
lcd.createChar(2, frownie); lcd.createChar(2, frownie);
// create a new character // create a new character
lcd.createChar(3, armsDown); lcd.createChar(3, armsDown);
// create a new character // create a new character
lcd.createChar(4, armsUp); lcd.createChar(4, armsUp);
// set up the lcd's number of columns and rows: // set up the lcd's number of columns and rows:
lcd.begin(16, 2); lcd.begin(16, 2);
// Print a message to the lcd. // Print a message to the lcd.
lcd.print("I "); lcd.print("I ");
lcd.write(0); lcd.write(0);
lcd.print(" Arduino! "); lcd.print(" Arduino! ");
lcd.write(1); lcd.write(1);
@@ -131,7 +131,7 @@ void loop() {
lcd.setCursor(4, 1); lcd.setCursor(4, 1);
// draw him arms up: // draw him arms up:
lcd.write(4); lcd.write(4);
delay(delayTime); delay(delayTime);
} }

View File

@@ -1,15 +1,15 @@
/* /*
LiquidCrystal Library - display() and noDisplay() LiquidCrystal Library - display() and noDisplay()
Demonstrates the use a 16x2 LCD display. The LiquidCrystal Demonstrates the use a 16x2 LCD display. The LiquidCrystal
library works with all LCD displays that are compatible with the library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you Hitachi HD44780 driver. There are many of them out there, and you
can usually tell them by the 16-pin interface. can usually tell them by the 16-pin interface.
This sketch prints "Hello World!" to the LCD and uses the This sketch prints "Hello World!" to the LCD and uses the
display() and noDisplay() functions to turn on and off display() and noDisplay() functions to turn on and off
the display. the display.
The circuit: The circuit:
* LCD RS pin to digital pin 12 * LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11 * LCD Enable pin to digital pin 11
@@ -21,13 +21,13 @@
* 10K resistor: * 10K resistor:
* ends to +5V and ground * ends to +5V and ground
* wiper to LCD VO pin (pin 3) * wiper to LCD VO pin (pin 3)
Library originally added 18 Apr 2008 Library originally added 18 Apr 2008
by David A. Mellis by David A. Mellis
library modified 5 Jul 2009 library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net) by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009 example added 9 Jul 2009
by Tom Igoe by Tom Igoe
modified 22 Nov 2010 modified 22 Nov 2010
by Tom Igoe by Tom Igoe
@@ -44,7 +44,7 @@
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() { void setup() {
// set up the LCD's number of columns and rows: // set up the LCD's number of columns and rows:
lcd.begin(16, 2); lcd.begin(16, 2);
// Print a message to the LCD. // Print a message to the LCD.
lcd.print("hello, world!"); lcd.print("hello, world!");
@@ -54,7 +54,7 @@ void loop() {
// Turn off the display: // Turn off the display:
lcd.noDisplay(); lcd.noDisplay();
delay(500); delay(500);
// Turn on the display: // Turn on the display:
lcd.display(); lcd.display();
delay(500); delay(500);
} }

View File

@@ -1,14 +1,14 @@
/* /*
LiquidCrystal Library - Hello World LiquidCrystal Library - Hello World
Demonstrates the use a 16x2 LCD display. The LiquidCrystal Demonstrates the use a 16x2 LCD display. The LiquidCrystal
library works with all LCD displays that are compatible with the library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you Hitachi HD44780 driver. There are many of them out there, and you
can usually tell them by the 16-pin interface. can usually tell them by the 16-pin interface.
This sketch prints "Hello World!" to the LCD This sketch prints "Hello World!" to the LCD
and shows the time. and shows the time.
The circuit: The circuit:
* LCD RS pin to digital pin 12 * LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11 * LCD Enable pin to digital pin 11
@@ -20,7 +20,7 @@
* 10K resistor: * 10K resistor:
* ends to +5V and ground * ends to +5V and ground
* wiper to LCD VO pin (pin 3) * wiper to LCD VO pin (pin 3)
Library originally added 18 Apr 2008 Library originally added 18 Apr 2008
by David A. Mellis by David A. Mellis
library modified 5 Jul 2009 library modified 5 Jul 2009
@@ -29,7 +29,7 @@
by Tom Igoe by Tom Igoe
modified 22 Nov 2010 modified 22 Nov 2010
by Tom Igoe by Tom Igoe
This example code is in the public domain. This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystal http://www.arduino.cc/en/Tutorial/LiquidCrystal
@@ -42,7 +42,7 @@
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() { void setup() {
// set up the LCD's number of columns and rows: // set up the LCD's number of columns and rows:
lcd.begin(16, 2); lcd.begin(16, 2);
// Print a message to the LCD. // Print a message to the LCD.
lcd.print("hello, world!"); lcd.print("hello, world!");
@@ -53,6 +53,6 @@ void loop() {
// (note: line 1 is the second row, since counting begins with 0): // (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1); lcd.setCursor(0, 1);
// print the number of seconds since reset: // print the number of seconds since reset:
lcd.print(millis()/1000); lcd.print(millis() / 1000);
} }

View File

@@ -1,15 +1,15 @@
/* /*
LiquidCrystal Library - scrollDisplayLeft() and scrollDisplayRight() LiquidCrystal Library - scrollDisplayLeft() and scrollDisplayRight()
Demonstrates the use a 16x2 LCD display. The LiquidCrystal Demonstrates the use a 16x2 LCD display. The LiquidCrystal
library works with all LCD displays that are compatible with the library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you Hitachi HD44780 driver. There are many of them out there, and you
can usually tell them by the 16-pin interface. can usually tell them by the 16-pin interface.
This sketch prints "Hello World!" to the LCD and uses the This sketch prints "Hello World!" to the LCD and uses the
scrollDisplayLeft() and scrollDisplayRight() methods to scroll scrollDisplayLeft() and scrollDisplayRight() methods to scroll
the text. the text.
The circuit: The circuit:
* LCD RS pin to digital pin 12 * LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11 * LCD Enable pin to digital pin 11
@@ -21,18 +21,18 @@
* 10K resistor: * 10K resistor:
* ends to +5V and ground * ends to +5V and ground
* wiper to LCD VO pin (pin 3) * wiper to LCD VO pin (pin 3)
Library originally added 18 Apr 2008 Library originally added 18 Apr 2008
by David A. Mellis by David A. Mellis
library modified 5 Jul 2009 library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net) by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009 example added 9 Jul 2009
by Tom Igoe by Tom Igoe
modified 22 Nov 2010 modified 22 Nov 2010
by Tom Igoe by Tom Igoe
This example code is in the public domain. This example code is in the public domain.
http://arduino.cc/en/Tutorial/LiquidCrystalScroll http://arduino.cc/en/Tutorial/LiquidCrystalScroll
*/ */
@@ -44,7 +44,7 @@
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() { void setup() {
// set up the LCD's number of columns and rows: // set up the LCD's number of columns and rows:
lcd.begin(16, 2); lcd.begin(16, 2);
// Print a message to the LCD. // Print a message to the LCD.
lcd.print("hello, world!"); lcd.print("hello, world!");
@@ -52,11 +52,11 @@ void setup() {
} }
void loop() { void loop() {
// scroll 13 positions (string length) to the left // scroll 13 positions (string length) to the left
// to move it offscreen left: // to move it offscreen left:
for (int positionCounter = 0; positionCounter < 13; positionCounter++) { for (int positionCounter = 0; positionCounter < 13; positionCounter++) {
// scroll one position left: // scroll one position left:
lcd.scrollDisplayLeft(); lcd.scrollDisplayLeft();
// wait a bit: // wait a bit:
delay(150); delay(150);
} }
@@ -65,20 +65,20 @@ void loop() {
// to move it offscreen right: // to move it offscreen right:
for (int positionCounter = 0; positionCounter < 29; positionCounter++) { for (int positionCounter = 0; positionCounter < 29; positionCounter++) {
// scroll one position right: // scroll one position right:
lcd.scrollDisplayRight(); lcd.scrollDisplayRight();
// wait a bit: // wait a bit:
delay(150); delay(150);
} }
// scroll 16 positions (display length + string length) to the left // scroll 16 positions (display length + string length) to the left
// to move it back to center: // to move it back to center:
for (int positionCounter = 0; positionCounter < 16; positionCounter++) { for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
// scroll one position left: // scroll one position left:
lcd.scrollDisplayLeft(); lcd.scrollDisplayLeft();
// wait a bit: // wait a bit:
delay(150); delay(150);
} }
// delay at the end of the full loop: // delay at the end of the full loop:
delay(1000); delay(1000);

View File

@@ -1,14 +1,14 @@
/* /*
LiquidCrystal Library - Serial Input LiquidCrystal Library - Serial Input
Demonstrates the use a 16x2 LCD display. The LiquidCrystal Demonstrates the use a 16x2 LCD display. The LiquidCrystal
library works with all LCD displays that are compatible with the library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you Hitachi HD44780 driver. There are many of them out there, and you
can usually tell them by the 16-pin interface. can usually tell them by the 16-pin interface.
This sketch displays text sent over the serial port This sketch displays text sent over the serial port
(e.g. from the Serial Monitor) on an attached LCD. (e.g. from the Serial Monitor) on an attached LCD.
The circuit: The circuit:
* LCD RS pin to digital pin 12 * LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11 * LCD Enable pin to digital pin 11
@@ -20,18 +20,18 @@
* 10K resistor: * 10K resistor:
* ends to +5V and ground * ends to +5V and ground
* wiper to LCD VO pin (pin 3) * wiper to LCD VO pin (pin 3)
Library originally added 18 Apr 2008 Library originally added 18 Apr 2008
by David A. Mellis by David A. Mellis
library modified 5 Jul 2009 library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net) by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009 example added 9 Jul 2009
by Tom Igoe by Tom Igoe
modified 22 Nov 2010 modified 22 Nov 2010
by Tom Igoe by Tom Igoe
This example code is in the public domain. This example code is in the public domain.
http://arduino.cc/en/Tutorial/LiquidCrystalSerial http://arduino.cc/en/Tutorial/LiquidCrystalSerial
*/ */
@@ -41,8 +41,8 @@
// initialize the library with the numbers of the interface pins // initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup(){ void setup() {
// set up the LCD's number of columns and rows: // set up the LCD's number of columns and rows:
lcd.begin(16, 2); lcd.begin(16, 2);
// initialize the serial communications: // initialize the serial communications:
Serial.begin(9600); Serial.begin(9600);

View File

@@ -1,40 +1,40 @@
/* /*
LiquidCrystal Library - TextDirection LiquidCrystal Library - TextDirection
Demonstrates the use a 16x2 LCD display. The LiquidCrystal Demonstrates the use a 16x2 LCD display. The LiquidCrystal
library works with all LCD displays that are compatible with the library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you Hitachi HD44780 driver. There are many of them out there, and you
can usually tell them by the 16-pin interface. can usually tell them by the 16-pin interface.
This sketch demonstrates how to use leftToRight() and rightToLeft() This sketch demonstrates how to use leftToRight() and rightToLeft()
to move the cursor. to move the cursor.
The circuit: The circuit:
* LCD RS pin to digital pin 12 * LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11 * LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5 * LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4 * LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3 * LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2 * LCD D7 pin to digital pin 2
* LCD R/W pin to ground * LCD R/W pin to ground
* 10K resistor: * 10K resistor:
* ends to +5V and ground * ends to +5V and ground
* wiper to LCD VO pin (pin 3) * wiper to LCD VO pin (pin 3)
Library originally added 18 Apr 2008 Library originally added 18 Apr 2008
by David A. Mellis by David A. Mellis
library modified 5 Jul 2009 library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net) by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009 example added 9 Jul 2009
by Tom Igoe by Tom Igoe
modified 22 Nov 2010 modified 22 Nov 2010
by Tom Igoe by Tom Igoe
This example code is in the public domain. This example code is in the public domain.
http://arduino.cc/en/Tutorial/LiquidCrystalTextDirection http://arduino.cc/en/Tutorial/LiquidCrystalTextDirection
*/ */
// include the library code: // include the library code:
#include <LiquidCrystal.h> #include <LiquidCrystal.h>
@@ -45,7 +45,7 @@ LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int thisChar = 'a'; int thisChar = 'a';
void setup() { void setup() {
// set up the LCD's number of columns and rows: // set up the LCD's number of columns and rows:
lcd.begin(16, 2); lcd.begin(16, 2);
// turn on the cursor: // turn on the cursor:
lcd.cursor(); lcd.cursor();
@@ -55,17 +55,17 @@ void loop() {
// reverse directions at 'm': // reverse directions at 'm':
if (thisChar == 'm') { if (thisChar == 'm') {
// go right for the next letter // go right for the next letter
lcd.rightToLeft(); lcd.rightToLeft();
} }
// reverse again at 's': // reverse again at 's':
if (thisChar == 's') { if (thisChar == 's') {
// go left for the next letter // go left for the next letter
lcd.leftToRight(); lcd.leftToRight();
} }
// reset at 'z': // reset at 'z':
if (thisChar > 'z') { if (thisChar > 'z') {
// go to (0,0): // go to (0,0):
lcd.home(); lcd.home();
// start again at 0 // start again at 0
thisChar = 'a'; thisChar = 'a';
} }

View File

@@ -1,14 +1,14 @@
/* /*
LiquidCrystal Library - setCursor LiquidCrystal Library - setCursor
Demonstrates the use a 16x2 LCD display. The LiquidCrystal Demonstrates the use a 16x2 LCD display. The LiquidCrystal
library works with all LCD displays that are compatible with the library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you Hitachi HD44780 driver. There are many of them out there, and you
can usually tell them by the 16-pin interface. can usually tell them by the 16-pin interface.
This sketch prints to all the positions of the LCD using the This sketch prints to all the positions of the LCD using the
setCursor(0 method: setCursor(0 method:
The circuit: The circuit:
* LCD RS pin to digital pin 12 * LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11 * LCD Enable pin to digital pin 11
@@ -20,18 +20,18 @@
* 10K resistor: * 10K resistor:
* ends to +5V and ground * ends to +5V and ground
* wiper to LCD VO pin (pin 3) * wiper to LCD VO pin (pin 3)
Library originally added 18 Apr 2008 Library originally added 18 Apr 2008
by David A. Mellis by David A. Mellis
library modified 5 Jul 2009 library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net) by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009 example added 9 Jul 2009
by Tom Igoe by Tom Igoe
modified 22 Nov 2010 modified 22 Nov 2010
by Tom Igoe by Tom Igoe
This example code is in the public domain. This example code is in the public domain.
http://arduino.cc/en/Tutorial/LiquidCrystalSetCursor http://arduino.cc/en/Tutorial/LiquidCrystalSetCursor
*/ */
@@ -48,8 +48,8 @@ const int numCols = 16;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() { void setup() {
// set up the LCD's number of columns and rows: // set up the LCD's number of columns and rows:
lcd.begin(numCols,numRows); lcd.begin(numCols, numRows);
} }
void loop() { void loop() {
@@ -60,7 +60,7 @@ void loop() {
// loop over the rows: // loop over the rows:
for (int thisRow = 0; thisRow < numCols; thisRow++) { for (int thisRow = 0; thisRow < numCols; thisRow++) {
// set the cursor position: // set the cursor position:
lcd.setCursor(thisRow,thisCol); lcd.setCursor(thisRow, thisCol);
// print the letter: // print the letter:
lcd.write(thisLetter); lcd.write(thisLetter);
delay(200); delay(200);