Termómetro corporal con semáforo y contador de personas

hola espero me puedan ayudar les explico un poco el funcionamiento, el termómetro debe tomar la temperatura corporal y debe ser activado con un sensor para que cuando el sensor lo detecte tome la temperatura y ala vez cuente alas personas que tomen su temperatura a su vez debe estar reflejado tanto la temperatura como el contador en un lcd 16x2, y también debe encender 3 leds de color verde para indicar que la temperatura es normal, naranja para indicar que esta un poco elevada o moderado, rojo para indicar que tiene fiebre
prácticamente no realiza nada ya que no toma la temperatura correctamente y no detecta ala persona les adjunto el programa

[quote="cowboydaniel, post:1, topic:978681, full:true"]
I am brand new to Arduino (its great though!).
I am making a rfid activated relay that has a buzzer and an I2C LCD, and I haven't found anyone else who had the perfect thing already made.
I have merged two different codes that I DID find to create this (it is a bit of a mess, but at least it works most of the time):

#include <LiquidCrystal.h>
//pantalla lcd//
LiquidCrystal lcd(12, 13, 5, 4, 3, 2);
int contador=0;
int contrastPin = 6; //Pin que identifica el pin donde esta conectado el puerto de contraste del LCD
int tiempo=0;
int distancia=0;
int Buzzer=7;
int contrastValue= 1; // Valor del contraste en la Pantalla (5-20)
#define trig 7 // Emisor de pulso o señal

#define echo 6 // Receptor "del eco" del pulso o señal

#define buzzer 8 //Zumbador

//Sensor Temperatura//
int umbralTemp = 35; //Nuestro valor umbral seran 35 grados centigrados
float sensorTemp = 0.0; //Lectura del sensor en valores decimales
int sensorPin = A0; //Configuracion del Pin de lectura del sensor de T
int temp = 35; //Lectura del sensor en valores enteros

//LED RGB//

int RojoLed = 9;
int VerdeLed = 10;
int NaranjaLed = 11;

void setup() {
lcd.print("TERMOMETRO"); // Imprime "PROYECTO YOUTUBE" sobre el LCD
delay(1000); // Espera 1 segundo lcd.setCursor(0,1);
lcd.clear(); // Limpia la pantalla
delay(1500);
lcd.print("CBTIS 260");// Seteamos la ubicacion texto 0 linea 1 que sera escrita sobre el LCD
delay(1500);
lcd.clear(); // Limpia la pantalla
delay(300);
//Puerto Serial//
//Puerto serial para hacer display del sensor de Temperatura
Serial.begin(9600);
//buzzer//
// Sólo se activa una vez al iniciarse el programa. Definimos entradas y salidas

pinMode(trig, OUTPUT); //Emisor

pinMode(echo, INPUT); //Receptor

pinMode(buzzer, OUTPUT); //Emisor
//Pantalla LCD//

pinMode(contrastPin,OUTPUT); //El pin contrast (LCD) debe estar configurado como salida
//Seteo numero de filas y columnas:
lcd.begin(16, 2);
// Imprimo mensaje en el LCD.
lcd.print("Temperatura: ");
lcd.begin(1, 1);
lcd.print(" ");
//LED RGB//
pinMode(RojoLed, OUTPUT);
pinMode(NaranjaLed, OUTPUT);
pinMode(VerdeLed, OUTPUT);
}

