NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » Math Problem
January 15, 2011 by Jalex |
Hi I didn't want to use a timer as the RC time constant is very short. 40 pf and 1.5 meg ohm I have a separate circuit board with a comparator that goes high when the input drops below .7 volts. An RC is connected to it's input. I am trying to get it to measure degrees of a trimmer cap. As you can see I added it to your code just to play around but I have some errors. It uses 2 input pins and 1 output pin to monitor the comparator. The third pin needs to trigger the math that adds the difference to the midway point. // initialload.c // for NerdKits with ATmega168 // mrobbins@mit.edu define F_CPU 14745600include <stdio.h>include <avr/io.h>include <avr/interrupt.h>include <avr/pgmspace.h>include <inttypes.h>include "../libnerdkits/delay.h"include "../libnerdkits/lcd.h"// PIN DEFINITIONS: // // PC4 -- LED anode int main() { // LED as output DDRC |= (1<<PC4); // Make Pin5 pin6 an input DDRC &= ~(1<<PC5); DDRC &= ~(1<<PC6); // turn on LED PORTC |= (1<<PC4); // int Result as 16 bit uint16_t Result = 0; // fire up the LCD lcd_init(); lcd_home(); // print message to screen // 20 columns wide: // 01234567890123456789 lcd_line_one(); lcd_write_string(PSTR(" Jim Alexander's ")); lcd_line_two(); lcd_write_string(PSTR("****")); lcd_line_three(); lcd_write_string(PSTR(" First Program ")); lcd_line_four(); lcd_write_string(PSTR(" is alive and well ")); // I am trying to just add 3 digit integer to the end of the forth line. //fprintf_P(&lcd_stream, PSTR(is alive and well: %.3f"), Result); // turn off that LED PORTC &= ~(1<<PC4); // busy loop while(1) {
// error is expected ";" before "(" token
} return 0; } |
---|
Please log in to post a reply.
Did you know that an electroluminescent backlight for an LCD panel requires hundreds of volts AC to run? Learn more...
|