#include<pic.h>//Configure Bits__CONFIG(XT & PWRTDIS & WDTDIS & UNPROTECT);//Delayvoid delay(void){ int t; for(t=0;t<=0x00FF;t++) ;}void main (void) { unsigned char digit=0x00; unsigned char tens; unsigned char ones; TRISA = ~0x0F; TRISB = ~0x0F; PORTB &= ~0x0F; PORTA &= ~0x0F; while(1) { tens = digit/10; ones = digit - (tens * 10); //ones PORTA=0x01; PORTB=ones; delay(); //tens PORTA=0x02; PORTB=tens; delay(); if(RB4==0) //plus1 { delay(); //debounce delay digit+=1; if (digit>99) digit=0x00; } if(RB5==0) //plus2 { delay(); digit+=2; if (digit>99) digit=0x00; } if(RB6==0) //plus3 { delay(); digit+=3; if (digit>99) digit=0x00; } if(RB7==0) //minus1 { delay(); if (digit>0) digit-=1; if (digit<0) digit=0x00; } } }
salamat po sa inyong lahat...huh...mga sir,balak ko kc 2 pic16f84 nlng ggmitin ko.ung 1 para sa timer and shot clock then ung isa sa score.pwede po b un?ung sa timer nd shootclock nlng kelangan ko....salamat sir gigs....gamitin ko bigay mo.un din po b ang code pag 3ssd?
hehe yung nakapost na code pang mikroC na compiler yan, yan yung unang gawa ko, kaya pati yung EEPROM read/write hindi ko pa nailalagay.. tapos na yung Code ng pang 3 SSD ko, what i mean complete na sya.. timer naman ang gagawin ko.. next time gagawa ako nito na gagamit ako ng shift registers ^_^not familiar sa syntax ng Hitech eh kaya hindi ko maintindihan ehhehehepede kang magrely dun sa mga sample codes ni sir paranz sa tutorial thread nya..^^
#include<pic.h>//Configure Bits__CONFIG(XT & PWRTDIS & WDTDIS & UNPROTECT);//Delayvoid delay(void){ int t; for(t=0;t<=0x00FF;t++) ;}void main (void) { unsigned char digit=0x00; unsigned char hundreds; unsigned char tens; unsigned char ones; unsigned char debounce; TRISA = ~0x0F; TRISB = ~0x0F; PORTB &= ~0x0F; PORTA &= ~0x0F; debounce = 0; while(1) { hundreds = digit/100; digit = digit - (hundreds * 100); tens = digit/10; ones = digit - (tens * 10); //ones PORTA=0x01; PORTB=ones; delay(); //tens PORTA=0x02; PORTB=tens; delay(); //hundreds PORTA=0x04; PORTB=hundreds; delay(); if (debounce>0) { debounce--; delay(); } if(RB4==0 && debounce == 0) //plus1 { debounce = 255; //debounce delay digit+=1; if (digit>250) //highest score is 250. let digit rollover from 255 to 0 digit=0x00; } if(RB5==0 && debounce == 0) //plus2 { debounce = 255; digit+=2; if (digit>250) digit=0x00; } if(RB6==0 && debounce == 0) //plus3 { debounce = 255; digit+=3; if (digit>250) digit=0x00; } if(RB7==0 && debounce == 0) //minus1 { debounce = 255; if (digit>0) digit-=1; if (digit<0) digit=0x00; } } }
hundreds = digit/100; digit = digit - (hundreds * 100); tens = digit/10; ones = digit - (tens * 10);
hundreds = digit/100; tens = (digit - (hundreds * 100))/10; ones = digit - (hundreds * 100) - (tens * 10);
interesting po ito, gusto ko din sana gumawa nito para sa basketball court sa amin.pa post naman sir "fherdysheng" yung complete schematics and code pag natapos mo na..thanks