Thermostat yaitu alat yang digunakan untuk mempertahankan suhu sesuai dengan set point yang telah ditentukan. Suhu dibaca oleh sensor LM35 dan hasilnya ditampilkan pada seven segment. Seven segment terdiri dari 4 digit, 2 digit untuk menampilkan suhu yang terbaca dan 2 digit untuk menampilkan satuan derajat celsius. Sedangkan set point di seting dengan menggunakan 3 tombol. Tombol SET digunakan untuk masuk pada menu seting set point. Tombol UP digunakan untuk menambah/menaikkan setpoint. Sedangkan tombol DOWN digunakan untuk mengurangi setpoint. Heater/pemanas di kontrol ON/OFF-nya menggunakan relay yang terhubung dengan kaki output Arduino.
Kebutuhan Hardware
- 1 Modul Sensor LM35
- Modul Seven segment 4 Digit
- Modul Relay 5Vdc
- Heater
- 3 Tombol Push ON
- Modul Arduino UNO
- Power supply +5 Volt
Element Heater | Source
Diagram Blok
Schematic
7-Segment CA Wiring | Source
Koneksi Arduino UNO dengan 7 segment
Koneksi Arduino UNO dengan LM35
Koneksi Arduino UNO dengan Relay
Koneksi Arduino UNO dengan 7 Tombol
Source Code/Sketch
int adc,T,setPoint;
byte setSP, f_awal, kedip;
long lastButton = 0;
long delayAntiBouncing = 50;
byte seven_seg_digits[12][7] = { { ,0,0,0,0,0,1 }, // = 0
{ 1,0,0,1,1,1,1 }, // = 1
{ 0,0,1,0,0,1,0 }, // = 2
{ 0,0,0,0,1,1,0 }, // = 3
{ 1,0,0,1,1,0,0 }, // = 4
{ 0,1,0,0,1,0,0 }, // = 5
{ 0,1,0,0,0,0,0 }, // = 6
{ 0,0,0,1,1,1,1 }, // = 7
{ 0,0,0,0,0,0,0 }, // = 8
{ 0,0,0,0,1,0,0 }, // = 9
{ 0,0,1,1,1,0,0 }, // = derajat
{ 0,1,1,0,0,0,1 } // = C
};
void setup(){
for(char i=2; i<13; i++){
pinMode(i,OUTPUT);
}
pinMode(A1,INPUT);
pinMode(A2,INPUT);
pinMode(A3,INPUT);
digitalWrite(A1,HIGH);
digitalWrite(A2,HIGH);
digitalWrite(A3,HIGH);
pinMode(A4,OUTPUT);
setPoint=40;
}
void loop(){
adc = analogRead(0);
T = (adc*5)/10;
tampilSuhu();
tampilC();
if(T<(setPoint-1) || f_awal==0){
digitalWrite(A4,HIGH);
f_awal=1;
}
else if(T>=setPoint){
digitalWrite(A4,LOW);
}
tombol();
}
void tampilSuhu(){
digitalWrite(10,LOW); digitalWrite(11,HIGH);
digitalWrite(12,HIGH); digitalWrite(13,HIGH);
if (setSP==1){
sevenSegWrite(setPoint/10);
}
else{
sevenSegWrite(T/10);
}
delay(5);
digitalWrite(10,HIGH); digitalWrite(11,LOW);
digitalWrite(12,HIGH); digitalWrite(13,HIGH);
if (setSP==1){
sevenSegWrite(setPoint%10);
}
else{
sevenSegWrite(T%10);
}
delay(5);
}
void tampilC(){
digitalWrite(10,HIGH); digitalWrite(11,HIGH);
digitalWrite(12,LOW); digitalWrite(13,HIGH);
sevenSegWrite(10);
delay(5);
digitalWrite(10,HIGH); digitalWrite(11,HIGH);
digitalWrite(12,HIGH); digitalWrite(13,LOW);
sevenSegWrite(11);
delay(5);
}
void sevenSegWrite(byte segment) {
byte pin = 2;
for (byte segCount = 0; segCount < 7; ++segCount) {
digitalWrite(pin, seven_seg_digits[segment][segCount]);
++pin;
}
}
void tombol(){
if(digitalRead(A1)==0){
if ((millis() - lastButton) > delayAntiBouncing){
setSP=1;
}
lastButton = millis();
}
while (setSP){
//-----------------tombol seting
if(digitalRead(A1)==0){
if ((millis() - lastButton) > delayAntiBouncing){
setSP=0;
}
lastButton = millis();
}
//---------------tombol up
else if(digitalRead(A2)==0){
if ((millis() - lastButton) > delayAntiBouncing){
setPoint++;
}
lastButton = millis();
}
//---------------tombol down
else if(digitalRead(A3)==0){
if ((millis() - lastButton) > delayAntiBouncing){
if (setPoint>0){
setPoint--;
}
}
lastButton = millis();
}
if (kedip<30){
tampilC();
}
else{
tampilSuhu();
tampilC();
if(kedip>60)kedip=0;
}
++kedip;
}
setSP=0;
}
byte setSP, f_awal, kedip;
long lastButton = 0;
long delayAntiBouncing = 50;
byte seven_seg_digits[12][7] = { { ,0,0,0,0,0,1 }, // = 0
{ 1,0,0,1,1,1,1 }, // = 1
{ 0,0,1,0,0,1,0 }, // = 2
{ 0,0,0,0,1,1,0 }, // = 3
{ 1,0,0,1,1,0,0 }, // = 4
{ 0,1,0,0,1,0,0 }, // = 5
{ 0,1,0,0,0,0,0 }, // = 6
{ 0,0,0,1,1,1,1 }, // = 7
{ 0,0,0,0,0,0,0 }, // = 8
{ 0,0,0,0,1,0,0 }, // = 9
{ 0,0,1,1,1,0,0 }, // = derajat
{ 0,1,1,0,0,0,1 } // = C
};
void setup(){
for(char i=2; i<13; i++){
pinMode(i,OUTPUT);
}
pinMode(A1,INPUT);
pinMode(A2,INPUT);
pinMode(A3,INPUT);
digitalWrite(A1,HIGH);
digitalWrite(A2,HIGH);
digitalWrite(A3,HIGH);
pinMode(A4,OUTPUT);
setPoint=40;
}
void loop(){
adc = analogRead(0);
T = (adc*5)/10;
tampilSuhu();
tampilC();
if(T<(setPoint-1) || f_awal==0){
digitalWrite(A4,HIGH);
f_awal=1;
}
else if(T>=setPoint){
digitalWrite(A4,LOW);
}
tombol();
}
void tampilSuhu(){
digitalWrite(10,LOW); digitalWrite(11,HIGH);
digitalWrite(12,HIGH); digitalWrite(13,HIGH);
if (setSP==1){
sevenSegWrite(setPoint/10);
}
else{
sevenSegWrite(T/10);
}
delay(5);
digitalWrite(10,HIGH); digitalWrite(11,LOW);
digitalWrite(12,HIGH); digitalWrite(13,HIGH);
if (setSP==1){
sevenSegWrite(setPoint%10);
}
else{
sevenSegWrite(T%10);
}
delay(5);
}
void tampilC(){
digitalWrite(10,HIGH); digitalWrite(11,HIGH);
digitalWrite(12,LOW); digitalWrite(13,HIGH);
sevenSegWrite(10);
delay(5);
digitalWrite(10,HIGH); digitalWrite(11,HIGH);
digitalWrite(12,HIGH); digitalWrite(13,LOW);
sevenSegWrite(11);
delay(5);
}
void sevenSegWrite(byte segment) {
byte pin = 2;
for (byte segCount = 0; segCount < 7; ++segCount) {
digitalWrite(pin, seven_seg_digits[segment][segCount]);
++pin;
}
}
void tombol(){
if(digitalRead(A1)==0){
if ((millis() - lastButton) > delayAntiBouncing){
setSP=1;
}
lastButton = millis();
}
while (setSP){
//-----------------tombol seting
if(digitalRead(A1)==0){
if ((millis() - lastButton) > delayAntiBouncing){
setSP=0;
}
lastButton = millis();
}
//---------------tombol up
else if(digitalRead(A2)==0){
if ((millis() - lastButton) > delayAntiBouncing){
setPoint++;
}
lastButton = millis();
}
//---------------tombol down
else if(digitalRead(A3)==0){
if ((millis() - lastButton) > delayAntiBouncing){
if (setPoint>0){
setPoint--;
}
}
lastButton = millis();
}
if (kedip<30){
tampilC();
}
else{
tampilSuhu();
tampilC();
if(kedip>60)kedip=0;
}
++kedip;
}
setSP=0;
}
Jalannya Alat
1. Koneksikan antara sistem Arduino dengan peripheral lain seperti pada rangkaian (skematik).
2. Pasang power supply.
3. Upload program diatas.
4. Tampilan normal menampilkan suhu yang terbaca.
5. Heater akan ON apabila suhu dibawah set point, setpoint awal 40°C.
6. Heater OFF pada saat suhu sama dengan set point.
7. Heater akan menyala lagi setelah suhu berkurang 5°C dibawah set point.
8. Seting setpoint dengan menekan tombol SET, sehingga seven segment menampilkan suhu setpoint
dan tampilanya berkedip.
9. Tekan tombol UP untuk menambah suhu set point atau tekan tombol DOWN untuk menguranginya.
10. Tekan tombol SET jika setingan sudah selesai.
11. Tampilan kembali pada tampilan normal.
Video untuk Project III - 9. Thermostat dengan Tampilan 7-Segment berbasis Arduino
KONTAK KAMI 085743320570 (adi sanjaya)
No comments:
Post a Comment