Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <89c51rd2.h>
- #define LEDS P2
- typedef unsigned short int WORD;
- typedef unsigned char BYTE;
- void Diody_w_lewo(void);
- void Diody_w_prawo(void);
- void Delay1(WORD);
- void main (void)
- {
- unsigned int przycisk0=0;
- unsigned int przycisk7=0;
- BYTE k=1;
- BYTE i=0x80;
- while(1)
- {
- if(P3_0==0 || przycisk0==1)
- {
- przycisk7=0;
- przycisk0=1;
- //i=1;
- LEDS=~k;
- k= (k==0x80 ) ? 1 : k<<1;
- Delay1(0x1FFF);
- Delay1(0x1FFF);
- }
- if (P3_7==0 || przycisk7==1)
- {
- przycisk7=1;
- przycisk0=0;
- //i=0x80;
- LEDS=~i;
- i= (i==1) ? 0x80 : i>>1;
- Delay1(0x1FFF);
- Delay1(0x1FFF);
- }
- }
- }
- void Delay1 (WORD wait )
- {
- WORD i;
- for(i=0;i<wait;i++){};
- }
- void Diody_w_lewo(void)
- {
- x=1;
- static BYTE i=1;
- LEDS=~i;
- i= (i==0x80 ) ? 1 : i<<1;
- Delay1(0x1FFF);
- Delay1(0x1FFF);
- }
- void Diody_w_prawo(void)
- {
- y=1;
- static BYTE i=0x80;
- LEDS=~i;
- i= (i==1) ? 0x80 : i>>1;
- Delay1(0x1FFF);
- Delay1(0x1FFF);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement