Hola soy muy inexperto en el tema de programación arduino y buscando en internet y en un cd que tenia conseguí dos codigos para poder con uno regular la temperatura (es decir un termostato con lcd basado en el sensor lm 35) y con el otro encender y apagar alternativamente un motor. Todo esto con el fin de construir una pequeña incubadora... despues de un buen rato tratando de unir los dos codigos logre que me lo aceptara el programa arduino y que "funcione" con un error. Este error es que la pantalla parpadea al mismo ritmo que lo haría el motor. Y si modifico los tiempos del motor la pantalla ni siquiera prende.. Que tendría que modificar? aquí dejo los dos códigos originales y el que yo arme.
El que quiero usar para el motor.
//A blinking led
//turn on the LED for half a second,then off for half a second,reaptedly
/************************************************/
int ledPin = 9;//the number of the LED pin
/************************************************/
void setup()
{
pinMode(ledPin,OUTPUT);//initialize the digital pin as an output
}
/************************************************/
//the loop routine runs over and over again forever
void loop()
{
digitalWrite(ledPin,HIGH);//turn the LED on
delay(1000); //wait for half a second
digitalWrite(ledPin,LOW); //turn the LED off
delay(1000); //wait for half a second
}
/*************************************************/
El de el termostato.
[code]////////////////////////////////////////////
// ARDUINO TERMOSTATO CON RELÈ, DISPLAY E LM35
// Autore Fancello Salvatore
// Per maggiori info: http://www.progettiarduino.com
/////////////////////////////////////////////
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int reading = 0;
int sensorPin = A0;
int relay =7;
void setup() {
lcd.begin(16, 2);
pinMode(relay,OUTPUT);
}
void loop() {
reading = analogRead(sensorPin);
int celsius = reading/2;
lcd.setCursor(0, 0);
lcd.print("Temperatura: ");
lcd.setCursor(0,1);
lcd.print(celsius, DEC);
lcd.print((char)223);
lcd.print("C");
if (celsius >28) {
digitalWrite(7,HIGH);
lcd.print(" ON");
} else {
digitalWrite(7,LOW);
lcd.print(" OFF");
}
delay(500);
lcd.clear();
}
Y el que yo hice.
////////////////////////////////////////////
// ARDUINO TERMOSTATO CON RELÈ, DISPLAY E LM35
// Autore Fancello Salvatore
// Per maggiori info: http://www.progettiarduino.com
/////////////////////////////////////////////
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int reading = 0;
int sensorPin = A0;
int relay =7;
int motor = 9;
void setup() {
lcd.begin(16, 2);
pinMode(relay,OUTPUT);
pinMode(motor,OUTPUT);
}
void loop() {
reading = analogRead(sensorPin);
int celsius = reading/2;
lcd.setCursor(0, 0);
lcd.print("Temperatura: ");
lcd.setCursor(0,1);
lcd.print(celsius, DEC);
lcd.print((char)223);
lcd.print("C");
if (celsius <38) {
digitalWrite(7,HIGH);
lcd.print(" O");
} else {
digitalWrite(7,LOW);
lcd.print(" OFF");
delay(500);
}
lcd.clear();
digitalWrite(motor,HIGH);//turn the LED on
delay(500); //wait for half a second
digitalWrite(motor,LOW);
delay(500); //turn the LED off
}
Desde ya muchas gracias!![/code]