This is an old revision of the document!


Arduino

  1. Arduino tutorials (also can be found in IDE) http://arduino.cc/en/Tutorial/HomePage
  2. Google and own imagination 😉

There will be supply of leds, resistors, some sensors (light, temperature, IR …) and bunch of other arduino related stuff.

Programming for arduino is basically C language with some specific commands and libraries.

Smallest code, that sucessfully compiles looks like this:

void setup() {
}
 
void loop() {  
}

Here you have two functions, one for initial setup of variables, pins etc, and loop function that runs in infinite loop after setup as it's name suggests.

Now for some code, that actually does something usefull (blinking LED):

//global constant for more comprehensible code, you can use just number, 
//this way it is just more user friendly when handling multiple pins
int ledPin = 13; 
 
void setup() {
  // initialize digital pin 13 as an output, LED will be connected here  
  pinMode(ledPin, OUTPUT);
}
 
void loop() {
  //digitalWrite(pin, value) command is used to set voltageon pin to certain value
  //most usefull are constants HIGH and LOW, you don't need to use numbers
  digitalWrite(ledPin, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second, led is turned on
  digitalWrite(ledPin, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second, led is turned off
}

This code also requires some basic assembly, LED needs to be connected to arduino, it is recomended to use breadboard and some jumper wires, exact way is illustrated on image below.

<note important>When connecting LED, remember that LEDs are like in all diodes, so electricity flows in one direction only. The longer lead is positive (anode) needs to be connected to power and shorter leg (cathode) to ground.</note> <note warning>LEDs are not capable of handling arduino's 5V power, so resistor is required. Usually one which has 220Ω is used, but in this case it is not necessary to be exact, so you can use 200Ω or 300Ω as well and it will slightly affect brightness of LED, but nothing more.</note>