Sergiy Baydachnyy

Blog about technologies

Internet of Things: My first experience with Galileo (part 3)

leave a comment »

Published on MSDN Blog. Please, visit it for more great articles from Canadian DX team.

In the previous post we developed our first device based on digital outputs from Galileo board. Today I am going to show emulation of analog outputs.

But before we will start to create something I want to return to question about electric schemas. Frankly speaking I am not sure if I want to learn all symbols related to schemas but at the same time we need a tool which will help us show design of our schemas. In order to do it I am going to use a free, open-source application called Fritzing. This application was developed by University of Applied Sciences in Potsdam, Germany. You can download the tool here: http://fritzing.org and it contains links to versions for operation systems like Windows, Linux and OS X.

clip_image002

It’s too easy to recognize needed components, put them to a breadboard and understand if your circuit is completed. Just drag and drop needed components from the parts section to breadboard and connect them in order to make a route.

I tried to create a schema for the previous example and you can see the result below:

clip_image004

If you are not able to find some components here you can make search in Internet. For example, I found a better look of Galileo board on Intel Community site. I just clicked the Mine tab and imported “.fzpz” file there.

So, I just used Fritzing in order to show our next example.

clip_image005

Here we are going to use RGB LED in order to show digital outputs in pulse mode. RGB LED is able to show different colors based on RGB schema (R – red, G – green, B – Blue) and it allows different voltage for each lead (the longest lead relates to the ground; the shortest lead, near the ground, relates to red; the shortest lead, on opposite side, relates to blue color; last one relates to green). As I mentioned in the previous post, we are able to emulate analog output using the digital pins with mark “~”. So, let’s connect each lead of RGB LED to appropriate pins (like the image shows) and complete the circuit. We will need more 330 Ohm resistors in order to resist our voltage.

In order to emulate analog output we should use analogWrite method instead of digitalWrite. This method allows to vary parameter from 0 to 255 instead of High/Low and looks very simple in our example. This code will help to show basic color with RGB LED. It will help you to test your circuit and later you can change the parameters of color method in order to generate different colors.

#include "stdafx.h"
#include "arduino.h"

int _tmain(int argc, _TCHAR* argv[])
{
return RunArduinoSketch();
}

const int redPin = 6;
const int greenPin = 5;
const int bluePin = 3;

void setup()
{
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}

void color(unsigned char red, unsigned char green, unsigned char blue)
{
analogWrite(redPin, red);
analogWrite(bluePin, blue);
analogWrite(greenPin, green);
}

void loop()
{
color(255, 0, 0); // turn the RGB LED red
delay(10000);
color(0, 255, 0); // turn the RGB LED green
delay(10000);
color(0, 0, 255); // turn the RGB LED blue
delay(10000);
}

In the next article I am going to talk about digital and analog inputs and we will create more examples there.

Advertisements

Written by Sergiy Baydachnyy

11/22/2014 at 1:19 AM

Posted in IoT

Tagged with

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: