back


Introduction Arduino

Download: http://arduino.cc/en/Main/Software



Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It’s intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments.


Arduino can sense the environment by receiving input from a variety of sensors and can affect its surroundings by controlling lights, motors, and other actuators. The microcontroller on the board is programmed using the Arduino programming language (based on Wiring) and the Arduino development environment (based on Processing). Arduino projects can be stand-alone or they can communicate with software on running on a computer (e.g. Flash, Processing, MaxMSP).


Basically the board has the following input and output pins:


1.digital input (e.g. Switch)
2.digital output (e.g. LED on/off)
3.analog input (e.g. measuring values of a sensor)
4.analog outptut (z.B. dimming LED or controlling power DC-motor)


According to that the software has the following main functions in their syntax:


1.digitalRead(pin)
2.digitalWrite(pin, value)
3.analogRead(pin)
4.analogWrite(pin, value)


The board is programmed by using the Arduino programming language.



Introduction to the software Environment: http://arduino.cc/en/Guide/Environment


Pieces of code are also called sketches. The Arduino programming language is based on C.

There are two main basic functions:


1.) setup() function:

The setup() function is called when a sketch starts. Use it to initialize variables, pin modes, start using libraries, etc. The setup function will only run once, after each powerup or reset of the Arduino board.


2.) loop() function:

After creating a setup() function, which initializes and sets the initial values, the loop() function does precisely what its name suggests, and loops consecutively, allowing your program to change and respond. Use it to actively control the Arduino board.


Basic example how to switch on and off the LED on pin 13 which is already on the board:


int ledPin = 13;                // LED connected to Arduino-pin 13

void setup()
{
  pinMode(ledPin, OUTPUT);      // define ledPin as output
}

void loop()
{
  digitalWrite(ledPin, HIGH);   // turn LED on
  delay(1000);                  // wait for a second
  digitalWrite(ledPin, LOW);    // turn LED off
  delay(1000);                  // wait for a second
}