NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » My first .h file usage
January 24, 2011 by Ralphxyz |
Geesch I have only been doing this for a year now you'd think I'd gotten beyond this. So I have "tried" to use a .h file with my code. It actually worked the first time imagine that, first time success!! My .c code page was getting to cluttered so I decided to try to use a .h file for fixed (non changing) code. What I need is further instruction on how to clean up the .c file further. Here is the .c file followed by the .h file.
The PULSER.h file
I do not know what happen to the line numbers usually don't they appear when one highlights a code section? Maybe it's because of doing two code selections, well no matter I think you can see that it is readable code. So is this it? Like I said it works but it still looks kinda cluttered. Thanks again as always for your help. I have thick skin (I have been over on AVRfreaks and survived) so don't hedge your comments. Oh and if anyone wants to know how to flash a led based on a pot (Potentiometer) here you go. Put the pot wiper to PIN23 (PC0) and a LED on PIN18 (PB4). You will get a ADC: reading on the LCD as you do with the tempsensor project and a variable flashing LED depending on the position of the pot. Ralph |
---|---|
January 26, 2011 by Hexorg |
Ralphxyz, generally, you only put stuff like function declaration and pre-processor directives. Just have a look at what libnerdkits/delay.h and libnerdkits/delay.c has in common/different. My suggestion would be to make main.c file, that'd have the main() function, and add "#include "pulser.h" in it. In pulser.h put only function definitions:
and have pulser.c with code
then, when you compile, instead of running
run
|
January 31, 2011 by Ralphxyz |
Hexorg, this brings me to a edge of a cliff. I am probable going to jump off and try it but thought I'd ask for some help first. "then, when you compile, instead of running
run
I have never used the avr-gcc command I just do "make". So what do I use as a Makefile? Especially for pulser.c? I am completely lost here, but really appreciate your suggestion it almost makes sense (well it makes perfect sense I just have not fully comprehended it). Ralph |
Please log in to post a reply.
Did you know that any circuit of voltage sources and resistors can be simplified to a "Thevenin" equivalent circuit? Learn more...
|