// adc_skel.c //A simple voltmeter with the ADC operating in 10 bit mode with no interrupts, //coarse ADC accuracy, no quiet mode. Skeletonized by R. Traylor 11.1.2016 #include #include #include #include #include "hd44780.h" uint8_t i; //dummy variable uint16_t adc_result; //holds adc result char lcd_str_h[16]; //holds string to send to lcd char lcd_str_l[16]; //holds string to send to lcd div_t fp_adc_result, fp_low_result; //double fp_adc_result; /*******************************************************/ void spi_init(void){ /* Run this code before attempting to write to the LCD.*/ DDRF |= 0x08; //port F bit 3 is enabling for LCD PORTF &= 0xF7; //port F bit 3 is initially low DDRB |= 0x07; //Turn on SS_n, MOSI, SCLK. SS_n must be out for MSTR mode //see: /$install_path/avr/include/avr/iom128.h for bit definitions //Master mode, Clock=clk/2, Cycle half phase, Low polarity, MSB first SPCR=(1<