SlideShare a Scribd company logo
#include <16F877a.h>
#fuses XT,NOPROTECT
#use delay (clock=4M)
#byte TRISC = 0x87
#byte PORTC = 0x07
#byte TRISB = 0x86
#byte PORTB = 0x06
#byte TRISA = 0x85
#byte PORTA = 0x05
void set7seg();
char display[10] = { 0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7C,0x07,0x7F,0x67};
char i,j;
long count=0;
void set7seg(){
output_high(PIN_C0); //TURN ON Q1
output_low(PIN_C1);//TURN OFF Q2
PORTB = display[i];
delay_ms(1);
output_high(PIN_C1); //TURN ON Q2
PORTB = display[j];
output_low(PIN_C0); //TURN OFF Q1
delay_ms(1);
}
#int_timer0 // 1S
void timer0(){
count++;//500us
if(count == 1850)
{
i--;
count = 0;
if(i == -1)
{
i = 9;
j--;
}
}
SET_TIMER0(131);
}
void main(){
TRISC = 0b00000000; // PAPUNTANG TRANSISTOR
TRISB = 0x00; // data papunta sa 7seg resistor
TRISA = 0b111100; //push button data
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_4);
SET_TIMER0(131);
i=j=0;
while(true)
{
set7seg();
if(input(PIN_A0) == 0)
{
while
(input(PIN_A0) == 0)
{
set7seg();
}
i++;
if
(i == 10)
{
i = 0;
j++;
}}
if(input(PIN_A1) == 0)
{
while(input(PIN_A1) == 0)
{
set7seg();
}
i--;
if(i == -1)
{
i = 9;
j--;
}}
if(input(PIN_A2) == 0) { while(input(PIN_A2) == 0){set7seg();}SET_TIMER0(131);
enable_interrupts(INT_TIMER0); enable_interrupts(GLOBAL); }
if(input(PIN_A3) == 0) { while(input(PIN_A3) == 0){set7seg();}
disable_interrupts(GLOBAL); }
if(i==0 && j==0)disable_interrupts(GLOBAL);
}}

More Related Content

What's hot

Lab programs FOR 8TH SEM EC SUBJECT BY LOHITH KUMAR |11GUEE6018
Lab programs FOR 8TH SEM EC SUBJECT BY LOHITH KUMAR |11GUEE6018Lab programs FOR 8TH SEM EC SUBJECT BY LOHITH KUMAR |11GUEE6018
Lab programs FOR 8TH SEM EC SUBJECT BY LOHITH KUMAR |11GUEE6018
UVCE
 
Pic programms FOR 8TH SEM STUDENTS BY LOHITH KUMAR | 11GUEE6018
Pic programms FOR 8TH SEM STUDENTS BY LOHITH KUMAR | 11GUEE6018Pic programms FOR 8TH SEM STUDENTS BY LOHITH KUMAR | 11GUEE6018
Pic programms FOR 8TH SEM STUDENTS BY LOHITH KUMAR | 11GUEE6018
UVCE
 
4th sem hons
4th sem hons4th sem hons
4th sem hons
avi9432
 
Programa.eje
Programa.ejePrograma.eje
Programa.eje
guapi387
 
My bitmap
My bitmapMy bitmap
My bitmap
Milruwan Perera
 
PHP in 2018 - Q1 - AFUP Limoges
PHP in 2018 - Q1 - AFUP LimogesPHP in 2018 - Q1 - AFUP Limoges
PHP in 2018 - Q1 - AFUP Limoges
✅ William Pinaud
 

What's hot (6)

Lab programs FOR 8TH SEM EC SUBJECT BY LOHITH KUMAR |11GUEE6018
Lab programs FOR 8TH SEM EC SUBJECT BY LOHITH KUMAR |11GUEE6018Lab programs FOR 8TH SEM EC SUBJECT BY LOHITH KUMAR |11GUEE6018
Lab programs FOR 8TH SEM EC SUBJECT BY LOHITH KUMAR |11GUEE6018
 
Pic programms FOR 8TH SEM STUDENTS BY LOHITH KUMAR | 11GUEE6018
Pic programms FOR 8TH SEM STUDENTS BY LOHITH KUMAR | 11GUEE6018Pic programms FOR 8TH SEM STUDENTS BY LOHITH KUMAR | 11GUEE6018
Pic programms FOR 8TH SEM STUDENTS BY LOHITH KUMAR | 11GUEE6018
 
4th sem hons
4th sem hons4th sem hons
4th sem hons
 
Programa.eje
Programa.ejePrograma.eje
Programa.eje
 
My bitmap
My bitmapMy bitmap
My bitmap
 
PHP in 2018 - Q1 - AFUP Limoges
PHP in 2018 - Q1 - AFUP LimogesPHP in 2018 - Q1 - AFUP Limoges
PHP in 2018 - Q1 - AFUP Limoges
 

Similar to Two digit-countdown-timer

Microcontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docxMicrocontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docx
SANTIAGO PABLO ALBERTO
 
codings related to avr micro controller
codings related to avr micro controllercodings related to avr micro controller
codings related to avr micro controller
Syed Ghufran Hassan
 
8051 -5
8051 -58051 -5
please show elegoo arduino board setup using a passive buzzer- heres t.pdf
please show elegoo arduino board setup using a passive buzzer- heres t.pdfplease show elegoo arduino board setup using a passive buzzer- heres t.pdf
please show elegoo arduino board setup using a passive buzzer- heres t.pdf
admin463580
 
PIC and LCD
PIC and LCDPIC and LCD
PIC and LCD
hairilfaiz86
 
REPORT
REPORTREPORT
#include LPC17xx.h#include Lights.h#include traffic_fo.docx
#include LPC17xx.h#include Lights.h#include traffic_fo.docx#include LPC17xx.h#include Lights.h#include traffic_fo.docx
#include LPC17xx.h#include Lights.h#include traffic_fo.docx
ajoy21
 
Codigo fuente
Codigo fuenteCodigo fuente
Codigo fuente
BlackD10
 
Combine the keypad and LCD codes in compliance to the following requ.pdf
Combine the keypad and LCD codes in compliance to the following requ.pdfCombine the keypad and LCD codes in compliance to the following requ.pdf
Combine the keypad and LCD codes in compliance to the following requ.pdf
forwardcom41
 
ARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lectureARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lecture
anishgoel
 
Linux Serial Driver
Linux Serial DriverLinux Serial Driver
Linux Serial Driver
艾鍗科技
 
C# Assignmet Help
C# Assignmet HelpC# Assignmet Help
C# Assignmet Help
Programming Homework Help
 
# peripheral registers .equ PWR_BASE0x40007000 .equ PWR_CR0x00 .docx
# peripheral registers  .equ PWR_BASE0x40007000    .equ PWR_CR0x00  .docx# peripheral registers  .equ PWR_BASE0x40007000    .equ PWR_CR0x00  .docx
# peripheral registers .equ PWR_BASE0x40007000 .equ PWR_CR0x00 .docx
mayank272369
 
(381877808) 102054282 5-listing-program
(381877808) 102054282 5-listing-program(381877808) 102054282 5-listing-program
(381877808) 102054282 5-listing-program
Dimz I
 
Programming A Robot Using
Programming A Robot UsingProgramming A Robot Using
Programming A Robot Using
Spitiq
 
Embedded JavaScript
Embedded JavaScriptEmbedded JavaScript
Embedded JavaScript
Jens Siebert
 
7segment scetch
7segment scetch7segment scetch
7segment scetch
Bang Igo
 
Code
CodeCode
Metal detecting robot sketch
Metal detecting robot sketchMetal detecting robot sketch
Metal detecting robot sketch
Akhil Unnikrishnan
 
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdfHow do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
footstatus
 

Similar to Two digit-countdown-timer (20)

Microcontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docxMicrocontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docx
 
codings related to avr micro controller
codings related to avr micro controllercodings related to avr micro controller
codings related to avr micro controller
 
8051 -5
8051 -58051 -5
8051 -5
 
please show elegoo arduino board setup using a passive buzzer- heres t.pdf
please show elegoo arduino board setup using a passive buzzer- heres t.pdfplease show elegoo arduino board setup using a passive buzzer- heres t.pdf
please show elegoo arduino board setup using a passive buzzer- heres t.pdf
 
PIC and LCD
PIC and LCDPIC and LCD
PIC and LCD
 
REPORT
REPORTREPORT
REPORT
 
#include LPC17xx.h#include Lights.h#include traffic_fo.docx
#include LPC17xx.h#include Lights.h#include traffic_fo.docx#include LPC17xx.h#include Lights.h#include traffic_fo.docx
#include LPC17xx.h#include Lights.h#include traffic_fo.docx
 
Codigo fuente
Codigo fuenteCodigo fuente
Codigo fuente
 
Combine the keypad and LCD codes in compliance to the following requ.pdf
Combine the keypad and LCD codes in compliance to the following requ.pdfCombine the keypad and LCD codes in compliance to the following requ.pdf
Combine the keypad and LCD codes in compliance to the following requ.pdf
 
ARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lectureARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lecture
 
Linux Serial Driver
Linux Serial DriverLinux Serial Driver
Linux Serial Driver
 
C# Assignmet Help
C# Assignmet HelpC# Assignmet Help
C# Assignmet Help
 
# peripheral registers .equ PWR_BASE0x40007000 .equ PWR_CR0x00 .docx
# peripheral registers  .equ PWR_BASE0x40007000    .equ PWR_CR0x00  .docx# peripheral registers  .equ PWR_BASE0x40007000    .equ PWR_CR0x00  .docx
# peripheral registers .equ PWR_BASE0x40007000 .equ PWR_CR0x00 .docx
 
(381877808) 102054282 5-listing-program
(381877808) 102054282 5-listing-program(381877808) 102054282 5-listing-program
(381877808) 102054282 5-listing-program
 
Programming A Robot Using
Programming A Robot UsingProgramming A Robot Using
Programming A Robot Using
 
Embedded JavaScript
Embedded JavaScriptEmbedded JavaScript
Embedded JavaScript
 
7segment scetch
7segment scetch7segment scetch
7segment scetch
 
Code
CodeCode
Code
 
Metal detecting robot sketch
Metal detecting robot sketchMetal detecting robot sketch
Metal detecting robot sketch
 
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdfHow do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
 

Recently uploaded

Collective Mining | Corporate Presentation - June 2024
Collective Mining  | Corporate Presentation - June 2024Collective Mining  | Corporate Presentation - June 2024
Collective Mining | Corporate Presentation - June 2024
CollectiveMining1
 
ZKsync airdrop of 3.6 billion ZK tokens is scheduled by ZKsync for next week.pdf
ZKsync airdrop of 3.6 billion ZK tokens is scheduled by ZKsync for next week.pdfZKsync airdrop of 3.6 billion ZK tokens is scheduled by ZKsync for next week.pdf
ZKsync airdrop of 3.6 billion ZK tokens is scheduled by ZKsync for next week.pdf
SOFTTECHHUB
 
Cyberagent_For New Investors_EN_240424.pdf
Cyberagent_For New Investors_EN_240424.pdfCyberagent_For New Investors_EN_240424.pdf
Cyberagent_For New Investors_EN_240424.pdf
CyberAgent, Inc.
 
Methanex Investor Presentation - April 2024
Methanex Investor Presentation - April 2024Methanex Investor Presentation - April 2024
Methanex Investor Presentation - April 2024
Methanex Corporation
 
Collective Mining | Corporate Presentation - June 2024
Collective Mining | Corporate Presentation - June 2024Collective Mining | Corporate Presentation - June 2024
Collective Mining | Corporate Presentation - June 2024
CollectiveMining1
 
Mandalay Resouces June 2024 Investor Relations PPT
Mandalay Resouces June 2024 Investor Relations PPTMandalay Resouces June 2024 Investor Relations PPT
Mandalay Resouces June 2024 Investor Relations PPT
MandalayResources
 
Understanding-the-E-Way-Bill-A-Digital-Transformation-in-Logistics.pptx
Understanding-the-E-Way-Bill-A-Digital-Transformation-in-Logistics.pptxUnderstanding-the-E-Way-Bill-A-Digital-Transformation-in-Logistics.pptx
Understanding-the-E-Way-Bill-A-Digital-Transformation-in-Logistics.pptx
cosmo-soil
 
快速办理(CUBoulder毕业证书)科罗拉多大学博尔德分校毕业证录取通知书一模一样
快速办理(CUBoulder毕业证书)科罗拉多大学博尔德分校毕业证录取通知书一模一样快速办理(CUBoulder毕业证书)科罗拉多大学博尔德分校毕业证录取通知书一模一样
快速办理(CUBoulder毕业证书)科罗拉多大学博尔德分校毕业证录取通知书一模一样
f3wjr2q2
 
ppt-namibia-worldeconomy-standardbank.ppt
ppt-namibia-worldeconomy-standardbank.pptppt-namibia-worldeconomy-standardbank.ppt
ppt-namibia-worldeconomy-standardbank.ppt
TestOrg1
 
Cleades robinson:The Diplomat is Blue
Cleades robinson:The Diplomat is BlueCleades robinson:The Diplomat is Blue
Cleades robinson:The Diplomat is Blue
Cleades Robinson
 
Osisko Gold Royalties Ltd - Corporate Presentation, June 12, 2024
Osisko Gold Royalties Ltd - Corporate Presentation, June 12, 2024Osisko Gold Royalties Ltd - Corporate Presentation, June 12, 2024
Osisko Gold Royalties Ltd - Corporate Presentation, June 12, 2024
Osisko Gold Royalties Ltd
 
AGM Presentation Probe June 11 Final.pdf
AGM Presentation Probe June 11 Final.pdfAGM Presentation Probe June 11 Final.pdf
AGM Presentation Probe June 11 Final.pdf
Probe Gold
 
UnityNet World Environment Day Abraham Project 2024 Press Release
UnityNet World Environment Day Abraham Project 2024 Press ReleaseUnityNet World Environment Day Abraham Project 2024 Press Release
UnityNet World Environment Day Abraham Project 2024 Press Release
LHelferty
 
Corporate Presentation Probe June 2024.pdf
Corporate Presentation Probe June 2024.pdfCorporate Presentation Probe June 2024.pdf
Corporate Presentation Probe June 2024.pdf
Probe Gold
 

Recently uploaded (14)

Collective Mining | Corporate Presentation - June 2024
Collective Mining  | Corporate Presentation - June 2024Collective Mining  | Corporate Presentation - June 2024
Collective Mining | Corporate Presentation - June 2024
 
ZKsync airdrop of 3.6 billion ZK tokens is scheduled by ZKsync for next week.pdf
ZKsync airdrop of 3.6 billion ZK tokens is scheduled by ZKsync for next week.pdfZKsync airdrop of 3.6 billion ZK tokens is scheduled by ZKsync for next week.pdf
ZKsync airdrop of 3.6 billion ZK tokens is scheduled by ZKsync for next week.pdf
 
Cyberagent_For New Investors_EN_240424.pdf
Cyberagent_For New Investors_EN_240424.pdfCyberagent_For New Investors_EN_240424.pdf
Cyberagent_For New Investors_EN_240424.pdf
 
Methanex Investor Presentation - April 2024
Methanex Investor Presentation - April 2024Methanex Investor Presentation - April 2024
Methanex Investor Presentation - April 2024
 
Collective Mining | Corporate Presentation - June 2024
Collective Mining | Corporate Presentation - June 2024Collective Mining | Corporate Presentation - June 2024
Collective Mining | Corporate Presentation - June 2024
 
Mandalay Resouces June 2024 Investor Relations PPT
Mandalay Resouces June 2024 Investor Relations PPTMandalay Resouces June 2024 Investor Relations PPT
Mandalay Resouces June 2024 Investor Relations PPT
 
Understanding-the-E-Way-Bill-A-Digital-Transformation-in-Logistics.pptx
Understanding-the-E-Way-Bill-A-Digital-Transformation-in-Logistics.pptxUnderstanding-the-E-Way-Bill-A-Digital-Transformation-in-Logistics.pptx
Understanding-the-E-Way-Bill-A-Digital-Transformation-in-Logistics.pptx
 
