Electgpl

PIC - Dimmer con Temp por BT o Serie UART

Jun 19th, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.13 KB | None | 0 0
  1. #include <16F883.h>
  2. #device adc=8
  3. #use delay(clock=4000000)
  4. #use rs232(baud=9600,parity=N,xmit=PIN_B7,rcv=PIN_B6,bits=8)
  5. #define LCD_ENABLE_PIN  PIN_A0
  6. #define LCD_RS_PIN      PIN_B4
  7. #define LCD_RW_PIN      PIN_B5
  8. #define LCD_DATA4       PIN_B0
  9. #define LCD_DATA5       PIN_B1
  10. #define LCD_DATA6       PIN_B2
  11. #define LCD_DATA7       PIN_B3
  12. #include <LCD.C>
  13. void main(){
  14.    setup_adc_ports(sAN1|VSS_VDD);
  15.    setup_adc(ADC_CLOCK_DIV_2);
  16.    setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
  17.    setup_timer_1(T1_DISABLED);
  18.    setup_timer_2(T2_DIV_BY_16,255,1);
  19.    setup_ccp1(CCP_PWM);
  20.    set_pwm1_duty(512);
  21.    setup_comparator(NC_NC_NC_NC);
  22.    lcd_init();
  23.    lcd_gotoxy(1,1);
  24.    printf(lcd_putc,"boot...             ");
  25.    delay_ms(1000);
  26.    unsigned int8 varInt, adc1;
  27.    while(TRUE){
  28.       varInt=getc();
  29.       set_pwm1_duty(varInt);
  30.       lcd_gotoxy(1,1);
  31.       printf(lcd_putc,"valor: %u         ",varInt);
  32.       delay_ms(100);
  33.       set_adc_channel(1);
  34.       adc1=read_adc()+13;
  35.       delay_us(60);
  36.       lcd_gotoxy(1,2);
  37.       printf(lcd_putc,"envia: %u         ",adc1);
  38.       printf("%u",adc1);
  39.       delay_ms(100);
  40.    }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment