Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "p33Fxxxx.h"
- _FWDT(FWDTEN_OFF);
- // Watchdog Timer controlat prin soft
- void delay(unsigned int t)
- {
- unsigned int x;
- unsigned int i;
- for(i=0;i<650;i++)
- for(x=0;x<t;x++);
- }
- void random()
- {
- int number;
- number=rand()%4+1;
- if(number==1)
- PORTB=0x7000;
- delay(50);
- if(number==2)
- PORTB=0xE000;
- delay(50);
- if(number==3)
- PORTB=0xD000;
- delay(50);
- if(number==4)
- PORTB=0xB000;
- delay(50);
- }
- int main(void)
- {
- RCONbits.SWDTEN=0;
- /* Dezactivare Watch Dog Timer*/
- TRISB = 0x0000;
- /*setarea pinilor portului B ca iesiri*/
- LATB = 0x0000;
- /* valoarea din latch-urile de date este 0*/
- while(1)
- {
- random();
- //PORTB=0x7000;
- //delay(300);
- //PORTB=0xE000;
- //delay(300);
- //PORTB=0xB000;
- //delay(300);
- //PORTB=0xD000;
- //delay(300);
- //PORTB=0xE000;
- //delay(300);
- //PORTB=0x7000;
- //delay(300);
- //PORTB=0xD000;
- //delay(300);
- //PORTB=0xB000;
- //delay(300);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement