Acabo de realizar un shield para mi LCD debido a que llego un momento en que era incomodo tener que enchufar los 10 cables cada vez que necesitase usar el LCD.
Mi shield esta basado en este link:
Y aqui el resultado final:
![]() |
| Source: http://www.flickr.com/photos/sctv/3138287688/#/ |
| Source: http://luckylarry.co.uk |
#include//Libreria para el sensor #include //Libreria para el sensor #include //Libreria para el LCD // Conectamos el sensor de temperatura al pin 10 de Arduino #define ONE_WIRE_BUS 10 // Setup de oneWire instance para que se comunique con dispositivos OneWire OneWire oneWire(ONE_WIRE_BUS); // Pasomos la referencia de oneWire a Dallas Temperature. DallasTemperature sensors(&oneWire); //Iniciamos la libreria del LCD con los respectivos pines LiquidCrystal lcd(12, 11, 5, 4, 3, 2); const int ledPin = 13; // Pin al que esta conectado el led void setup(void) { //Setup de las lineas y columnas. lcd.begin(16, 2); //Escribimos Temperatura en el LCD. lcd.print("Temperatura:"); // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // start serial port Serial.begin(9600); Serial.println("Control de Temperatura"); // Start up the library sensors.begin(); } float val = 0; // Importate usar el float para obtener la temperatura en formato ºC y NN,NN void loop(void) { // call sensors.requestTemperatures() to issue a global temperature // request to all devices on the bus Serial.print("Requesting ..."); sensors.requestTemperatures(); // Send the command to get temperatures Serial.println("DONE"); Serial.print("Temperatura es "); Serial.print(sensors.getTempCByIndex(0)) ; // Why "byIndex"? You can have more than one IC on the same bus. 0 refers to the first IC on the wire Serial.print(" "); float val = sensors.getTempCByIndex(0) ; // Almacenar la temperatura //Serial.println(val); // print the value to // the serial port // 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(val); if (val >= 22) { // turn LED on: digitalWrite(ledPin, HIGH); } else { // turn LED off: digitalWrite(ledPin, LOW); } delay(4000); // wait for 4 second }