X hits on this document

162 views

0 shares

0 downloads

0 comments

37 / 51

4.6

The first programmes

Having the prototype ready and able to be connected with a PC, I started to write the first programs. A set of small prototypical examples are already developed in order to illustrate the basics of the media and the available commands of the language. These examples are available in the Wiring Examples sketchbook distributed with the application and from the Wiring web site in the Reference section.

The syntax is quite simple, and easy to learn. First the user must initialize the mode of the pins to be either output or input.

void setup() { int i; for(i=0; i<35; i++)// initializes pins 0 to 35 as outputs { pinMode(i, OUTPUT); }

}

And then in the loop function all one needs to do, is give the number of the particular LED you want to be lit (HIGH) and the duration (delay).

void loop() { digitalWrite(1, HIGH); delay(200); digitalWrite(1, LOW);

// sets on the num 1 // waits for 200 milli seconds // turns the num 1 off

}

The above example makes a LED to blink every 200 milli seconds.

A variety of different programmes was used as a means of testing the abilities of the wiring software as well as the prototype’s . Through such experimentations one comes across a number of bugs in the software, such as the random() function which does not work properly.

Physical Computing:

Using Everyday Objects as Communication tools

Fig. 51 The first programs

37

Document info
Document views162
Page views162
Page last viewedWed Dec 07 21:15:13 UTC 2016
Pages51
Paragraphs578
Words13463

Comments