//  Led.cpp - Library for blinking LED class.
//  This file corresponds to the part of the arduino code you want to pack in a class
//  By Hannes Oswald at CAAD Arch EtHZ, 04.02.2009
//  Created for learning purposes

#include "WProgram.h"				 // necessary line. basic functions that usually arduino code appends automaticaly
#include "Led.h"				 // includes the header file

Led::Led(int pin)                                // constructor function (no return variable)
{
        pinMode(pin, OUTPUT);
        _pin = pin;
}

void Led::blink(int times, int duration)         // all the function need to have this Classname::functionname syntax
{
        for(int i = 0; i < times; i++)		 // coding works the same as in arduino
        {		 				 // why it works eventhough i is not declared in the header file - I would like to know myself to
                digitalWrite(_pin, 1);
                delay(duration);
                digitalWrite(_pin, 0);
                delay(duration);
        }
}

This website has been archived and is no longer maintained.