Processing with Intel Galileo

Page 1


1. Sketch in IDE Hi, we have already done preparing NUC and Galileo to communicate with each other. Now, let’s do a simplest task that can be done by Galileo. Nothing can be done by Galileo alone, though. Therefore, first we have to get help of NUC.

Now, click the IDE icon. You can see a blank sketch which has no source code. A sketch is the name that Galileo uses for a program. It’s the unit of code that is uploaded to and run on a Galileo board. At least, there are functions in a ‘sketch.’ They are ‘setup()’ and ‘loop()’ respectively. The setup function will only run once, after each powerup of Galileo board. Use it to initialize variables, pin modes, start using libraries, etc. The loop function repeats your source code consecutively, allowing your program to change and respond. You need to include both functions in your sketch, even if you don’t need them for anything. Let’s take a look at a simple ‘Sketch’ program.

2


2. Checking Serial Port and importing an example Always make sure that if ‘Board’ and ‘Serial port’ item in ‘Tools’ menu are correctly set at Galileo IDE. ‘Board’ is set well all the time, but sometimes ‘Serial port’ is not properly checked. Make sure that ‘COMx’ of ‘Serial port’ in ‘Tool’ menu is the same as ‘Galileo(COMx)’ under ‘Port (COM&LPT)’ of ‘Device Manager’. We are now going to flicker LED on the top of the Galileo board.

Go to File>Examples>01.Basics>Blink. See, new Sketch window is created. For the time being, we’ll use a text based language called ‘Processing’ to code programs for Galileo. Then, I’ll show you how later on to code a graphical language called ‘ArduBlock’ which is similar to ‘Scratch’ language. From now on, we will learn the way to convert ‘Processing’ langua ge in IDE by the ‘Upload’ icon so that Galileo can understand. This process is called ‘compiling.’

3


3. Blinking LED on Galieo through ‘Upload’ button

There are six tool bar buttons right under the line with ‘File’ and ‘Tools’ menus. They are ‘Verify,’ ‘Upload,’ ‘New,’ ‘Open,’ ‘Save,’ and ‘Serial Monitor’ respectively. Among them, the button with ‘Right-pointing arrow’ is for ‘Upload.’ Click on the ‘upload’ button. You will see some complicated messages on the bottom, black screen which is showing the process of ‘compiling.’ You will see the message ‘Transfer complete’ after it successfully transferred the data to the Galileo board’s storage.

Let’s see what change is made on the Galileo board. Only two of the LED was turned on before, but now the third LED is blinking. Why did such alteration occur? Let’s take a look at the source code. 4


4. Understanding Source Code of Sketch

Comments in a Sketch help you understand how your program works or to inform others how your program works. They are only readable by human. There are two different ways of marking comments. Single-line comments preceded by two forward slashes (//). Galileo compiler accept multiple lines comments beginning with a forward slash and asterisk combination (/*) ending with an asterisk and forward slash combination (*/). Do you see the number 13 in the source code? What do you think it means? Galileo has two connectors: the side close to USB ports mostly has digital pins and another side has analog and power pins. Through the result of ‘upload’ and compiling, we found out that the LED on the Galileo board is connected to the digital pin #13. There are two times of ‘delay(1000);’ in the bottom part of the Sketch. The number here represents microseconds. 1000 milliseconds is the same as 1 second. Change these numbers into 5000, 50, or else, and then press ‘upload’ button. You will be able to observe how the Galileo board’s LED changes.

5


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.