At 01:52 PM 8/18/2004 -0500, you wrote: >OK, I have made a very rough sketch of how the program would work (in C): > >void define_frequency() { > //Do ADC > return x; >} void functions do not return values, maybe you want something like: int define_frequency(void) { int frequency; // the frequency in wombat-cycles per cow-acre // Do ADC and calculate return frequency; } Then you could write: int current_frequency; // the current frequency in w-c/c-a ... current_frequency = define_frequency(); >void define_duty() { > //Do ADC > return z; >} Ditto, and you could also use x, since the name will be local to the function. But it is nice to use variable names that mean something in most cases. I get the impression that you are expecting the variables to be global in scope. You need to learn the differences, and should (generally) avoid global variables in favor of automatic or static variables. While you are at it, learn what volatile and register mean. >for (x){ > if (z != 0){ > out_pin = 1; > } else { > out_pin = 0; > } > if (x == 0){ > define_frequency(); > define_duty(); > } else { > x--; > z--; > } > >} > >Am I doing this right? (my first C program.. lol) Assuming some appropriate declarations etc., it is almost a valid C program ("for" needs a different syntax), but I'm not sure it will do anything especially pleasant or desirable. Suggest you spend some time learning C in your desktop environment first. Best regards, Spehro Pefhany --"it's the network..." "The Journey is the reward" speff@interlog.com Info for manufacturers: http://www.trexon.com Embedded software/hardware/analog Info for designers: http://www.speff.com -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu