Where I describe how to use the servos() interface in AVR C.
Servos are a powerful addition to the embedded programming toolkit as they enable motion. Not high-speed motion as in a electric motor, however, motion which can be easily controlled and typically in an arc or as angles. Servos are much more precise as to how they can move in comparison to electric motors. See Sources above for a few example tutorials as to how to use them.
Where I describe how to develop use pointers in AVR_C.
Pointers are introduced by “K&R” with the following comment “Pointers have been lumped with the goto statement as a marvelous way to create impossible- to-understand programs.” While pointers are simple in nature, they can become quite complex, quickly. I recommend going through the examples on this page, slowly and methodically as well as making changes and determine if the change had the effects you believed it would. I also recommend having a C Language reference manual open as well, as I won’t got through the usage.
Where I demonstrate the value of coding efficiency to reduce the cost of hardware.
In the another entry, I discussed code size, program space and RAM requirements and why they matter. Here are my thoughts from that page:
Where I demonstrate how to use the C Language data type struct and how to use it to simplify a program.
As programs become more complicated, its desirable to group common elements into a “block”, then debug that block and have the block serve as a single debugged element. For example, a function can serve as a block of code which performs a set of commands commonly used together. Once debugged, the function can be called instead of the individual commands, simplifying debugging and code management.
Where I list all of the examples found in the examples folder for easy reference.
When using a specific function or while attempting to understand a C programming concept, it is helpful to see a working example. The examples below, (except where noted), have all been tested and work on an Arduino Uno.
Demonstrates analogRead() which reads the 10bit Analog-Digital Converter (ADC).
Where I discuss how to use PROGMEM (storing values in Flash memory) for storage.
Storing message strings in AVR RAM can become prohibitively expensive, very quickly. With only 2KB of RAM, the Uno needs as much RAM available for dynamic storage, while message strings are best stored in Flash memory. Due to the AVR microcontroller’s different architecture, you can’t simply read the Flash memory as reading RAM. You also can’t simply “embed” strings in Flash, by making them a constant, there are very specific commands to do both of these tasks.
Where I discuss marking time and measuring program execution time.
The Arduino has two time routines, millis() and micros(). The former provides the ability to measure time in milliseconds for a long period of time (50 days) and the latter provides the ability to measure in microseconds (kinda) for a far shorter period of time, 70 minutes. The kinda arises from this comment from the arduino reference on micros() “On 16 MHz Arduino boards (e.g. Duemilanove and Nano), this function has a resolution of four microseconds (i.e. the value returned is always a multiple of four). On 8 MHz Arduino boards (e.g. the LilyPad), this function has a resolution of eight microseconds.”
Where I describe the function - tone() as well as noTone() and how to play music on the Uno.
Using the function tone() allows us to play musical notes via the Uno and a speaker. Using tone() is more difficult than understanding the command. It requires having a understanding of music, songs and melodies to use tone() to its fullest.
We are also somewhat spoiled in this era of polyphonic speakers, that is speakers which are able to play multiple notes at once. The Uno and a simple cone speaker is only capable of playing a single tone, which limits the melodies and fidelity of the music played.
Where I develop the C version of multi-tasking, similar to the example provided by Adafruit.
An informative and valuable lesson on the Adafruit site is Multi-tasking the Arduino - Part 1. In this explanation, the author lays out how to “Make your Arduino walk and chew gum at the same time.” While it is phenomenal instructional content, the ultimate solution is a class approach which is not allowed in C. This entry will follow the content of the original, however, it will provide C-based solution.
Where I describe how to develop user functions in AVR_C.
While much of the content in “Developing in C for the ATmega328P” is focused on the Library functions, developing your own functions is an important aspect of programming in C. Functions help you structure your code into smaller, less complex modules. This allows you to debug each module, then as you develop your code and you will feel more confident that the program will work, if all modules are error-free.