Código feito no CCS C Compiler
#include <16F877A.h>
#device adc = 8
#FUSES NOWDT, HS, NOPUT, NOPROTECT
#FUSES NODEBUG, NOBROWNOUT, NOLVP, NOCPD, NOWRT
#use delay(clock = 20MHz)
//#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#use rs232(baud = 9600, parity = N, xmit = PIN_C6, rcv = PIN_C7, bits = 8, STREAM = Wireless)
#ifndef lcd_enable
#define lcd_enable pin_E1 // pino enable do LCD
#define lcd_rs pin_E2 // pino rs do LCD
//#define lcd_rw pin_e2 // pino rw do LCD
#define lcd_d4 pin_d4 // pino de dados d4 do LCD
#define lcd_d5 pin_d5 // pino de dados d5 do LCD
#define lcd_d6 pin_d6 // pino de dados d6 do LCD
#define lcd_d7 pin_d7 // pino de dados d7 do LCD
#endif
#include <mod_lcd.c>
unsigned int i = 0, tensao = 0;
signed int y = -50;
void main(){
setup_adc(ADC_CLOCK_DIV_16);
setup_adc_ports(AN0);
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
set_adc_channel(0);
delay_us( 50 );
lcd_ini();
while(true){
putc('A');
putc('\n');
putc('\r');
delay_ms(1000);
for(i = 1; i <= 10; i++){
//fprintf(Wireless,"%u %d\r", i, y);
printf(lcd_escreve, "%u %d\r", i, y);
delay_ms(1000);
if(++y > 50) y = -50;
}
}
}
Saída gerada no PicsimLab |
Nenhum comentário:
Postar um comentário