Reader small image

You're reading from  C Programming for Arduino

Product typeBook
Published inMay 2013
Reading LevelIntermediate
PublisherPackt
ISBN-139781849517584
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Julien Bayle
Julien Bayle
author image
Julien Bayle

Julien Bayle owns his Master Degree of biology & computer sciences in 2000. After several years in pure IT System Design, he founded Design the Media early 2010 in order to provide his own courses, training & tools for art fields. As a digital artist, he designed some huge new media art installations, like the permanent exhibition of La Maison des Cinématographies de la Méditerranée (Château de la Buzine) in Marseille, France, in 2011. He also works as a new media technology consultant for some private & public entities. As an A/V live performer, he plays his cold electronic music from New York to Marseille, where he actually lives. Arduino framework is one of his first electronic hardware studies early 2005 and he designed the famous protodeck controller with some opensource framework too. As an art & technology teacher, also certified by Ableton in 2010, he teaches a lot of courses about the digital audio workstation named Ableton Live, about the real-time graphical programming framework Max6 and also about Processing and Arduino. As a minimalist digital artist, he works at the crossroads of sound, visual and data. He explores relationships between sounds and visuals through his immersive A/V installations, his live performances and his released music. His work, often described as “complex, intrigating and relevant”, tries to break classical codes to bring audience a new vision of our world through his pure digital and real-time generated stimuli. He's deeply involved in the open source community and loves to share and provide workshops and masterclasses online and on-site too. His personal website is http://julienbayle.net.
Read more about Julien Bayle

Right arrow

Making smart loops for repetitive tasks


A loop is a series of events repeating themselves in time. Basically, computers have been designed, at first, to make a lot of calculations repeatedly to save human's time. Designing a loop to repeat tasks that have to be repeated seems a natural idea. C natively implements some ways to design loops. Arduino core naturally includes three loop structures:

  • for

  • while

  • dowhile

for loop structure

The for loop statement is quite easy to use. It is based on, at least, one counter starting from a particular value you define, and increments or decrements it until another defined value. The syntax is:

for (declaration & definition ; condition ; increment) {
// statements
}

The counter is also named index. I'm showing you a real example here:

for (int i = 0 ; i < 100 ; i++) {
println(i);
}

This basic example defines a loop that prints all integers from 0 to 99. The declaration/definition of the integer type variable i is the first element of the for structure...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
C Programming for Arduino
Published in: May 2013Publisher: PacktISBN-13: 9781849517584

Author (1)

author image
Julien Bayle

Julien Bayle owns his Master Degree of biology & computer sciences in 2000. After several years in pure IT System Design, he founded Design the Media early 2010 in order to provide his own courses, training & tools for art fields. As a digital artist, he designed some huge new media art installations, like the permanent exhibition of La Maison des Cinématographies de la Méditerranée (Château de la Buzine) in Marseille, France, in 2011. He also works as a new media technology consultant for some private & public entities. As an A/V live performer, he plays his cold electronic music from New York to Marseille, where he actually lives. Arduino framework is one of his first electronic hardware studies early 2005 and he designed the famous protodeck controller with some opensource framework too. As an art & technology teacher, also certified by Ableton in 2010, he teaches a lot of courses about the digital audio workstation named Ableton Live, about the real-time graphical programming framework Max6 and also about Processing and Arduino. As a minimalist digital artist, he works at the crossroads of sound, visual and data. He explores relationships between sounds and visuals through his immersive A/V installations, his live performances and his released music. His work, often described as “complex, intrigating and relevant”, tries to break classical codes to bring audience a new vision of our world through his pure digital and real-time generated stimuli. He's deeply involved in the open source community and loves to share and provide workshops and masterclasses online and on-site too. His personal website is http://julienbayle.net.
Read more about Julien Bayle