Objetivo
El objetivo de este manual es ofrecer la manera de testear el modulo de temperatura Digital KY-028 con nuestro Uno R3.
Materiales necesarios:
- Modulo Sensor de Temperatura Digital KY-028
- Uno R3 + Cable USB para Arduino
- Jumpers Macho-Hembra 20cm
Diagrama de conexión:
SENSOR KY-028 |
ARDUINO UNO R3 |
Pin (+) | 5V |
DO | Pin 3 |
AO | Pin A0 |
Pin (-) | GND (-) |
Codigo utilizado:
// Declaration and initialization of the input pins
int Analog_Eingang = A0; // X-axis-signal
int Digital_Eingang = 3; // Button
void setup ()
{
pinMode (Analog_Eingang, INPUT);
pinMode (Digital_Eingang, INPUT);
Serial.begin (9600); // serial output with 9600 bps
}
// The program reads the current values at the input pins
// and outputs them at the serial output
void loop ()
{
float Analog;
int Digital;
// Current values will be read and converted to voltage
Analog = analogRead (Analog_Eingang) * (5.0 / 1023.0);
Digital = digitalRead (Digital_Eingang);
//... and outputted here
Serial.print ("Analog voltage value:"); Serial.print (Analog, 4); Serial.print ("V, ");
Serial.print ("Extreme value:");
if(Digital==1)
{
Serial.println (" reached");
}
else
{
Serial.println (" not yet reached");
}
Serial.println ("----------------------------------------------------------------");
delay (200);
}