Optimized and ideal for large C programs, this small compact controller will suit the most demanding applications with heaps of features combined with high-speed operation. The PIC18F Microcontroller is loaded with features, including an optimized core for high speed operation. Full linear program memory addressing for the full k of program memory. Hardware implemented 8 x 8 Multiply instruction. Additional external memory can be easily added for up to 2MBytes. All the necessary support components are included, together with a Power and Programming LED for easy status indication.
|Published (Last):||7 January 2006|
|PDF File Size:||19.87 Mb|
|ePub File Size:||1.91 Mb|
|Price:||Free* [*Free Regsitration Required]|
I see a number of things that could help you improve your program. Fix the formatting Perhaps the indentation problem is partly a cut-and-paste problem when you put it into the question, but the resulting formatting is not good, with very little indenting of code.
Fix the bugs In this line if ev. In this code, d, f and ballmmoving are all unused according to my compiler also tells me that. Your compiler is probably also smart enough to tell you that, if you ask it to do so. Eliminate global variables My rewrite of this code uses no global variables, so clearly they are neither faster nor necessary. Eliminating them allows your code to be more readable and maintainable, both of which are important characteristics of well-written code.
Global variables introduce messy linkages that are difficult to spot and error prone. You should check the return values to make sure they did not. Eliminate "magic numbers" This code is littered with "magic numbers," that is, unnamed constants such as , 7, , etc. Break up the code into smaller functions Rather than having everything in one long function, it would be easier to read and maintain if each discrete step were its own function. Think of the user Right now there is no graceful way to end the game.
Something is awry. Use objects Each of the players, the field and the ball could all be objects which could simplify some things here. Consider transforming the code into a more object-oriented design.
PIC18F8722 Development Kit
PIC Analog to Digital Converter tutorial