GithubHelp home page GithubHelp logo

erogluegemen / automated-temperature-control-system-with-visual-and-auditory-feedback Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 2.26 MB

The objective of this project is to create a temperature control system using an Arduino microcontroller that regulates a fan motor's speed based on the ambient temperature. Additionally, the system provides visual feedback using an RGB LED and auditory feedback using a buzzer.

circuit circuit-design embedded embedded-systems sensors tinkercad tinkercad-project

automated-temperature-control-system-with-visual-and-auditory-feedback's Introduction

Automated-Temperature-Control-System-with-Visual-and-Auditory-Feedback

Introduction

The objective of this project is to create a temperature control system using an Arduino microcontroller that regulates a fan motor's speed based on the ambient temperature. Additionally, the system provides visual feedback using an RGB LED and auditory feedback using a buzzer.

Project Overview

embedded

Project Code

#include <Adafruit_LiquidCrystal.h>
#define TEMPERATURE A0
#define MOTOR 3
#define BUZZER_PIN 4

Adafruit_LiquidCrystal lcd(0);

// define RGB LED pins
int redPin = 9;
int greenPin = 11;  
int bluePin = 10; 

// define button pin
int interruptPin = 2;

// define interrupt variables
volatile bool state = false;
volatile int seconds = 0;
unsigned long lastDebounceTime = 0;  

void setup() {
  Serial.begin(9600);
  lcd.begin(16, 2);
  pinMode(MOTOR, OUTPUT);
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
  pinMode(interruptPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(interruptPin), button_pressed, FALLING);
  pinMode(BUZZER_PIN, OUTPUT);
}

void loop() {
  if (state) {
    lcd.setCursor(0, 0);
    lcd.setBacklight(1); 
    lcd.print("Turned ON: ");
    lcd.setCursor(11, 0);
    lcd.print("   ");
    lcd.setCursor(11, 0);
    lcd.print(seconds);

    int rawTemp = analogRead(TEMPERATURE);
    int temperature = map(rawTemp, 20, 358, -40, 125);
    int speed = speedDecider(temperature);

    analogWrite(MOTOR, speed);
    setLight(temperature);
    
    lcd.setCursor(0, 1);
    lcd.print("T: ");
    lcd.setCursor(5, 1);
    lcd.print(" ");
    lcd.setCursor(3, 1);
    lcd.print(temperature);
    
    lcd.setCursor(7, 1);
    lcd.print("S: ");
    lcd.setCursor(12, 1);
    lcd.print(" ");
    lcd.setCursor(10, 1);
    lcd.print(speed);
  }
  else {
    analogWrite(MOTOR, 0);
    setColor(0, 0, 0);
    digitalWrite(BUZZER_PIN, LOW);
    lcd.setCursor(0, 0);
    lcd.print("Turned OFF: ");
    lcd.setCursor(12, 0);
    lcd.print("   ");
    lcd.setCursor(12, 0);
    lcd.print(seconds);
    lcd.setCursor(0, 1);
    lcd.print("               ");
  }
}

void button_pressed() {
  unsigned long currentTime = millis();
  if (currentTime - lastDebounceTime > 50) { 
    state = !state;
    seconds = millis() / 1000;
    Serial.println(seconds);
    lastDebounceTime = currentTime;
  }
}

int speedDecider(int temp) {
  if (temp < 10)
    return 0;
  else if (temp > 60)
    return 255;
  else
    return map(temp, 10, 60, 0, 255);
}

void setLight(int temp) {
  // green for cool
  if (temp <= 30)
    setColor(0, 255, 0);   
  else if (temp >= 80) {
    // blink red LED
    static bool toggle = false;
    if (toggle) {
      setColor(255, 0, 0);
      digitalWrite(BUZZER_PIN, HIGH);
    } else { // turn off the LED
      setColor(0, 0, 0); 
      digitalWrite(BUZZER_PIN, LOW);
    }
    toggle = !toggle;
  } else {
    setColor(255, 20, 0); // orange for moderate
    digitalWrite(BUZZER_PIN, LOW);
  }
}

void setColor(int redValue, int greenValue, int blueValue) {
  analogWrite(redPin, redValue);
  analogWrite(greenPin, greenValue);
  analogWrite(bluePin, blueValue);
}

Contact

For any inquiries or feedback, please contact the project team at:
@Egemen Eroglu
@Ece Akdeniz

automated-temperature-control-system-with-visual-and-auditory-feedback's People

Contributors

erogluegemen avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.