Book Image

C Programming for Arduino

By : Julien Bayle
Book Image

C Programming for Arduino

By: Julien Bayle

Overview of this book

Physical computing allows us to build interactive physical systems by using software & hardware in order to sense and respond to the real world. C Programming for Arduino will show you how to harness powerful capabilities like sensing, feedbacks, programming and even wiring and developing your own autonomous systems. C Programming for Arduino contains everything you need to directly start wiring and coding your own electronic project. You'll learn C and how to code several types of firmware for your Arduino, and then move on to design small typical systems to understand how handling buttons, leds, LCD, network modules and much more. After running through C/C++ for the Arduino, you'll learn how to control your software by using real buttons and distance sensors and even discover how you can use your Arduino with the Processing framework so that they work in unison. Advanced coverage includes using Wi-Fi networks and batteries to make your Arduino-based hardware more mobile and flexible without wires. If you want to learn how to build your own electronic devices with powerful open-source technology, then this book is for you.
Table of Contents (21 chapters)
C Programming for Arduino
Credits
About the Author
Acknowledgement
About the Reviewers
www.PacktPub.com
Preface
Index

About hardware prototyping


We can program and build software quite easily today using a lot of open source frameworks for which you can find a lot of helpful communities on the Web. I'm thinking about Processing (Java-based, check http://processing.org), and openFrameworks (C++-based, check http://www.openframeworks.cc), but there are many others that sometimes use very different paradigms like graphical programming languages such as Pure Data (http://puredata.info), Max 6 (http://cycling74.com/products/max/), or vvvv (http://vvvv.org) for Windows.

Because we, the makers, are totally involved in do-it-yourself practices, we all want and need to build and design our own tools and it often means hardware and electronics tools. We want to extend our computers with sensors, blinking lights, and even create standalone gears.

Even for testing very basic things like blinking a light emitting diode (LED), it involves many elements from supplying power to chipset low-level programming, from resistors value calculations to voltage-driven quartz clock setup. All those steps just gives headache to students and even motivated ones can be put off making just a first test.

Arduino appeared and changed everything in the landscape by proposing an inexpensive and all-included solution (we have to pay $30 for the Arduino Uno R3), a cross-platform toolchain running on Windows, OS X, and Linux, a very easy high-level C language and library that can also tweak the low-level bits, and a totally extensible open source framework.

Indeed, with an all-included small and cute board, an USB cable, and your computer, you can learn electronics, program embedded hardware using C language, and blink your LED.

Hardware prototyping became (almost) as easy as software prototyping because of the high level of integration between the software and the hardware provided by the whole framework.

One of the most important things to understand here is the prototyping cycle.

One easy hardware prototyping steps list

From our idea to our final render, we usually have to follow these steps.

If we want to make that LED blink, we have to define several blinking characteristics for instance. It will help to precisely define the project, which is a key to success.

Then we'll have to sketch a schematic with our Arduino board and our LED; it will dig the question, "How are they connected together?"

The firmware programming using C language can directly be started after we have sketched the circuit because, as we'll see later, it is directly related to the hardware. This is one of the strong powers of Arduino development. You remember? The board design has been designed only to make us think about our project and not to confuse us with very low-level abstract learning bits.

The upload step is a very important one. It can provide us a lot of information especially in case of further troubleshooting. We'll learn that this step doesn't require more than a couple of clicks once the board is correctly wired to our computer.

Then, the subcycle test and fix will occur. We'll learn by making, by testing, and it means by failing too. It is an important part of the process and it will teach you a lot. I have to confess something important here: at the time when I first began my bonome project (http://julienbayle.net/bonome), an RGB monome clone device, I spent two hours fixing a reverse wired LED matrix. Now, I know them very well because I failed one day.

The last step is the coolest one. I mentioned it because we have to keep in our mind the final target, the one that will make us happy in the end; it is a secret to succeed!