Skip to content

Commit

Permalink
initial implementation of lcd display code
Browse files Browse the repository at this point in the history
  • Loading branch information
will vuong committed Jun 26, 2012
1 parent 4a4b0e4 commit 39b1284
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 19 deletions.
79 changes: 79 additions & 0 deletions Autoscroll/Autoscroll.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
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://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);
int backLight = 13; // pin 13 will control the backlight

void setup() {
// set up backlight
pinMode(backLight, OUTPUT);
digitalWrite(backLight, HIGH); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.

// 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();
}

50 changes: 31 additions & 19 deletions bbqsmoker.ino
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
/*
Analog input, analog output, serial output
Reads an analog input pin, maps the result to a range from 0 to 255
and uses the result to set the pulsewidth modulation (PWM) of an output pin.
Also prints the results to the serial monitor.
The circuit:
* potentiometer connected to analog pin 0.
Center pin of the potentiometer goes to the analog pin.
side pins of the potentiometer go to +5V and ground
* LED connected from digital pin 9 to ground
created 29 Dec. 2008
modified 9 Apr 2012
by Tom Igoe
This example code is in the public domain.
Based on the "Analog input, analog output, serial output" example sketch.
This program reads from Maverick probes via analog A0 pin and writes the observed temperature
value to the LCD.
*/

// include the library code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int backLight = 13; // pin 13 will control the backlight

// These constants won't change. They're used to give names
// to the pins used:
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
const int analogInPin = A0; // Analog input pin that the probe is attached to

int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)
String stringValue = "";

void setup() {
// set up backlight
pinMode(backLight, OUTPUT);
digitalWrite(backLight, HIGH); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.
lcd.begin(16,2);

// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
Expand All @@ -44,6 +41,21 @@ void loop() {
Serial.print("\t output = ");
Serial.println(outputValue);

if (sensorValue == 0 || sensorValue == 1023) {
stringValue = "No signal";
}
else {
stringValue = outputValue + "°";
}

lcd.clear(); // start with a blank screen
lcd.setCursor(0,0); // set cursor to column 0, row 0 (the first row)
lcd.print("Current temp:"); // change this text to whatever you like. keep it clean.
lcd.setCursor(0,1); // set cursor to column 0, row 1
lcd.print(stringValue);
lcd.noAutoscroll();


// wait 2 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
Expand All @@ -70,4 +82,4 @@ int thermister_temp(int aval) {
T = (1 / ((2.3067434E-4) + (2.3696596E-4) * R + (1.2636414E-7) * R * R * R)) - 273.25;
// return degrees F
return ((int) ((T * 9.0) / 5.0 + 32.0));
}
}

0 comments on commit 39b1284

Please sign in to comment.