Created
December 24, 2013 05:27
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int sensor = 0; // entrada del sensor analogico | |
const int ledRojo = 11; //LED rojo | |
const int ledAzul = 10; //LED azul | |
long miliVolts; | |
long temperatura; | |
int brillo; | |
void setup() { | |
Serial.begin(9600); //iniciamos la comunicacion serial | |
pinMode(ledRojo,OUTPUT); | |
pinMode(ledAzul,OUTPUT); | |
} | |
void loop (){ | |
miliVolts = (analogRead(sensor)*5000L) / 1023; //calculamos los mV en la entrada | |
temperatura = (miliVolts / 10)-273.15; // calculamos la temperatura del sensor | |
brillo = map(temperatura,10, 40, 0, 255); //Ajustamos la escala de temperatura para poder usar analogRead | |
brillo = constrain(brillo, 0,255); //Limitar el rango de brillo de 0 a 255; | |
analogWrite(ledRojo, brillo); | |
analogWrite(ledAzul, 255 - brillo); //Ajustamos el color del LED | |
Serial.print ("Temperatura: "); //Enviamos la temperatura por | |
Serial.print (temperatura); //puerto serial | |
Serial.println(" grados"); | |
delay(200); ////Esperamos para no saturar el monitor | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment