Advertisement
Guest User

solarwind

a guest
Mar 8th, 2009
737
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.78 KB | None | 0 0
  1. #include "16F690_Test1.h"
  2.  
  3. int16 value;
  4.  
  5. void main() {    
  6.     setup_adc_ports(sAN0 | VSS_VDD);
  7.     setup_adc(ADC_CLOCK_DIV_64);
  8.     setup_spi(SPI_SS_DISABLED);
  9.     setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
  10.     setup_timer_1(T1_DISABLED);
  11.     setup_timer_2(T2_DISABLED,0,1);
  12.     setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
  13.     setup_oscillator(OSC_8MHZ);    
  14.            
  15.     while(TRUE) {
  16.         set_adc_channel(0);        
  17.         value = read_adc();
  18.         delay_us(100);                  //Give time for conversion to complete
  19.         output_c((int8) (value >> 6));  //Shift 4 MSBs into lower nibble
  20.         delay_us(40);                   //Simulate PWM to dim LEDs
  21.         output_c(0x00);
  22.         delay_us(10);
  23.     }    
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement