Voila, mon premier montage, l'affichage de la temperature sur un LCD et sur le moniteur serie...
Un debut pour ma prochaine station météo...
Des bouts de codes recuperes dans les exemples, sur le net...
Modification apportées en fonction du capteur de temp que j'ai et qui differe de celui de l'exemple, un LCD pas cher et donc peu lisible...
Commentaires bienvenus.
Code :
// 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);
//MCP9701E-TO Pin Variables
int sensorPin = 0; //the analog pin the MCP9701E's Vout (sense) pin is connected to
//the resolution is 19.5 mV / degree centigrade with a
//400 mV offset to allow for negative temperatures
/*
* setup() - this function runs once when you turn your Arduino on
* We initialize the serial connection with the computer
*/
void setup()
{
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Temperature");
Serial.begin(9600); //Start the serial connection with the computer
//to view the result open the serial monitor
}
void loop() // run over and over again
{
//getting the voltage reading from the temperature sensor
int reading = analogRead(sensorPin);
// converting that reading to voltage, for 3.3v arduino use 3.3
float voltage = reading * 5.0;
voltage /= 1024.0;
// print out the voltage
Serial.print(voltage); Serial.println(" volts");
// now print out the temperature
float temperatureC = (voltage - 0.4) * 51; //converting from 19.5 mv per degree with 400 mV offset
//to degrees ((volatge - 400mV) times 100)
Serial.print(temperatureC,1); Serial.println(" degres C");
// set the cursor to column 0, line 1
// (note: line 1 is the second row
lcd.setCursor(0, 1);
// print the Temperature:
lcd.print(temperatureC,1);
delay(5000); //waiting 5 seconds
Voila, mon premier montage, l'affichage de la temperature sur un LCD et sur le moniteur serie...
Un debut pour ma prochaine station météo...
Des bouts de codes recuperes dans les exemples, sur le net...
Modification apportées en fonction du capteur de temp que j'ai et qui differe de celui de l'exemple, un LCD pas cher et donc peu lisible...
Commentaires bienvenus.
Code :
// 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);
//MCP9701E-TO Pin Variables
int sensorPin = 0; //the analog pin the MCP9701E's Vout (sense) pin is connected to
//the resolution is 19.5 mV / degree centigrade with a
//400 mV offset to allow for negative temperatures
/*
* setup() - this function runs once when you turn your Arduino on
* We initialize the serial connection with the computer
*/
void setup()
{
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Temperature");
Serial.begin(9600); //Start the serial connection with the computer
//to view the result open the serial monitor
}
void loop() // run over and over again
{
//getting the voltage reading from the temperature sensor
int reading = analogRead(sensorPin);
// converting that reading to voltage, for 3.3v arduino use 3.3
float voltage = reading * 5.0;
voltage /= 1024.0;
// print out the voltage
Serial.print(voltage); Serial.println(" volts");
// now print out the temperature
float temperatureC = (voltage - 0.4) * 51; //converting from 19.5 mv per degree with 400 mV offset
//to degrees ((volatge - 400mV) times 100)
Serial.print(temperatureC,1); Serial.println(" degres C");
// set the cursor to column 0, line 1
// (note: line 1 is the second row
lcd.setCursor(0, 1);
// print the Temperature:
lcd.print(temperatureC,1);
delay(5000); //waiting 5 seconds
Félicitation pour ton premier montage.
Tu dis, LCD peu lisible. Sur ta photo, on dirait que le "backlight" n'est pas en fonction.
Est ce le cas?
Bonne question pour le backlight... aucune idée en fait... j'ai juste un potentiometre 10k pour regler le texte, mais le backlight je ne sais pas. Peut etre une histoire de jumper au dos, j'ai vu ca dans le datasheet, mais ne sachant pas dans quoi je me lancais, je n'y ai pas touché. Une aide de ton côté ?