快速办理(CUBoulder毕业证书)科罗拉多大学博尔德分校毕业证录取通知书一模一样
快速办理(CUBoulder毕业证书)科罗拉多大学博尔德分校毕业证录取通知书一模一样快速办理(CUBoulder毕业证书)科罗拉多大学博尔德分校毕业证录取通知书一模一样
快速办理(CUBoulder毕业证书)科罗拉多大学博尔德分校毕业证录取通知书一模一样
 
ppt-namibia-worldeconomy-standardbank.ppt
ppt-namibia-worldeconomy-standardbank.pptppt-namibia-worldeconomy-standardbank.ppt
ppt-namibia-worldeconomy-standardbank.ppt
 
Cleades robinson:The Diplomat is Blue
Cleades robinson:The Diplomat is BlueCleades robinson:The Diplomat is Blue
Cleades robinson:The Diplomat is Blue
 
Osisko Gold Royalties Ltd - Corporate Presentation, June 12, 2024
Osisko Gold Royalties Ltd - Corporate Presentation, June 12, 2024Osisko Gold Royalties Ltd - Corporate Presentation, June 12, 2024
Osisko Gold Royalties Ltd - Corporate Presentation, June 12, 2024
 
AGM Presentation Probe June 11 Final.pdf
AGM Presentation Probe June 11 Final.pdfAGM Presentation Probe June 11 Final.pdf
AGM Presentation Probe June 11 Final.pdf
 
UnityNet World Environment Day Abraham Project 2024 Press Release
UnityNet World Environment Day Abraham Project 2024 Press ReleaseUnityNet World Environment Day Abraham Project 2024 Press Release
UnityNet World Environment Day Abraham Project 2024 Press Release
 
Corporate Presentation Probe June 2024.pdf
Corporate Presentation Probe June 2024.pdfCorporate Presentation Probe June 2024.pdf
Corporate Presentation Probe June 2024.pdf
 

Two digit-countdown-timer

  • 1. #include <16F877a.h> #fuses XT,NOPROTECT #use delay (clock=4M) #byte TRISC = 0x87 #byte PORTC = 0x07 #byte TRISB = 0x86 #byte PORTB = 0x06 #byte TRISA = 0x85 #byte PORTA = 0x05 void set7seg(); char display[10] = { 0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7C,0x07,0x7F,0x67}; char i,j; long count=0; void set7seg(){ output_high(PIN_C0); //TURN ON Q1 output_low(PIN_C1);//TURN OFF Q2 PORTB = display[i]; delay_ms(1); output_high(PIN_C1); //TURN ON Q2 PORTB = display[j]; output_low(PIN_C0); //TURN OFF Q1 delay_ms(1); } #int_timer0 // 1S void timer0(){ count++;//500us if(count == 1850) { i--; count = 0; if(i == -1) { i = 9; j--; } } SET_TIMER0(131); } void main(){ TRISC = 0b00000000; // PAPUNTANG TRANSISTOR TRISB = 0x00; // data papunta sa 7seg resistor TRISA = 0b111100; //push button data setup_timer_0(RTCC_INTERNAL|RTCC_DIV_4); SET_TIMER0(131); i=j=0; while(true) { set7seg(); if(input(PIN_A0) == 0) { while (input(PIN_A0) == 0) { set7seg(); } i++;
  • 2. if (i == 10) { i = 0; j++; }} if(input(PIN_A1) == 0) { while(input(PIN_A1) == 0) { set7seg(); } i--; if(i == -1) { i = 9; j--; }} if(input(PIN_A2) == 0) { while(input(PIN_A2) == 0){set7seg();}SET_TIMER0(131); enable_interrupts(INT_TIMER0); enable_interrupts(GLOBAL); } if(input(PIN_A3) == 0) { while(input(PIN_A3) == 0){set7seg();} disable_interrupts(GLOBAL); } if(i==0 && j==0)disable_interrupts(GLOBAL); }}