#include <LiquidCrystal.
h> // include LCD library code
#define DS18B20_PIN 10
// LCD module connections (RS, E, D4, D5, D6, D7)
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
//VARIABLE DU DS18B20
int raw_temp;
float temp;
char txt[] = " C ";
// Définir la broche analogique utilisée du LM35
const int LM35_PIN = A0;
int analogValue = 0; // Variable pour stocker la valeur lue
float temperatureC = 0; // Variable pour stocker la température en degrés
Celsius
//declaration des leds
const int rouge = 11;
const int orange = 12;
const int vert= 13;
//declaration buzzer
const int buzzer = 0;
void setup(void) {
// start serial port
[Link](9600);
[Link](16, 2);
txt[0] = 223; // Put degree symbol (°)
[Link](1, 0);
[Link]("Projet GROUPE 4");
[Link](4, 1);
[Link]("BTMS");
delay(200);
pinMode(rouge,OUTPUT);
pinMode(vert,OUTPUT);
pinMode(orange,OUTPUT);
pinMode(buzzer,OUTPUT);
[Link]();
void loop(void) {
temp_bb();
if(ds18b20_read(&raw_temp)) {
temp = (float)raw_temp / 16; // Convert temperature raw value into
degree Celsius (temp in °C = raw/16)
// Display temperature on LCD
if(temp >= 36 && 37 > temp){
[Link]();
[Link](0,0);
[Link]("La temperature");
[Link](0,1);
[Link]("est normale");
digitalWrite(vert,HIGH);
delay(500);
digitalWrite(vert,LOW);
delay(200);
else if(temp >= 35 && 36 > temp){
[Link]();
[Link](0,0);
[Link]("Low-grade");
[Link](0,1);
[Link]("temp Inf");
digitalWrite(orange,HIGH);
delay(500);
digitalWrite(orange,LOW);
delay(200);
else if(temp >= 37 && 37.5 > temp){
[Link]();
[Link](0,0);
[Link]("Low-grade");
[Link](0,1);
[Link]("temperature");
digitalWrite(orange,HIGH);
delay(500);
digitalWrite(orange,LOW);
delay(200);
else if(temp >= 37.5 && 38 > temp){
[Link]();
[Link](0,0);
[Link]("Elevated");
[Link](0,1);
[Link]("temperature");
digitalWrite(orange,HIGH);
delay(500);
digitalWrite(orange,LOW);
delay(200);
else if(temp >= 38 && 38.5 > temp){
[Link]();
[Link](0,0);
[Link]("Fever");
digitalWrite(orange,HIGH);
delay(500);
digitalWrite(orange,LOW);
delay(200);
else if(temp >= 38.5 && 39 > temp){
[Link]();
[Link](0,0);
[Link]("A very high");
[Link](0,1);
[Link]("temperature");
digitalWrite(orange,HIGH);
delay(500);
digitalWrite(orange,LOW);
delay(200);
else{
[Link]();
[Link](0,0);
[Link]("Extremly high");
[Link](0,1);
[Link]("temperature");
digitalWrite(rouge,HIGH);
digitalWrite(buzzer,HIGH);
delay(5000);
digitalWrite(rouge,LOW);
digitalWrite(buzzer,HIGH);
delay(200);
else {
[Link]("Communication Error!");
[Link](4, 1);
[Link](" Error! ");
delay(1000);
/
***************************************************************************
********/
/***************************************LM
35**************************************/
/
***************************************************************************
*******/
void temp_bb(){
// Lire la valeur analogique (0 à 1023)
analogValue = analogRead(LM35_PIN);
[Link]();
// Convertir la valeur analogique en tension
// Supposons que la référence est 5V
float voltage = (analogValue * 5) / 1023;
// Convertir la tension en température (LM35 : 10 mV/°C)
temperatureC = voltage * 100.0;
// Afficher la température sur le moniteur série
[Link](0,0);
[Link]("Température: ");
[Link](0,1);
[Link](temperatureC);
[Link]("C");
// Attendre 1 seconde avant la prochaine lecture
delay(1000);
/
***************************************************************************
********/
/
**************************************MUSIQUE****************************
*********/
/
***************************************************************************
*******/
/
***************************************************************************
********/
/************************************CAPTEUR
DS18B20*******************************/
/
***************************************************************************
*******/
//Verifier si le capteur est present
bool ds18b20_start(){
bool ret = 0;
digitalWrite(DS18B20_PIN, LOW); // Send reset pulse to the DS18B20
sensor
pinMode(DS18B20_PIN, OUTPUT);
delayMicroseconds(500); // Wait 500 us
pinMode(DS18B20_PIN, INPUT);
delayMicroseconds(100); //wait to read the DS18B20 sensor
response
if (!digitalRead(DS18B20_PIN)) {
ret = 1; // DS18B20 sensor is present
delayMicroseconds(400); // Wait 400 us
return(ret);
void ds18b20_write_bit(bool value){
digitalWrite(DS18B20_PIN, LOW);
pinMode(DS18B20_PIN, OUTPUT);
delayMicroseconds(2);
digitalWrite(DS18B20_PIN, value);
delayMicroseconds(80);
pinMode(DS18B20_PIN, INPUT);
delayMicroseconds(2);
void ds18b20_write_byte(byte value){
byte i;
for(i = 0; i < 8; i++)
ds18b20_write_bit(bitRead(value, i));
bool ds18b20_read_bit(void) {
bool value;
digitalWrite(DS18B20_PIN, LOW);
pinMode(DS18B20_PIN, OUTPUT);
delayMicroseconds(2);
pinMode(DS18B20_PIN, INPUT);
delayMicroseconds(5);
value = digitalRead(DS18B20_PIN);
delayMicroseconds(100);
return value;
byte ds18b20_read_byte(void) {
byte i, value;
for(i = 0; i <8; i++)
bitWrite(value, i, ds18b20_read_bit());
return value;
}
bool ds18b20_read(int *raw_temp_value) {
if (!ds18b20_start()) // Send start pulse
return(0); // Return 0 if error
ds18b20_write_byte(0xCC); // Send skip ROM command
ds18b20_write_byte(0x44); // Send start conversion command
while(ds18b20_read_byte() == 0); // Wait for conversion complete
if (!ds18b20_start()) // Send start pulse
return(0); // Return 0 if error
ds18b20_write_byte(0xCC); // Send skip ROM command
ds18b20_write_byte(0xBE); // Send read command
*raw_temp_value = ds18b20_read_byte(); // Read temperature LSB
byte and store it on raw_temp_value LSB byte
*raw_temp_value |= (unsigned int)(ds18b20_read_byte() << 8); //
Read temperature MSB byte and store it on raw_temp_value MSB byte
return(1); // OK --> return 1