Kilian Esteban Tafur Guerrero
sensor de temperatura
explicación
programación
int tempC;
int unidad;
int decena;
float Temperatura;
float ValSen;
void apagar()
{
digitalWrite(A1, LOW);
digitalWrite(A2, LOW);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
}
void cerou()
{
digitalWrite(A1, HIGH);
digitalWrite(A2, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
return;
}
void oneu()
{
digitalWrite(A1, LOW);
digitalWrite(A2, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
return;
}
void twou()
{
digitalWrite(A1, HIGH);
digitalWrite(A2, HIGH);
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
return;
}
void threeu()
{
digitalWrite(A1, HIGH);
digitalWrite(A2, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
return;
}
void fouru()
{
digitalWrite(A1, LOW);
digitalWrite(A2, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
return;
}
void fiveu()
{
digitalWrite(A1, HIGH);
digitalWrite(A2, LOW);
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
return;
}
void sixu()
{
digitalWrite(A1, HIGH);
digitalWrite(A2, LOW);
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
return;
}
void sevenu()
{
digitalWrite(A1, HIGH);
digitalWrite(A2, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
return;
}
void eighu()
{
digitalWrite(A1, HIGH);
digitalWrite(A2, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
return;
}
void nineu()
{
digitalWrite(A1, HIGH);
digitalWrite(A2, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
return;
}
void cerod()
{
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);
digitalWrite(12, HIGH);
digitalWrite(13, LOW);
return;
}
void oned()
{
digitalWrite(7, LOW);
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
return;
}
void twod()
{
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
digitalWrite(9, LOW);
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);
digitalWrite(12, LOW);
digitalWrite(13, HIGH);
return;
}
void threed()
{
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, HIGH);
return;
}
void fourd()
{
digitalWrite(7, LOW);
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
digitalWrite(12, HIGH);
digitalWrite(13, HIGH);
return;
}
void fived()
{
digitalWrite(7, HIGH);
digitalWrite(8, LOW);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, LOW);
digitalWrite(12, HIGH);
digitalWrite(13, HIGH);
return;
}
void sixd()
{
digitalWrite(7, HIGH);
digitalWrite(8, LOW);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);
digitalWrite(12, HIGH);
digitalWrite(13, HIGH);
return;
}
void sevend()
{
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
return;
}
void eighd()
{
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);
digitalWrite(12, HIGH);
digitalWrite(13, HIGH);
return;
}
void nined()
{
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, HIGH);
return;
}
void setup()
{
pinMode (A0, INPUT);
Serial.begin (9600);
pinMode (A1,OUTPUT);
pinMode (A2,OUTPUT);
pinMode (2,OUTPUT);
pinMode (3,OUTPUT);
pinMode (4,OUTPUT);
pinMode (5,OUTPUT);
pinMode (6,OUTPUT);
pinMode (7,OUTPUT);
pinMode (8,OUTPUT);
pinMode (9,OUTPUT);
pinMode (10,OUTPUT);
pinMode (11,OUTPUT);
pinMode (12,OUTPUT);
pinMode (13,OUTPUT);
apagar();
}
void loop ()
{
ValSen = analogRead (A0);
Temperatura = (ValSen * 5.0 * 100.0) / 1023.0;
tempC = Temperatura;
decena = tempC/10;
unidad = tempC%10;
Serial.println(Temperatura);
Serial.println(tempC);
Serial.println(unidad);
Serial.println(decena);
delay(1000);
if(unidad == 0)
cerou();
if(unidad == 1)
oneu();
if(unidad == 2)
twou();
if(unidad == 3)
threeu();
if(unidad == 4)
fouru();
if(unidad == 5)
fiveu();
if(unidad == 6)
sixu();
if(unidad == 7)
sevenu();
if(unidad == 8)
eighu();
if(unidad == 9)
nineu();
if(decena == 0)
cerod();
if(decena == 1)
oned();
if(decena == 2)
twod();
if(decena == 3)
threed();
if(decena == 4)
fourd();
if(decena == 5)
fived();
if(decena == 6)
sixd();
if(decena == 7)
sevend();
if(decena == 8)
eighd();
if(decena == 9)
nined();
delay(1000);
}
objetivo
el objetivo del proyecto es que con un sensor de temperatura(LM35) mande una información al arduino y se embie a los dos display 7 segmentos para mostrar la lectura del sensor de temperatura (LM35).