void loop() {

//Sensor de Temperatura//
int lectura = analogRead(sensorPin);

float voltaje = 8.0 /1023 * lectura ;
float temp = voltaje * 100 ;
float sensorTemp = voltaje * 100 -50 ;
Serial.print(sensorTemp);
Serial.print(" ; ");
temp = (int)sensorTemp;
Serial.println(temp);
//delay(100);

//LED//
if (temp > 45)
{
digitalWrite(RojoLed, HIGH);
digitalWrite(VerdeLed, LOW);
digitalWrite(NaranjaLed, LOW);
digitalWrite(trig, LOW); //Para tener un pulso limpio empezamos con 2 microsegundos en apagado
delay(2);
digitalWrite(trig, HIGH); //Mandamos un pulso de 5 microsegundos
}

else if (temp >=36 && temp<=45 )
{
digitalWrite(VerdeLed, HIGH);
digitalWrite(RojoLed, LOW);
digitalWrite(NaranjaLed, LOW);
digitalWrite(trig, LOW); //Para tener un pulso limpio empezamos con 2 microsegundos en apagado
delay(2);
digitalWrite(trig, HIGH); //Mandamos un pulso de 5 microsegundos
}
else if (temp < 38 )
{
digitalWrite(NaranjaLed, HIGH);
digitalWrite(RojoLed, LOW);
digitalWrite(VerdeLed, LOW);
digitalWrite(trig, LOW); //Para tener un pulso limpio empezamos con 2 microsegundos en apagado
delay(2);
digitalWrite(trig, HIGH); //Mandamos un pulso de 5 microsegundos
}

//Pantalla LCD//
//Seteo el contraste
analogWrite(contrastPin, contrastValue); //El pin contrast (LCD) se setea por valor analogico (5-20)
// Seteo el cursor a columna 0, linea 1
// (nota: linea 1 is la segunda fila, la primera fila es la 0):
lcd.setCursor(6, 1);

lcd.print(temp);

if (temp >= 100)
{
lcd.setCursor(9, 1); // Posiciona el cursor para escribir
lcd.print("C");//Simbolo de Centigrados
}
else if ((temp >= 0)&&(temp < 10))
{
lcd.setCursor(8, 1); //Borra los espacios que no se usan
lcd.print(" ");
lcd.setCursor(7, 1); //Ubica el simbolo de centigrados
lcd.print("C");
}
else if ((temp >= -9)&&(temp < 0))
{
lcd.setCursor(9, 1); //Borra los espacios que no se usan
lcd.print(" ");
lcd.setCursor(8, 1); //Ubica el simbolo de centigrados
lcd.print("C");
}
else if (temp < -10)
{
lcd.setCursor(9, 1); //Ubica el simbolo de centigrados
lcd.print("C");
}
else
{
lcd.setCursor(9, 1);
lcd.print(" ");
lcd.setCursor(8, 1);
lcd.print("C");
}

delay(500);

//buzzer//
// Bucle
digitalWrite(trig,LOW);
delay(2);
digitalWrite(trig,HIGH);
delay(10);
digitalWrite(trig,LOW);
tiempo=pulseIn(echo,HIGH);
distancia=(tiempo/2)/29;
// Serial.println(distancia);
if(distancia<9){
digitalWrite(VerdeLed,HIGH);
digitalWrite(Buzzer,HIGH);
delay(100);
digitalWrite(Buzzer,LOW);
}else{
digitalWrite(VerdeLed,LOW);
contador=contador;
digitalWrite(Buzzer,LOW);
}
if(digitalRead(VerdeLed)==HIGH)
{
contador++;
delay(300);

}
if(contador>10){
contador=0;
lcd.clear();
}

Serial.println(contador);
Serial.print(" ");
Serial.print(distancia);
Serial.print(" ");
lcd.setCursor(7,1);
lcd.print("cont");
lcd.setCursor(10,1);
lcd.print("pers: ");
lcd.print(contador);
}

You may find this easier if you use a I2C LCD instead of a normal one.
This is the I2C LCD I used I2C LCD LINK
I have reworked your code for an I2C LCD and it works perfectly for me. I have included the reworked code below. You may have to change it to Spanish again as I wrote it in English so I could understand it.

#include <LiquidCrystal_I2C.h>
//LCD screen//
LiquidCrystal_I2C lcd(0x27, 16,2);
int counter=0;
int contrastPin = 6; //Pin that identifies the pin where the LCD contrast port is connected
int time=0;
int distance=0;
int Buzzer=7;
int contrastValue= 1; // Contrast value on the Screen (5-20)
#define trig 7 // Pulse or signal emitter

#define echo 6 // Receiver "of the echo" of the pulse or signal

#define buzzer 8 //Buzzer

//Temperature sensor//
int tempthreshold = 35; // Our threshold value will be 35 degrees centigrade
float sensorTemp = 0.0; //Sensor reading in decimal values
int sensorPin = A0; //Configuration of the T sensor reading Pin
int temp = 35; //Sensor reading in integer values

//RGB LEDs//
int RedLed = 9;
int GreenLed = 10;
int OrangeLed = 11;

void setup() {
lcd.init();
lcd.clear();
lcd.backlight();
lcd.print("  THERMOMETER"); // Print "YOUTUBE PROJECT" on the LCD
delay(1000); // Wait 1 second lcd.setCursor(0,1);
lcd.clear(); // clear the screen
delay(1500);
lcd.print("   CBTIS 260");// We set the location text 0 line 1 that will be written on the LCD
delay(1500);
lcd.clear(); // clear the screen
delay(300);
//Serial Port//
// Serial port to display the temperature sensor
Serial.begin(9600);
//buzzer//
// It is only activated once when the program starts. We define inputs and outputs

pinMode(trig, OUTPUT); //Transmitter

pinMode(echo, INPUT); //Receiver

pinMode(buzzer, OUTPUT); //Transmitter
//LCD screen//

// Print message on LCD.
lcd.print("Temperature: ");
lcd.print(" ");
//RGB LEDs//
pinMode(RedLed, OUTPUT);
pinMode(OrangeLed, OUTPUT);
pinMode(GreenLed, OUTPUT);
}

