Professional Documents
Culture Documents
AEMC Proiect
AEMC Proiect
Tantari Dumitru
Lisnic Colea
Antohi Oana
#include <xc.h>
char butt_state;
char temp_an;
uint16_t RH_an;
uint16_t Lux_an;
void init_uC(void);
void Start_Signal(void);
__bit Check_Response();
void lcd_clear(void);
void DHT_read(void);
float get_lm35(void);
float Read_ADC(void);
void Init_ADC(void);
void main(void)
init_uC();
init_LCD();
Init_ADC();
char butt_state = 1;
lcd_goto(0x80);
lcd_puts(logo1);
lcd_goto(0xC0);
afisare_diacritice(7, 0xC0);
afisare_diacritice(2, 0xC1);
lcd_puts("n");
afisare_diacritice(4, 0xC3);
lcd_puts("ari Dumitru");
lcd_goto(0x94);
lcd_puts(logo2);
lcd_goto(0xD4);
lcd_puts(logo3);
__delay_ms(2000);
lcd_clear();
while (1)
while(butt_state == 1 )
DHT_read();
if (RC0 ==1)
__delay_ms(100);
if (RC0 ==1)
butt_state++;
lcd_clear();
while(butt_state == 2 )
ADCON0bits.CHS = 0x00;
temp_an = get_lm35();
ADCON0bits.CHS = 0x01;
if(RH_an >=100)
lcd_goto(0x80);
lcd_puts("Senzori Analogici");
lcd_goto(0xC0);
lcd_puts(Temperature);
lcd_goto(0x94);
lcd_puts(Humidity);
if (RC0 ==1)
__delay_ms(100);
if (RC0 ==1)
butt_state++;
lcd_clear();
while(butt_state == 3 )
ADCON0bits.CHS = 0x02;
lcd_goto(0x80);
lcd_puts("Senzor lumina");
lcd_goto(0xC0);
lcd_puts(Luminozitate);
if (RC0 ==1)
__delay_ms(100);
if (RC0 ==1)
{
butt_state=1;
float get_lm35(void)
return temp;
float Read_ADC(void)
__delay_us(50);
GO = 1;
while(GO_DONE);
return (ADRESH<<8)+ADRESL;
void Init_ADC(void)
TRISA = 0xff;
ADCON0bits.ADCS = 0b00;
ADCON0bits.CHS = 0b0000;
ADCON0bits.ADON = 1;
ADCON1bits.ADFM = 1;
ADCON1bits.VCFG1 = 0;
ADCON1bits.VCFG0= 0;
void DHT_read(void)
if(Check_Response()) // check if there is a response from sensor (If OK start reading humidity and
temperature data)
// read (and save) data from the DHT11 sensor and check time out errors
lcd_clear();
lcd_goto(0x80);
}
else // if there is no time out error
// {
lcd_goto(0x80);
lcd_puts("Senzori Digitali");
lcd_goto(0xC0);
lcd_puts(Temperature);
lcd_goto(0x94);
lcd_puts(Humidity);
/*
Temperature_prev[i] =Temperature[i] ;
Humidity_prev[i] = Humidity[i];
*/
}
else
lcd_clear();
lcd_goto(0x80);
lcd_puts("Checksum Error!");
else
lcd_clear();
lcd_goto(0xC5);
lcd_puts("No response");
lcd_goto(0x94);
T1CON = 0x10; // set Timer1 clock source to internal with 1:2 prescaler (Timer1 clock =
1MHz)
TMR1L = 0;
RC0 =1;
TMR0 = 178; //
LED2 = !LED2; //
void Start_Signal(void) {
DHT11_PIN_DIR = 0; // configure DHT11_PIN as output
__delay_ms(25); // wait 25 ms
__delay_us(30); // wait 30 us
__bit Check_Response() {
TMR1L = 0;
while(!DHT11_PIN && TMR1L < 100); // wait until DHT11_PIN becomes high (checking of 80µs low
time response)
if(TMR1L > 99) // if response time > 99µS ==> Response error
else
TMR1L = 0;
while(DHT11_PIN && TMR1L < 100); // wait until DHT11_PIN becomes low (checking of 80µs high
time response)
if(TMR1L > 99) // if response time > 99µS ==> Response error
else
*dht_data = 0;
TMR1L = 0;
if(TMR1L > 100) { // if low time > 100 ==> Time out error (Normally it takes 50µs)
return 1;
TMR1L = 0;
//cod LCD
#include <xc.h>
char THETA = 0xF2; //codul ASCII pentru simbolul "? " (theta)
char SIGMAm = 0xE5; //codul ASCII pentru simbolul "s" (sigma mic)
char SIGMAM = 0xF6; //codul ASCII pentru simbolul "S" (sigma mare)
char MINUS1 = 0xE9; //codul ASCII pentru simbolul "-1" (putere -1)
char mt1[8]={0x04, 0x04, 0x0E, 0x04, 0x04, 0x05, 0x06, 0x02}; //litera "t,"
unsigned char a1, a2, i1, s1, t1, L1, L2, L3, L4,T1; //denumirile acestor variabile se aleg
void init_LCD(void);
void initializare_diacritice(void);
void init_LCD(void)
//delay_LCD(2000);
//lcd_write(0x2C);
delay_LCD(100);
lcd_clear();
delay_LCD(3000);
lcd_write(0x02);
delay_LCD(2000);
lcd_write(0x06);
delay_LCD(100);
lcd_write(0x0C);
delay_LCD(100);
lcd_write(0x10);
delay_LCD(100);
lcd_write(0x2C);
delay_LCD(100);
initializare_diacritice();
}
LCD_STROBE();
LCD_STROBE();
void lcd_clear(void)
LCD_RS = 0;
lcd_write(0x01);
while(*s)
lcd_write(*s++);
void lcd_putch(char c)
lcd_write( c );
LCD_RS = 0;
lcd_write(pos);
}
void initializare_diacritice(void)
char i;
*diacritic = pozitie_DDRAM;
lcd_goto(0x40+(pozitie_DDRAM*8)+i);
delay_LCD(100);
lcd_putch(matrice[i]);
delay_LCD(100);
}
lcd_goto(linia);
lcd_putch(diacritic_afisat);
Partea de PCB: