Hi guys i am developing a timer for my homemade uv exposure box. I wrote some codes and succesfully implement timer into those codes. But what i need is i need a push button which will turn on the timer. For example i have one led connected to RB0 pin and when i plug in the circuit timer starts to count down and the led toggle with every flow. But when i plug in the circuit i dont want the timer to start counting. I want it to start when i push the button. So can anyone help me with this? I am using micro c language.
C:
sbit LCD_RS at RC2_bit;
sbit LCD_EN at RC3_bit;
sbit LCD_D4 at RC4_bit;
sbit LCD_D5 at RC5_bit;
sbit LCD_D6 at RC6_bit;
sbit LCD_D7 at RC7_bit;
sbit LCD_RS_Direction at TRISC2_bit;
sbit LCD_EN_Direction at TRISC3_bit;
sbit LCD_D4_Direction at TRISC4_bit;
sbit LCD_D5_Direction at TRISC5_bit;
sbit LCD_D6_Direction at TRISC6_bit;
sbit LCD_D7_Direction at TRISC7_bit;
sbit LED at RB0_bit;
char message1[] = "PCB UV";
char message2[] = "EXPOSURE UNIT";
char message3[] = "PHOTORESIST";
char message4[] = "SOLDER MASK";
char message5[] = "REMAINING:";
unsigned short time;
void interrupt() {
time++ ;
if (time == 100) { // if time is 76
LED = ~LED; // then toggle led and
time = 0; // reset time
}
PIR1.TMR1IF = 0; // clear TMR1IF
TMR1H = 128;
TMR1L = 0;
}
void main() {
PORTB = 0x00; // Initialize PORTB
TRISB = 0; // PORTB is output
T1CON = 1; // Timer1 settings
PIR1.TMR1IF = 0; // clear TMR1IF
TMR1H = 128; // Initialize Timer1 register
TMR1L = 0;
PIE1.TMR1IE = 1; // enable Timer1 interrupt
time = 0; // initialize cnt
INTCON = 0xC0; // Set GIE, PEIE
start:
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,6,message1);
Lcd_Out(2,3,message2);
do {
} while (1);
}
Last edited by a moderator: