This is an old revision of the document!


Lab 02. Blinking LED

What you need

  • One Edison connected to Wyliodrin;
  • One LED;
  • One 200 Ohm resistor;
  • Two male-male jumper wires.

The Setup

Connect the LED to the Edison following the schematics the figure.

You will see when you look at the LED that it has two legs. One is longer, that one is usually the anode. This one has to be connected to the GPIO pin of the Edison. The shorter leg should to be connected to the resistor and then to the ground pin of the board. Although the position of the resistor is not fixed, it can can either connect the ground to the cathode or the anode to the GPIO pin, the cathode should be connected to the ground to obtain the usually desired behaviour. That means that we want the LED to light when the GPIO is set to HIGH and not to light when the GPIO is set to LOW. If you put the legs the other way around, the effect will be the opposite.

Streams programming language

Streams is an inbuilt programming language used in Wyliodrin to create many complex IOT projects.

It is quite different from usual programming languages, and it can sometimes contain visual blocks as functions.

This programming language works not as in imperative one, but is based on a data flow. The nodes will send messages to one another. You can look at these messages as JSON objects. Any message has two important fields: one will be the payload and a second one the topic. Any action in Streams starts with the run node. As you can see in its description, this node will set a payload at a certain interval. More specifically, you can choose in its settings to send the message at a certain time interval or at a specific time.

The Code

You go to the Wyliodrin Applications page and create a new application. You name it and select for the Streams programming language and select the example Led Blink - Streams. This will create an application that makes an LED connected to the pin 2 of the Edison to blink.

Once created, you click on the new application's name to open it. A new window will open to display it. In this example, the run node will send a message every 1 second to the node that says blink. Look in its settings. The payload field will be a number, incremented by one. The blink node is the one which holds the visual blocks. Double click on the latter to see the function inside. It will be in Visual Programming. What it does is to set a variable new message with the value of the data sent from this node to the next one to come. Now, this very message is composed like this: take the payload sent from the first node and divide it by 2. Which means the new message will be either 1 or 0. The function returns just one of these values, depending on the case. The last node is simply the digital write function. It will ask as a parameter for the pin number, so double click on it and specify the pin you are going to use. On this pin it will write the message that was previously composed.

Tips & Tricks

We said that usually the longer leg is the anode and the shorted one is the cathode. However, this is not standard, to make sure which is which, you should know that the cathode leg is always connected to the bigger part inside the LED.

Add a button

You can easily add a button to turn on and off the LED.

What you need

  • One Edison connected to \Wyliodrin;
  • Two 200 Ohm resistor;
  • Four male-female jumper wires;
  • Two male-male jumper wires;
  • One button;
  • One LED.

Schematics

To connect it, just think about the button as a voltage divider, the same as for the thermistor. Look in the introduction to electronics to properly understand the concept.

The code

You won't need to use more than 3 blocks.

  • one is the usual run
  • read the digital pin to which the button is connected
  • write its value on the pin where the LED is wired
iot/labs/02.1434983642.txt.gz ยท Last modified: 2015/06/22 17:34 by madalina.tanea
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0