Saturday, August 11, 2012

Nervous System - Arduino

The Arduino is an open-source electronics prototyping platform with a pretty large ecosystem of add ons.   The Arduino Environment runs on your PC and allows for the writing of code in a "C" like language that can then be downloaded to the Arduino to drive a multitude of connected devices.   The environment is written in Java which obviously makes it very portable between environments if a little pokey at times.

There are a wide variety of boards but I went with the Mega as I was not sure how many interfaces that I would ultimately need.   Besides, boys with their toys always favor a name like "Mega".
Having received the board I promptly connected it to my PC, downloaded the development environment, and made the on-board LED blink.  If nothing else I had the environment setup on my Ubuntu laptop and knew that the Arduino was alive.

/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
  This example code is in the public domain.
 */

// Pin 13 has an LED connected on most Arduino boards.

// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {               
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);    
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}


I actually didn't even write anything as the above is one of the many samples that comes with the Arduino environment!



No comments:

Post a Comment