Programming AVR pins in AVRStudio5 with C++

Controlling microcontroller pins is a first task you usually do when learning. With AVR it is simple you grab some chip and write simple code in C language. In order to output a logic level to AVR pin you only need couple lines of code where you set up port direction register and port itself. Pete takes use through all of this with different approach.

Having in mind that C code may grow in to mess without proper coding discipline, he suggests to try programing in C++. In AVRStudio5 it is easy – you only need to select cpp file instead of C when creating source. Keep in mind that cpp tends to grow in to bigger program size and lower speed as well. But sometimes speed isn’t main criteria. C++ is object oriented programming language so you get lots of handy techniques to achieve results. Arduino is already based on C++ so that end user could easily use prepared libraries. They sacrifice speed and size for easier coding experience. Anyway its your choice – use plain C (especially on smaller MCUs) and have better performance, or give a try with C++ and find it more modular and fun.

[..Source link..]

Bookmark the permalink.

Comments are closed.