Making Furniture Interactive

September 25, 2007

Example of how to post code

Filed under: Course Materials,Examples — jet @ 8:54 am

To post source code, you need to put a wrapper around it using “sourcecode”. Use the “Code” tab of the editor to insert the “sourcecode” tags, not the “Visual” tab. The “Visual” tab does all sorts of magic that will cause the “sourcecode” tag to not be recognized.

[sourcecode language="cpp"]

[put your source here]


* AnalogInput
* by DojoDave <>
* Turns on and off a light emitting diode(LED) connected to digital
* pin 13. The amount of time the LED will be on and off depends on
* the value obtained by analogRead(). In the easiest case we connect
* a potentiometer to analog pin 2.

// int cellPin = 0;    // select the input pin for the potentiometer
int ledPin = 12;   // select the pin for the LED
int cdsPin = 0;
int cdsVal =0;
int ledDelay =0;

void setup() {
pinMode(ledPin, OUTPUT);  // declare the ledPin as an OUTPUT
pinMode(cdsPin, INPUT);

void loop() {

cdsVal = analogRead(cdsPin);
ledDelay = cdsVal;

digitalWrite(ledPin, HIGH);  // turn the ledPin on
digitalWrite(ledPin, LOW);   // turn the ledPin off



Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Blog at

%d bloggers like this: