Advertisement
Guest User

ex1

a guest
Apr 27th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <main.h>
  2. #define TIME_DELAY 500
  3. #define BxOUT 0x00
  4. const char PIN_ARR[] = {PIN_B0, PIN_B1, PIN_B2, PIN_B3, PIN_B4, PIN_B5, PIN_B6, PIN_B7};
  5.  
  6. void main(){
  7.  
  8. set_tris_b(BxOUT);
  9. output_B(BxOUT);
  10. // int i;
  11.  
  12. while(TRUE){
  13.  
  14. for (int i = 0; i < 8; i++){
  15. output_high(PIN_ARR[i]);
  16. delay_ms(TIME_DELAY);
  17. }
  18. //turn off all leds
  19. output_B(BxOUT);
  20. delay_ms(TIME_DELAY);
  21.  
  22. for (int j = 7; j >= 0; j--){
  23. output_high(PIN_ARR[j]);
  24. delay_ms(TIME_DELAY);
  25. }
  26. //turn off all leds
  27. output_B(BxOUT);
  28. delay_ms(TIME_DELAY);
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement