Raquel Gallego

Embedded programming

Arduino 1.0 "a layer on top of "C" language".

I have used Arduino to program the microcontroler.

Arduino is more user friendly as a platform,so I think is more realistic to learn how to use this one other than learning "C" programming.


I need this small scheme to program the input and output pins.


I have open one of the examples and edited it.

First thing is to understand Arduino works with 2 functions SETUP and LOOP.

What I have programm is the frecuency of the LED I have used on the board. I have stablish a variable ( m) so I can change anytime the speed of the blinking on the LED.

The other behave I have also program is what happens when I press the botton. The light is not blinking any more, it is constantly lighting up.


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

// This function calculates the average between 2 variables.
int media(int valor1, int valor2)
  int temp;
  temp = valor1 + valor2;  // addiction
  temp = temp / 2;        // sustraction
  return temp;            // return the value

void setup() {                
  // initialize the digital pin as an output.
  // Pin 8 has an LED connected on most Arduino boards:
  pinMode(8, OUTPUT);

void loop() 
  int m;
  int entrada;
  // reading the digital value of pin number 7
  entrada = digitalRead(7);

  // If the entry has value= 0 (button not pressed) blinking (the block between{}will execute)
  if (entrada == LOW) 
    m = media(400, 200);
    digitalWrite(8, HIGH);   // set the LED on
    delay(m);              // wait for a second
    digitalWrite(8, LOW);    // set the LED off
    delay(m);  // wait for a second
  else {  // if not, the LED will be active and turn on
    digitalWrite(8, HIGH);