Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <REGX52.H> //biblioteka sa definicijama registara
- typedef unsigned char byte;
- byte xdata LED_PREK _at_ 0x8000; //crvene LED diode / prekidaci
- byte xdata PLAVE_LED _at_ 0x8003; //zute LED diode
- //byte xdata ZELENE_LED _at_ 0x8001; //zelene LED diode
- byte LEDS; //pomocna promenljiva koja pamti
- //stanje zutih LED dioda
- byte prethodna_vr = 0x00;
- byte PREK_SL;
- byte MSB;
- void main()
- {
- unsigned long i; //brojacka promenljiva
- LEDS = 0x0F; //pocetno stanje zutih LED dioda
- while(1)
- {
- PREK_SL = ~LED_PREK; //izgleda sasavo, ali radi :)
- switch(PREK_SL) {
- case 0x00:
- if(PREK_SL != prethodna_vr) {
- LEDS = 0x01;
- prethodna_vr = 0x00;
- }
- break;
- case 0x01:
- if(PREK_SL != prethodna_vr) {
- LEDS = 0x03;
- prethodna_vr = 0x01;
- }
- break;
- case 0x02:
- if(PREK_SL != prethodna_vr) {
- LEDS = 0x07;
- prethodna_vr = 0x02;
- }
- break;
- case 0x03:
- if(PREK_SL != prethodna_vr) {
- LEDS = 0x0F;
- prethodna_vr = 0x03;
- }
- break;
- }
- for (i = 0; i < 200000; i++); //pauza
- PLAVE_LED = ~LEDS; //promena stanja
- if(~LED_PREK & 0x04) {
- MSB = LEDS & 0x80;
- LEDS = LEDS << 1;
- if(MSB) LEDS |= 1;
- } else {
- MSB = LEDS & 0x01;
- LEDS = LEDS >> 1;
- if(MSB) LEDS |= 0x80;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement