Abzod Robot

14:59 PM 26 Aug, 2018
  • 0
  • 0
  • 0

This robot will measure the temperature in your body, and display it on LCD.

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <OneWire.h>
#include <DallasTemperature.h> 

#define ONE_WIRE_BUS 10  // Temp sensoor pin no.10
LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
int value; 

const int red = 7; 
const int green = 6; 
float Celcius=0;
 
void setup() {
  lcd.init(); 
  lcd.backlight(); 
  lcd.setCursor(0,0); 
  lcd.print(" Tempereture ");
  sensors.begin(); 
  pinMode(red,OUTPUT);// RGB red color 
}
 
void loop() {
  sensors.requestTemperatures(); 
  Celcius=sensors.getTempCByIndex(0);
  lcd.setCursor(6,1); //place cursor at 6 column,2 row
  lcd.print(Celcius); //value displayed on lcd 
  delay(200); //delay 200ms 
  lcd.setCursor(9,1); //place cursor at 9 column,2 row
  lcd.print('°C'); //value displayed on lcd 
  delay(10000); //delay 10 s
   if((Celcius) > ( 39 )){
        digitalWrite(red,1);
        digitalWrite(green,0);
    }else{
        digitalWrite(red,0);
        digitalWrite(green,1);
    }
    
  lcd.clear(); //Clean the screen
  delay(1000);
  
}