Guest User

Untitled

a guest
Jan 19th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include <18F4520.h>
  2. #use delay (clock = 20000000)
  3. #fuses HS, NOWDT, NOLVP
  4.  
  5. int *ADCON1 = 0xFC1, *TRISB = 0xF93, *TRISC = 0xF94;
  6. int *PORTB = 0xF81, *PORTC = 0xF82;
  7.  
  8. MAIN(){
  9. int X;
  10. *ADCON1 = 0xFC;
  11. *TRISB = 0x01;
  12. *TRISC = 0x00;
  13. *PORTC = 0x01;
  14. while(1){
  15. if( *PORTB & 0x01){
  16. if( x == 255)
  17. x = 100;
  18. else
  19. x = 255;
  20. }
  21. while( *PORTC < 0x80){
  22. *PORTC = *PORTC<<1;
  23. delay_ms(x);
  24. }
  25. while( *PORTC > 0x01){
  26. *PORTC = *PORTC>>1;
  27. delay_ms(x);
  28. }
  29. }
  30. }
Add Comment
Please, Sign In to add comment