Tutorial beginner 2:

Switch on a LED!

Content of the tutorial:

- Build a simple project.

- Build the hardware.

- Install the Arduino IDE.

- Load the Project files on Arduino.


Dear User, have you read the first tutorial?

It is important you have read it before to go on, otherwise you could not understand everything we are going to describe here.

So, let's start with the first very simple application example: how to switch on a Led.
Of course you can replace the Led with any other devices, as a Relay Switch for instance. In this case you can switch on or off whatever you want in your home. However let's keep the Led for simplicity of the exercise!

You can find the Project I'm going to describe in the drop-down list of examples in the Devise Home header area:

Actually it is a very simple and maybe not so useful example in real world, because there is no need to use an intelligent controller to merely switch on a Led.
Well, let's take this example for understanding purpose only. It is better to start with something very simple.


Build the Project

Even if this Project is ready to be loaded from the examples drop-down list, now I'm going to show you how to build it completely from scratch.

So, starting from an empty project, we need to add and configure the four objects that will compose the final Project. But before that we have also to fill the project properties.
Let's follow these steps:


1. Fill the Project Properties.

In this step very few things to do are required:

- Give the title of the Project, i.e. a slogan that remind you the purpose of the Project.

- Set your name and the name of your company if exists.

- Write a brief (max 80 characters) description of the Project.

That's it!


2. Add the controller (Arduino Uno).

When the project is empty, or when we click in a white area of the whiteboard, the available controllers that we can use for the project are shown in the upper right side of the screen.
Click over one controller and it will be added to the Project. You can drag it wherever you like in the whiteboard:

Now the controller that you have added is selected (rounded by a red rectangle) and the list of available devices that can be attached to is magically shown. Furthermore the list of properties is shown in the bottom right side of your screen.


3. Add the push button.

Let's click on the button:

Perfect! Now the button is connected to the controller: how is it connected? Uhm, something is missing... Yes, you are right... we still need to define what pin of the controller the button is connected to...
Actually the tool assigns automatically a pin. Well, if we want to change it, we can write the pin number in the box of the button properties.

Of course the pin number must be the one we will really connect when we will physically cable those components. Let's set the pin number 2.


4. Add the Led.

It's time to add the Led. The procedure is the identical as the button one. You can connect a a led or a relay or whethever you like. As before, don't forget to specify the pin number of the controller the led is connected to. Let's set the pin number 13.


5. Link the button to the led.

What does it mean? Link the button to the led means that we want that the action of the button is trasferred to the led. When we push the button, the led lights on!

As before, we are now going to perform one more very simple action.
Right click on the button on your project and a small menu will open: select 'Link to'.
An orange rectangle will appear around the led. That means that the led is a component that can be connected to the button. Now click on the led and magically they will be connected together through a new connection component that will be automatically placed between the two devices.

That's all!

Now its time to save and download the project, but I'm sure that you know how to do it, as the procedure has been described on the previous tutorial


Build the hardware

Once we have saved the downloaded zip file on our disk, how can we proceed to use it? First of all we have to cable the button and the led to the controller, than we need to load the downloaded file on Arduino. After that we can proceed with our test.
Let's go step by step.

The 'bill of material' is listed below:

- 1 Arduino Uno, the controller.

- 1 Push Button.

- 1 USB cable, to connect Arduino to the PC.

- 1 Small breadboard.

- Some pieces of unipolar cable.

And the Led? No, you don't need it. Actually led itself is already present on the Arduino board and is already connected to the pin 13.

The following picture shows all the connections needed by the devices:

Of course do not forget to connect the Arduino board to your PC through a usb cable or to a power supply.

I do not think I have to provide more info about the connection among those components, it seems to be very easy to do at this level. However, for any projects you design, you can click on the hardware connections button . It provides you a complete and detailed connection schema you can print out and use to build your system.


Install the Arduino IDE

Even if the complete documentation can be easily found on Arduino website, I will summarize the main operations needed to correctly load the files. The following instructions are applicable to all the future projects related to Arduino as well.

First you need to install the Arduino IDE! ... What? ... What is this?

Yes, unfortunately it is a mandatory step, but the good news is that you have to do it only once, only the first time!

The Arduino IDE is the application that allows you to write the programming code and to load it on Arduino. Don't worry, you don't have to write any code as you have just downloaded it, you need Arduino IDE to load the code on Arduino only!

Well, let's proceed with the installation. Here you can download the Arduino IDE

Once downloaded and installed, you can run the IDE and configure it: you have to do only two steps for now:

- select the type of Arduino: 'Arduino Uno' for this Project

- select the the USB port Arduino is attached to: something like COM10, but it could be a different number. My suggestion is to try different choices until it works.

Well, now it's time to get back to our project. We have just downloaded a zip file that is a container of other files:

- *.h file(s)

- *.ino file(s)

We should now create somewhere in the hard disk a folder that has exactly the same name of the two files without their extention: in our example the downloaded .zip file includes two files called sketch_dome_Uno_0.ino and sketch_dome_Uno_0.h, so create a folder called it is sketch_dome_Uno_0.
Once created, you have to extract the two files into this new directory.


Ok, now double click on the '*.ino' file and the IDE will be opened showing the content of this file inside its screen. You can see now the Arduino source code that implements the functionalities of your project, in our case switch on a led. Without Devise Home you should have handly written this code by yourself.

If you are able to do it, you can also modify this code to change the behavior of your project... But don't worry, basically it is not required at all. The code is fully working by itself.


Load the files on the Controller

What you have to do now is load the program on the controller. It is as usually very simple: click on the Load buttone shown in the picture below and wait a few time, less than one minutes. If the previous steps have been correctly executed, all your work is now ready to be tested!

As said before, the purpose of this simple example is to become familiar with Devise Home and with Arduino. It is not a real useful application. If you want to learn more and go inside more and more useful applications, you can go ahead and read the next tutorial!

<< - Index - >>