English | 2013 | ISBN: 9781849517584 | 512 Pages | PDF | 10 MB
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.
What is a graphical programming framework?
A graphical programming frameworkis a programming language that provides a way for users to create programs by manipulating elements graphically instead of by typing text.
Usually, graphical programming languages are also called visual programming languages, but I’ll use “graphical” because, to many, “visual” is used for the product rendered by frameworks; I mean, the 3D scene for instance. Graphical is more related to GUI, that is, graphical user interface, which is, from the developer point of view, our editor interface (I mean, the IDE part).
Frameworks using this strong graphical paradigm include many ways of programming in which we can find data, data types, operator and functions, input and output, and a way of connecting hardware too.
Instead of typing long source codes, you add objects and connect them together in order to build software architectures. Think Tinker Toys or Legos.
A global software architecture, which is a system of objects connected and related on our 2D screen, is called Patchin the Max world. By the way, other graphical programming frameworks use this term too.
If this paradigm can be understood at first as a way of simplification, it is not the first purpose, I mean that not only is it easier, but it also provides a totally new approach for programmers and non-programmers alike. It also provides a new type of support task. Indeed, if we don’t program in the same way we patch, we don’t troubleshoot problems in the same way too.
Gen, for a new approach to code generation
If you understood that there was a kind of compilation/execution behind our patches, I’d disappoint you by saying it doesn’t really work like that. Even if everything works real time, there isn’t a real compilation.
confined to writing Max externals in C” even if it is totally possible using the Max 6 SDK (cycling74.com/products/sdk).
Genis a totally new concept.
Gen provides a way of patching patch bits that are compiled on the fly, and this is a real compilation from your patch. It provides a new type of patcher with specific objects, quite similar to Max objects.
It works for MSP, with the gen~Max object, providing a neat way to design signalrate related to audio patches architecture. You can design DSP and sound generators like that. The gen~patches are like a zoom in time; you have to consider them as sample processors. Each sample is processed by those patches inside the gen~patchers. There are smart objects to accumulate things over time, of course, in order to have signal processing windows of time.
Controlling software using hardware
Coming from pure digital realms where everything can be wrapped into software and virtual worlds, we often need physical interfaces. This can sound like a paradox; we want everything in one place, but that place is so small and user-unfriendly for everything related to pure creation and feelings that we need more or less big external (physical) interfaces. I love this paradox.
But, why do we need such interfaces? Sometimes, the old mouse and QWERTY keyboard don’t cut it. Our computers are fast, but these interfaces to control our programs are slow and clunky.
We need interfaces between the real world and the virtual world. Whatever they are, we need them to focus on our final purpose, which is usually not the interface or even the software itself.
Personally, I write books and teach art-related technology courses, but as a live performer, I need to focus on the final rendering. While performing, I want to blackbox as much as possible the technology under the hood. I want to feel more than I want to calculate. I want a controller interface to help me operate at the speed and level of flexibility to make the types of changes I want.
As I already said in this book, I needed a huge MIDI controller, heavy, solid, and complex, in order to control only one software on my computer. So, I built Protodeck (julienbayle.net/protodeck). This was my interface.
So, how can we use Arduino to control software? I guess you have just a part of your answer because we already sent data to our computer by turning a potentiometer.
Let’s improve our Max 6 patch to make it receive our Arduino’s data while we turn the potentiometer.
Improving the sequencer and connecting the Arduino
We are going to create a very cheap and basic project that will involve our Arduino board as a small sound controller. Indeed, we’ll directly use the firmware we just designed with the potentiometer, and then we’ll modify our patch. This is a very useful base for you to continue to build things and even create bigger controller machines.
Let’s connect the Arduino to Max 6
Arduino cancommunicate using the serial protocol. We already did that. Our latest firmware already does that, sending the voltage value.