Getting Started with Arduino - K9JM.COMk9jm.com/ArduinoGettingStarted.pdf · Getting Started with...

Preview:

Citation preview

Getting Started with Arduino

James Michener K9JM

These slides are available at

k9jm.com

Why Arduino?

It was designed as a teaching tool in Europe. The goal was to get the student up and running after the first day of class. Where one can start running real programs.

This is your first day of class….

And your second day of class….

What we will do: Getting started with

● Arduino IDE● Arduino Driver Install● Visual Studio + Visual Micro Arduino Extension● "Hello World" to a serial port / LCD● Example on-line of an Arduino RF voltmeter

Arduino Pros

● Up and running fast● Wide variety of hardware choices with a

common libraries and development platform● Built in / Intergrated: USB, Serial, EEPROM,

RAM, Flash, I2C, SDI, A/D, PWM● Full gcc g++ language support● Hundreds of prebuilt add on hardware

● LCD displays, touch screens, DDS, motor controllers, clocks, ethernet, WiFi, GSM

Arduino Con

Not good for big data / high speed applications.

Support only for C and C++ programming language. (no Java, Ruby, Lisp, Fortran, Python...etc)

Consider the Raspberry Pi, Beaglebone Black.... but you need to good at Unix

Step One:

Get a cup of coffee... especially if you're on DSL

Estimated time to download and install everything is two hours.

Download Arduino Software

● https://www.arduino.cc/en/Main/Software● Gets everything....

● Atmel gcc compilers● Libraries● Board Descriptions● Arduino IDE● Arduino Windows Drivers

Download Arduino Software

Hint:

I always go for the "Windows ZIP file for non admin install". The reason is, I can control where on my machine to install it AND (most important) you can have multiple versions of Arduino installed at one time. This is important when they come out with a new release (about every month).

Do you wish to donate?

Expand the zip file

The browser will save the zip file in it's 'download' directory.

Unzip the folder into your 'home' directory

(eg C:\Users\James )

This can be done by drag and dropping the folder

Short coffee break

Drag and Drop Folder from Zip

Make a desktop shortcutIn the new arduino directory, right click on arduino.exe and and click on 'create short cut'

Move short cut to desktop

● Drag and drop the short cut to the desktop● Rename the shortcut to Arduino-version#

● Hint: use F2 key for renaming a fime● Hint: you can delete the downloaded zip file

Double click on desktop icon

Uncheck 'Always ask before opening this file' and hit Run

Arduino IDE (Integrated Development Environment)

Driver Install

Note: Because you did not do an administrative install… Windows does not know where the Arduino drivers are located….

Plug in the USB cable connected to the Arduino and Windows will be unable to find the driver for this device.

Windows Fails to find driver. Hit Close

Open 'Computer Management' and look for an 'Unknown Device'

Right click on unknown device and select "Update driver software"

Then select Browse my computer for driver software

Browse to the Arduino driver directory

Say okay... and the driver is installed! Note the COM port

number

A better IDE

Earlier this year, Microsoft released FOR FREE, a version of their Visual Studio development suite call Visual Studio Community. They also opened up how to create

Visual Studio Community Download

https://www.visualstudio.com/downloads/download-visual-studio-vs

Install Visual Studio Community

● Either take a typical install, or custom, but make sure that C and C++ elements are installed!

● Installation can take up to an hour, so you might consider going for a walk.

Take either Typical or Custom

Minimum C++ and Extensibility Tools

Click Install

One hour later....Microsoft sign in

Sign in or create a new account

Just about there...

Visual Micro Install Extension

Open Visual Studio Community and in the menu select Tools, and Extensions and Updates.

On the left click on 'Online'

There are hundreds of extensions and pages of extensions!

Note: the '1 2 3 4 5 >' at the bottom, this selects the pages.Find the “Arduino IDE for Visual Studio”

Search for and select Arduino IDE Select and hit download

VSIX runs

Click okay... then click Restart Now

Enter location of Arduino IDE then hit OK

Added tool bars and menu items

Congratulations!

You are ready to go... more readinghttp://www.visualmicro.com/page/User-Guide.aspx

https://www.arduino.cc/en/Guide/HomePage

Hello World Example

● I used an I2C (TWI) LCD panel..less wires● Wiring – Clock = Uno pin A5 Data = Uno pin A4● Using I2C LCD ... what is the I2C Address??

● Warning I2C address is 7 bits and it may or may not be shifted left by one bit

● When in doubt 'sniff' it...

Important to understand about AVR Arduinos (eg Uno, Mega)

● Processors have very limited RAM● Uno has 2 kilobytes● Mega has 8 kilobytes

● Not much space for a 'heap'● Avoid using 'new' or 'malloc'● Avoid using STL● Avoid using RAM except as needed!

C / C++ notes

● Atmel compilier supports C++11● Not all Arduino libraries support C++11● Compilier supports C++11 STL changes● For AVR (Uno / Mega) avoid STL elements that

use malloc and new● Bottom line: Stick with C/C++ 98

Important to understand about AVR Arduinos (eg Uno, Mega)

● Processors use a 'Harvard Architecture'● Different instructions to address data or

SRAM● Data in Program Memory must be moved to

RAM

Important to understand about AVR Arduinos (eg Uno, Mega)

const char foo[] = "K9JM";

Serial.print("Hello World");

--- strings are in RAM!

const char foo[] PROGMEM = "K9JM";

Serial.print(F("Hello World"));

--- strings are in Program Memory

Arduino SAM processors(eg Due)

32 bit flat address space

96K of RAM

512K of Flash program memory

any 'const' is stored in Flash

Due compilier will properly handel (F(" ")) and PROGMEM functions, but are not required.

FYI

● Visual micro stores all objects and 'hex' files in a directory. Note: AppData is a hidden directory

/Users/James/AppData/Local/V.Micro/Arduino/Build

In case Visual Studio Express does not generate a desk top icon...

Go to this directory and right click on devenv.exe and click on 'Create shortcut'

Recommended