Posted on

TEMPORIZATOR – PROIECT COMPLET

Dupa foarte multe teste si reglaje fine am reusit sa gasesc si timpul necesar sa public proiectul complet al temporizatorului vandut de peste 1 an, pe care il gasiti in varianta complet asamblata sau doar placa in linkurile de mai jos :

http://chiplogic.ro/?product=temporizator-cu-memorie

http://chiplogic.ro/?product=temporizator-cu-memorie-doar-placa

 

Proiectul contine gerberele + CODUL de arduino. Se poate modifica dupa bunul plac atat timp cat se pastreaza referinta catre autorul original.

 

Proiect Gerber

COD ARDUINO

(Pentru compilarea corecta aveti nevoie si de libraria eepromanything)

 

#include <LiquidCrystal.h>
#include “EEPROManything.h”
int eepMin,eepSec,eepTotal,timptotal1,contorres;
int minutes;
int seconds;
int lcd_key = 0;
int adc_key_in = 0;
int countdown = 0;
int ReleuPin = 6;
int buzzerPin = 7;
const int rs = 13, en = 12, d4 = 11, d5 = 10, d6 = 9, d7 = 8;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
#define btnRESET 0
#define btnSECUNDE 1
#define btnMINUTE 2
#define btnSTART 4
#define btnNONE 5
boolean startCountdown = false;
boolean SUNET = true;
int read_LCD_buttons()
{
adc_key_in = analogRead(0);
if (adc_key_in > 1000) return btnNONE;
if ((adc_key_in > -10) && (adc_key_in < 10)) return btnSTART;
if ((adc_key_in > 300) && (adc_key_in < 360)) return btnSECUNDE;
if ((adc_key_in > 500) && (adc_key_in < 550)) return btnMINUTE;
if ((adc_key_in > 240) && (adc_key_in < 255)) return btnRESET;
return btnNONE;
}
void sunetpornire(){
tone(buzzerPin, 800, 100);
delay(200);
tone(buzzerPin, 1000, 100);
delay(800);
tone(buzzerPin, 1200, 100);
delay(200);
tone(buzzerPin, 800, 100);
delay(200);
tone(buzzerPin, 500, 100);
delay(200);
tone(buzzerPin, 500, 100);
delay(200);
tone(buzzerPin, 1000, 100);
delay(800);
}
void sunetpornire2(){
delay(1);
}
void pornireecran()
{
lcd.clear();
lcd.setCursor(3, 0);
lcd.print(” UV Box By”);
lcd.setCursor(2, 1);
lcd.print(“* ChipLogic *”);
delay(3000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Timp total util.”);
lcd.setCursor(0, 1);
lcd.print(timptotal1);
lcd.print(” Secunde”);
delay(3000);
if ( SUNET == false){
sunetpornire2();
}
if ( SUNET == true){
sunetpornire();
}
}
void cbronzare()
{
countdown = ((minutes * 60) + seconds);
digitalWrite(ReleuPin, HIGH);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“====EXPUNERE====”);
lcd.setCursor(0, 1);
lcd.print(“TIMP:”);
lcd.setCursor(11, 1);
lcd.print(” Sec”);
for (int timer = countdown; timer >= 0; timer –)
{
char buffer[6];
sprintf(buffer, “%4d”, countdown);
lcd.setCursor(7, 1);
lcd.print(buffer);
delay(1000);
countdown = countdown – 1;
/////////////////////////////////////////////////////////////////////////////////
lcd_key = read_LCD_buttons();
if(lcd_key == 0) // reset in timp ce numara
{
if ( SUNET == true)
{
tone(buzzerPin, 1000, 100);
delay(800);
tone(buzzerPin, 1200, 100);
delay(200);
tone(buzzerPin, 800, 100);
delay(200); }
digitalWrite(ReleuPin, LOW);
startCountdown = false;
minutes = 0;
seconds = 0;
countdown = 0;
delay(2000);
lcd.clear();
delay(200);
lcd.setCursor(5, 0);
lcd.print(“ANULAT”);
delay(700);
setuptimp();
}
///////////////////////////////////////////////////////////////////////////////////////
}
/////////////////////// Sfarsit numaratoare////////////////////////
digitalWrite(ReleuPin, LOW);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(” ** GATA **”);
buzzer();
delay(3000);
startCountdown = false;
countdown = 0;
setuptimp();
}
///////////////////Meniu principal 🙂 /////
void setuptimp()
{
lcd_key = read_LCD_buttons();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(” Timp Expunere “);
lcd.setCursor(0, 1);
lcd.print(“Min: “);
lcd.setCursor(9, 1);
lcd.print(“Sec: “);
while(startCountdown == false)
{
if (lcd_key == 1) // secunde
{
seconds ++;
if ( SUNET == true)
{
tone(buzzerPin, 1100, 100);}
delay(300);
if (seconds >= 60)
{
seconds = 0;
minutes ++;
}
}
//////////aici ruleaza cod in meniu
////////////////////////////////////
//char buffer[3];
// sprintf(buffer, “%2d”, seconds);
lcd.setCursor(14, 1);
lcd.print(seconds);
if (lcd_key == 2) // minute
{
minutes ++;
if (minutes > 99)
{
minutes = 0;
minutes ++;
lcd.clear();
}
if ( SUNET == true)
{
tone(buzzerPin, 400, 100);
;}
delay(400);
}
lcd.setCursor(6, 1);
lcd.print(minutes);
if(lcd_key == 0) // reset
{
if ( SUNET == true)
{
tone(buzzerPin, 1000, 100);
delay(800);
tone(buzzerPin, 1200, 100);
delay(200);
tone(buzzerPin, 800, 100); }
digitalWrite(ReleuPin, LOW);
delay(200);
seconds = 0;
minutes = 0;
delay(500);
lcd.clear();
delay(1000);
startCountdown = false;
setuptimp();
}
lcd_key = read_LCD_buttons();
if (lcd_key == 4) // START
{
if ( SUNET == true)
{
tone(buzzerPin, 1500, 100);}
delay(200);
eepMin+=minutes;
eepSec+=seconds;
eepTotal=((minutes*60)+seconds);
timptotal1= timptotal1+eepTotal;
EEPROM_writeAnything(0,eepMin);
EEPROM_writeAnything(2,eepSec);
EEPROM_writeAnything(4,eepTotal);
EEPROM_writeAnything(6,timptotal1);
startCountdown = true;
}
}
lcd.setCursor(8, 1);
lcd.print(countdown);
lcd.setCursor(12, 1);
lcd.print(“Secs”);
cbronzare();
}
void buzzer()
{
for(int x = 0; x <= 6; x++)
{
if ( SUNET == true)
{
tone(buzzerPin, 1500, 100);
delay(200);
tone(buzzerPin, 1000, 100);
delay(200);
tone(buzzerPin, 1500, 100);
delay(200);
tone(buzzerPin, 500, 100);
delay(200);}
}
delay(1);
}
void setup()
{
pinMode(buzzerPin, OUTPUT);
pinMode(ReleuPin, OUTPUT);
lcd.begin(16, 2);
digitalWrite(ReleuPin, LOW);
Serial.begin(9600);
EEPROM_readAnything(0,eepMin);
EEPROM_readAnything(2,eepSec);
EEPROM_readAnything(4,eepTotal);
EEPROM_readAnything(6,timptotal1);
EEPROM_readAnything(8,contorres);
EEPROM_readAnything(10,SUNET);
Serial.println(“UV BOX | ChipLogic 2018”);
Serial.println(“Model: UVT01a”);
Serial.println(“SN :226572493”);
Serial.print(“TIMP TOTAL : “);
Serial.print(timptotal1);
Serial.println(” SECUNDE”);
Serial.println(“Pentru comenzi : 0734 621 828 sau www.chiplogic.ro”);
Serial.print(“sunet : “);
Serial.println(SUNET);
}
void reseteeprom()
{
EEPROM_writeAnything(0,0);
EEPROM_writeAnything(2,0);
EEPROM_writeAnything(4,0);
EEPROM_writeAnything(6,0);
contorres = contorres + 1;
EEPROM_writeAnything(8,contorres);
}
void loop()
{
pornireecran();
delay(500);
lcd_key = read_LCD_buttons();
if (lcd_key == 5) // meniu!
{
setuptimp();
}
if (lcd_key == 1)
{
reseteeprom();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“EEPROM”);
lcd.setCursor(0, 1);
lcd.print(“RESETAT”);
Serial.println(“EEPROM RESETAT”);
delay(9000);
setuptimp();
}
if (lcd_key == 2)
{
if (SUNET == false)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“SUNET”);
lcd.setCursor(0, 1);
lcd.print(“PORNIT”);
SUNET = !SUNET ;
EEPROM_writeAnything(10,SUNET);
delay(2000);
setuptimp();
}
if (true == SUNET)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“SUNET”);
lcd.setCursor(0, 1);
lcd.print(“OPRIT”);
SUNET = !SUNET ;
EEPROM_writeAnything(10,SUNET);
delay(2000);
setuptimp();
}
}
delay(2000);
delay(100);
}