void loop() {

//Temperature sensor//
int read = analogRead(sensorPin);
float voltage = 8.0 /1023 * temp ;
float temp = voltage * 100 ;
float sensorTemp = voltage * 100 -50 ;
Serial.print(sensorTemp);
Serial.print(" ; ");
temp = (int)sensorTemp;
Serial.println(temp);
//delay(100);

//LED//
if (temp > 45)
{
digitalWrite(RedLed, HIGH);
digitalWrite(GreenLed, LOW);
digitalWrite(OrangeLed, LOW);
digitalWrite(trig, LOW); //To have a clean pulse we start with 2 microseconds off
delay(2);
digitalWrite(trig, HIGH); // We send a pulse of 5 microseconds
}

else if (temp >=36 && temp<=45 )
{
digitalWrite(GreenLed, HIGH);
digitalWrite(RedLed, LOW);
digitalWrite(OrangeLed, LOW);
digitalWrite(trig, LOW); //To have a clean pulse we start with 2 microseconds off
delay(2);
digitalWrite(trig, HIGH); // We send a pulse of 5 microseconds
}
else if (temp < 38 )
{
digitalWrite(OrangeLed, HIGH);
digitalWrite(RedLed, LOW);
digitalWrite(GreenLed, LOW);
digitalWrite(trig, LOW); //To have a clean pulse we start with 2 microseconds off
delay(2);
digitalWrite(trig, HIGH); // We send a pulse of 5 microseconds
}

//LCD screen//
//Set the contrast
analogWrite(contrastPin, contrastValue); //The contrast pin (LCD) is set by analog value (5-20)
// Set the cursor to column 0, line 1
// (note: line 1 is the second row, the first row is 0):
lcd.setCursor(6, 1);

lcd.print(temp);

if (temp >= 100)
{
lcd.setCursor(9, 1); // Position the cursor to write
lcd.print("C");//Celsius symbol
}
else if ((temp >= 0)&&(temp < 10))
{
lcd.setCursor(8, 1); //Delete unused spaces
lcd.print(" ");
lcd.setCursor(7, 1); // Locate the centigrade symbol
lcd.print("C");
}
else if ((temp >= -9)&&(temp < 0))
{
lcd.setCursor(9, 1); //Delete unused spaces
lcd.print(" ");
lcd.setCursor(8, 1); // Locate the centigrade symbol
lcd.print("C");
}
else if (temp < -10)
{
lcd.setCursor(9, 1); // Locate the centigrade symbol
lcd.print("C");
}
else
{
lcd.setCursor(9, 1);
lcd.print(" ");
lcd.setCursor(8, 1);
lcd.print("C");
}

delay(500);

//buzzer//
// Loop
digitalWrite(trig,LOW);
delay(2);
digitalWrite(trig,HIGH);
delay(10);
digitalWrite(trig,LOW);
time=pulseIn(echo,HIGH);
distance=(time/2)/29;
// Serial.println(distance);
if(distance<9){
digitalWrite(GreenLed,HIGH);
digitalWrite(Buzzer,HIGH);
delay(100);
digitalWrite(Buzzer,LOW);
}else{
digitalWrite(GreenLed,LOW);
counter=counter;
digitalWrite(Buzzer,LOW);
}
if(digitalRead(GreenLed)==HIGH)
{
counter++;
delay(300);

}
if(counter>10){
counter=0;
lcd.clear();
}

Serial.println(counter);
Serial.print(" ");
Serial.print(distance);
Serial.print(" ");
lcd.setCursor(7,1);
lcd.print("cont");
lcd.setCursor(10,1);
lcd.print("pers: ");
lcd.print(counter);
}

Let me know if this works for you!

1 Like

Moderador:
Por favor, lee las Normas del foro y edita tu código/error usando etiquetas de código.
Ve a edición, luego selecciona todo el código que has publicado, lo cortas y click en </>


Observa como luce la respuesta de quien te respondió. Asi debe lucer tu código o los errores cuando muestras alguno de éstos.

Gracias

1 Like

Did it work for you?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.