Electgpl

PIC - Rele bluetooth de 4 canales

Nov 10th, 2015
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.70 KB | None | 0 0
  1. #include <16F876A.h>
  2. #use delay(clock=4000000)
  3. #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
  4. void main(){
  5.    char charIn;
  6.    printf("---------------------------\r");
  7.    printf("RELE BLUETOOTH DE 4 CANALES\r");
  8.    printf("  electgpl.blogspot.com.ar \r");
  9.    printf("---------------------------\r");
  10.    printf("-  q: B0=1  ---  a: B0=0  -\r");
  11.    printf("-  w: B1=1  ---  s: B1=0  -\r");
  12.    printf("-  e: B2=1  ---  d: B2=0  -\r");
  13.    printf("-  r: B3=1  ---  f: B3=0  -\r");
  14.    printf("---------------------------\r");
  15.    printf("\r");
  16.    while(true){
  17.       if(kbhit()){
  18.          charIn=getch();
  19.          switch(charIn){
  20.          case 'q':
  21.             output_high(PIN_B0);
  22.             printf("B0 ENCENDIDO\r");
  23.             break;
  24.          case 'a':
  25.             output_low(PIN_B0);
  26.             printf("B0 APAGADO\r");
  27.             break;
  28.          case 'w':
  29.             output_high(PIN_B1);
  30.             printf("B1 ENCENDIDO\r");
  31.             break;
  32.          case 's':
  33.             output_low(PIN_B1);
  34.             printf("B1 APAGADO\r");
  35.             break;
  36.          case 'e':
  37.             output_high(PIN_B2);
  38.             printf("B2 ENCENDIDO\r");
  39.             break;
  40.          case 'd':
  41.             output_low(PIN_B2);
  42.             printf("B2 APAGADO\r");
  43.             break;
  44.          case 'r':
  45.             output_high(PIN_B3);
  46.             printf("B3 ENCENDIDO\r");
  47.             break;
  48.          case 'f':
  49.             output_low(PIN_B3);
  50.             printf("B3 APAGADO\r");
  51.             break;
  52.          default:
  53.             output_low(PIN_B0);
  54.             output_low(PIN_B1);
  55.             output_low(PIN_B2);
  56.             output_low(PIN_B3);
  57.             break;
  58.          }
  59.       }
  60.    }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment