Convert library examples

This commit is contained in:
2016-08-28 21:30:18 +01:00
parent 768ab1254d
commit 8c441b7ccd
11 changed files with 177 additions and 176 deletions

View File

@@ -1,74 +1,74 @@
/*
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 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/LiquidCrystalAutoscroll
*/
// include the library code:
#include <LiquidCrystal.h>
// 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);
}
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();
}
/*
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 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/LiquidCrystalAutoscroll
*/
// include the library code:
#include <Arduino.h>
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
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();
}

View File

@@ -37,10 +37,11 @@
*/
// include the library code:
#include <Arduino.h>
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup() {
// set up the LCD's number of columns and rows:

View File

@@ -38,10 +38,11 @@
*/
// include the library code:
#include <Arduino.h>
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup() {
// set up the LCD's number of columns and rows:
@@ -57,5 +58,4 @@ void loop() {
// Turn on the cursor:
lcd.cursor();
delay(500);
}
}

View File

@@ -39,10 +39,11 @@
*/
// include the library code:
#include <Arduino.h>
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
// make some custom characters:
byte heart[8] = {
@@ -137,4 +138,4 @@ void loop() {
// draw him arms up:
lcd.write(4);
delay(delayTime);
}
}

View File

@@ -38,10 +38,11 @@
*/
// include the library code:
#include <Arduino.h>
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup() {
// set up the LCD's number of columns and rows:
@@ -57,5 +58,4 @@ void loop() {
// Turn on the display:
lcd.display();
delay(500);
}
}

View File

@@ -38,10 +38,11 @@
*/
// include the library code:
#include <Arduino.h>
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup() {
// set up the LCD's number of columns and rows:
@@ -56,5 +57,4 @@ void loop() {
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis() / 1000);
}
}

View File

@@ -38,10 +38,11 @@
*/
// include the library code:
#include <Arduino.h>
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup() {
// set up the LCD's number of columns and rows:
@@ -81,6 +82,4 @@ void loop() {
// delay at the end of the full loop:
delay(1000);
}
}

View File

@@ -36,10 +36,11 @@
*/
// include the library code:
#include <Arduino.h>
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup() {
// set up the LCD's number of columns and rows:
@@ -61,4 +62,4 @@ void loop() {
lcd.write(Serial.read());
}
}
}
}

View File

@@ -37,6 +37,7 @@
*/
// include the library code:
#include <Arduino.h>
#include <LiquidCrystal.h>
// these constants won't change. But you can change the size of
@@ -45,7 +46,7 @@ const int numRows = 2;
const int numCols = 16;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup() {
// set up the LCD's number of columns and rows:
@@ -67,6 +68,4 @@ void loop() {
}
}
}
}
}

View File

@@ -37,10 +37,11 @@ http://www.arduino.cc/en/Tutorial/LiquidCrystalTextDirection
*/
// include the library code:
#include <Arduino.h>
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int thisChar = 'a';

View File

@@ -1,80 +1,79 @@
#include "Arduino.h"
extern "C" {
#include "pb_decode.h"
#include "pb_encode.h"
#include "lcdkeypad.pb.h"
}
#include <LiquidCrystal.h>
// Select the pins used on the LCD panel
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
// Define some values used by the panel and buttons
int lcd_key = 0;
int adc_key_in = 0;
#define btnRIGHT 0
#define btnUP 1
#define btnDOWN 2
#define btnLEFT 3
#define btnSELECT 4
#define btnNONE 5
// Read the buttons
int read_LCD_buttons() {
// Read the value from the sensor
adc_key_in = analogRead(0);
// Map buttons (v1.0 hardware)
if (adc_key_in > 1000) return btnNONE;
if (adc_key_in < 50) return btnRIGHT;
if (adc_key_in < 195) return btnUP;
if (adc_key_in < 380) return btnDOWN;
if (adc_key_in < 555) return btnLEFT;
if (adc_key_in < 790) return btnSELECT;
return btnNONE; // when all others fail, return this...
}
void setup() {
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("Push the buttons");
}
void loop() {
// Move cursor to second line "1" and 9 spaces over
lcd.setCursor(9, 1);
// Display seconds elapsed since power-up
lcd.print(millis()/1000);
// Move to the start of the second line
lcd.setCursor(0, 1);
// Read the buttons
lcd_key = read_LCD_buttons();
// Print button status
switch (lcd_key) {
case btnRIGHT:
lcd.print("RIGHT ");
break;
case btnLEFT:
lcd.print("LEFT ");
break;
case btnUP:
lcd.print("UP ");
break;
case btnDOWN:
lcd.print("DOWN ");
break;
case btnSELECT:
lcd.print("SELECT");
break;
case btnNONE:
lcd.print("NONE ");
break;
}
#include <Arduino.h>
#include <LiquidCrystal.h>
extern "C" {
#include "pb_decode.h"
#include "pb_encode.h"
#include "lcdkeypad.pb.h"
}
// Select the pins used on the LCD panel
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
// Define some values used by the panel and buttons
int lcd_key = 0;
int adc_key_in = 0;
#define btnRIGHT 0
#define btnUP 1
#define btnDOWN 2
#define btnLEFT 3
#define btnSELECT 4
#define btnNONE 5
// Read the buttons
int read_LCD_buttons() {
// Read the value from the sensor
adc_key_in = analogRead(0);
// Map buttons (v1.0 hardware)
if (adc_key_in > 1000) return btnNONE;
if (adc_key_in < 50) return btnRIGHT;
if (adc_key_in < 195) return btnUP;
if (adc_key_in < 380) return btnDOWN;
if (adc_key_in < 555) return btnLEFT;
if (adc_key_in < 790) return btnSELECT;
return btnNONE; // when all others fail, return this...
}
void setup() {
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("Push the buttons");
}
void loop() {
// Move cursor to second line "1" and 9 spaces over
lcd.setCursor(9, 1);
// Display seconds elapsed since power-up
lcd.print(millis()/1000);
// Move to the start of the second line
lcd.setCursor(0, 1);
// Read the buttons
lcd_key = read_LCD_buttons();
// Print button status
switch (lcd_key) {
case btnRIGHT:
lcd.print("RIGHT ");
break;
case btnLEFT:
lcd.print("LEFT ");
break;
case btnUP:
lcd.print("UP ");
break;
case btnDOWN:
lcd.print("DOWN ");
break;
case btnSELECT:
lcd.print("SELECT");
break;
case btnNONE:
lcd.print("NONE ");
break;
}
}