Advertisement
Guest User

INTERRUPÇÃO BLUETOOTH

a guest
Apr 25th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. //Utiliza interrupcao serial para receber comandos enviados via bluetooth
  2. #include "SanUSB1.h"
  3. short int pisca=0;
  4. unsigned char comando;
  5. char nome[]
  6.  
  7. #pragma interrupt interrupcao
  8. void interrupcao() {
  9. if (serial_interrompeu) {
  10. serial_interrompeu=0;
  11. comando = le_serial();
  12. switch (comando){
  13. case 'L':
  14. pisca=0; nivel_alto(pin_b7); //Não imprime (printf) dentro da interrupcao
  15. break;
  16. case 'D':
  17. pisca=0; nivel_baixo(pin_b7);
  18. break;
  19. case 'P':
  20. pisca=1;nivel_alto(pin_b7);
  21. break;
  22. }
  23. }
  24. }
  25.  
  26. void main(){
  27. clock_int_4MHz();
  28. habilita_interrupcao(recep_serial);
  29. taxa_serial(19200);
  30. while(1){
  31. if (!entrada_pin_e3){Reset();} // pressionar o botão no pino 1 para gravação
  32. while (pisca==1){
  33. inverte_saida(pin_b7);tempo_ms (300);
  34. }//pisca rapido
  35. sendrw((rom char *) "SanUSB ");//envia de forma sem fio a palavra para o PC ou Android
  36. tempo_ms (2000);
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement