Guest User

Untitled

a guest
Jan 22nd, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. #include <16f628a.h>
  2.  
  3. #FUSES NOWDT //Sem Timer Cão de Guarda
  4. #FUSES INTRC_IO //Oscilador Interno e dois pinos de I/O liberados
  5. #FUSES NOPUT //Sem timer de alimentação
  6. #FUSES NOPROTECT //Epprom desprotegida (permite a leitura)
  7. #FUSES NOBROWNOUT //Brownout desabilitado
  8. #FUSES NOMCLR //Pino Master Clear habilitado como porta I/O
  9. #FUSES NOLVP //Programação em baixa tensão desabilitada
  10. #FUSES NOCPD //Código desprotegido (permite a leitura)
  11.  
  12. //A frequencia do Clock Interno é de 1Mhz
  13. //A sentença abaixo informa ao compilador essa frequencia para que este
  14. //calcule corretamente os delays em mili-segundos
  15. #use delay(clock=1000000)
  16.  
  17. #define PINO_LED1 PIN_A0 //Define em qual pino o LED está ligado
  18. #define PINO_LED2 PIN_A1 //Define em qual pino o LED está ligado
  19. #define PINO_LED3 PIN_A2 //Define em qual pino o LED está ligado
  20. #define PINO_LED4 PIN_A3 //Define em qual pino o LED está ligado
  21.  
  22. //------------------------------------------------------
  23. // PROGRAMA PRINCIPAL
  24. //------------------------------------------------------
  25. void main() // Note que o programa no pic nunca deve terminar
  26. {
  27. while (1) //Loop infinito, por isso nunca acaba
  28. {
  29. output_bit( PINO_LED1, true); // Liga o Led
  30. delay_ms(500); // Espera 1000ms = 1 Segundo
  31. output_bit( PINO_LED1, false); // Desliga o Led
  32. delay_ms(100); // Espera 1000ms = 1 Segundo
  33. output_bit( PINO_LED1, true); // Liga o Led
  34. delay_ms(500); // Espera 1000ms = 1 Segundo
  35. output_bit( PINO_LED1, false); // Desliga o Led
  36. delay_ms(100); // Espera 1000ms = 1 Segundo
  37. output_bit( PINO_LED2, true); // Liga o Led
  38. delay_ms(500); // Espera 1000ms = 1 Segundo
  39. output_bit( PINO_LED2, false); // Desliga o Led
  40. delay_ms(100); // Espera 1000ms = 1 Segundo
  41. output_bit( PINO_LED2, true); // Liga o Led
  42. delay_ms(500); // Espera 1000ms = 1 Segundo
  43. output_bit( PINO_LED2, false); // Desliga o Led
  44. delay_ms(100); // Espera 1000ms = 1 Segundo
  45. output_bit( PINO_LED3, true); // Liga o Led
  46. delay_ms(500); // Espera 1000ms = 1 Segundo
  47. output_bit( PINO_LED3, false); // Desliga o Led
  48. delay_ms(100); // Espera 1000ms = 1 Segundo
  49. output_bit( PINO_LED4, true); // Liga o Led
  50. delay_ms(500); // Espera 1000ms = 1 Segundo
  51. output_bit( PINO_LED4, false); // Desliga o Led
  52. delay_ms(100); // Espera 1000ms = 1 Segundo
  53.  
  54.  
  55. } //Fim loop infinito
  56. }
Add Comment
Please, Sign In to add comment