Arduino Manual PDF

Title Arduino Manual
Author mark ter
Course Creative Decisions& Dsgn
Institution Georgia Institute of Technology
Pages 31
File Size 1.5 MB
File Type PDF
Total Downloads 85
Total Views 159

Summary

manual for the arduino functions necessary for the course...


Description

Arduino Mechatronics Manual

Georgia Institute of Technology | ME2110: Creative Decisions and Design | 4-11-2019

Contents Getting Started Setup Steps Install Arduino IDE Windows Installation Mac OS X Installation Communicating With The Arduino

2 2 2 2 3 4

Introduction Install necessary libraries from GitHub

5 5

The Arduino UNO Why the Arduino? The ME 2110 Arduino Interface Board Writing an Arduino Sketch Arduino programming basics

7 7 8 9 9

Syntax If-else Conditions Loops Polling Using the ME2110 Library Callable Functions and Variables Miscellaneous

9 10 10 10 11 12 14

Electromechanical Components Digital vs Analog Signals Sensors

15 15 16

Switches IR Distance Sensor Potentiometer Encoder

16 17 18 19

Actuators DC Motors Solenoids

20 20 22

Pneumatics

23

Example Sketch

25

Reference

28 1

Getting Started This section will give quick references on how to get started with the Arduino Uno. However, to understand the Arduino Uno and how it is being used in ME2110, you must read through the rest of the manual.

Setup Steps ● Download Arduino software (IDE) ● Connect your Arduino to your computer ● Download necessary libraries

Install Arduino IDE The Arduino IDE (Integrated Development Environment) allows you to write programs and upload them to your Arduino. Have your Arduino board and USB cable near your computer. Do not plug them in yet. Download the latest version of the IDE from: arduino.cc/download Windows Installation 1. After finishing the download, navigate to your download path and double-click on “arduino-1.x.x-rx-windows.exe” (where the x depends on the version you downloaded). If a security warning window shows up, click on”Run” or “Allow” and accept the License Agreement. Click on “next” to choose the folder to install the IDE and click on “Install”. 2. Connect the Arduino board to the computer using a proper USB cable. The board will automatically draw power from the USB connection of the computer and the green LED (labeled ON) will turn on. 3. Windows should initiate its driver installation process when the board is plugged in. In some cases your computer won’t be able to find the drivers by itself. If so, you need to point it to the proper folder. ● Windows XP: If Windows Update asks about the path for the software, select “Yes, for this time only” and the “Install from a list or specific location” ● Other: A popup window asks you to install the driver automatically or to look for it in the computer, choose to look for the driver on your computer. 4. If the installation doesn’t start automatically, click on the Start Menu and open the device manager. 5. Look for the Arduino device under the category “Other Devices” or “Unknown Devices” and select “Update Driver” or “Update Driver Software” clicking with the right button of the mouse. 6. Click on “browse” and select the “Drivers” folder (not the folder “FTDI USB Drivers”) in the Arduino software IDE folder. Press “OK” and “Next”. If a dialog box about a test on the Windows Logo shows up, click on “Continue Anyway”. Windows will now install the driver. 7. In the “Device Manager”, under “Ports (COM & LPT)”, you should see a port similar to “Arduino Uno (COM4)”. 2

Mac OS X Installation 1. If you are using 10.8 (Mountain Lion) or later, go to System Preferences and open the “Security & Privacy” panel. In the “General” tab, under the heading “Allow applications downloaded from”, click the toggle for “Anywhere”. 2. Once the Arduino software IDE has finished downloading, double-click on the .zip file to expand the application 3. Coopy the Arduino application to the Applications folder, or anywhere else you wish to install the software. 4. Connect your Arduino board to the computer with the USB cable. The board will be automatically powered from the USB connection and the green LED (labeled ON) will turn on. 5. You do not need to install any drivers to work with the board. 6. Depending on the version of the OS X that you are running, you might get a dialog box asking if you wish to open the “system Preferences”. Click the “Network Preferences” button and click “Apply”. 7. The board will show up as “Not Configured”, but it is already working. You can quit System Preferences.

3

Communicating With The Arduino After the Arduino software IDE has been installed, you can now upload a program. 1. Open the Arduino IDE and appropriate program you would like to upload to the microcontroller. 2. Ensure that the correct Board Type has been selected under “Tools” (1) 3. Ensure that the correct Communication Port has been selected. (2) 4. Use the

button to verify the code does not have syntax or build errors. (3)

5. Use the button to upload the code to the Arduino. This will also verify the code, so Step 4 is optional.

Sample Arduino IDE Window

4

Introduction The rest of this manual contains all the information needed to be successful in using the arduino Uno in ME 2110: Creative Decisions and Design. It contains the steps required to get the necessary programs to get the Uno set up and running, a quick start to programming in the Arduino environment with examples, background information on the sensors and actuators (electromechanical components), and a wealth of other useful details.

Install necessary libraries from GitHub Download the “myDuino” libraries from GitHub. Login using your GaTech credentials if you are prompted. https://github.gatech.edu/TeamEPICS/ME2110_Arduino

5

Extract the files in the ZIP folder and move them into the “libraries” folder inside wherever your “Arduino” folder is located (should be located in Program Files x86).

When writing a new Arduino sketch, ensure that your code has #include at the top. Check Sketch >> Include Library to see if the library has been properly referenced.

6

The Arduino UNO

Simplified layout of the Arduino UNO microcontroller

Why the Arduino? The ME 2110 team is piloting multiple microcontrollers for the course, each with its own advantages and disadvantages. The class has been using the myRIO platform for some years now, with the manual noting that: “The reason is to introduce ME students to a professional programming environment used extensively in the industry and more importantly in the 3000 and 4000 level lab courses in the ME curriculum. The myRIO is significantly more powerful than typical embedded controllers (Arduinos, Raspberry Pi, TI Launchpad etc) thanks to its dual core ARM processor coupled with an FPGA. In addition, using LabVIEW’s toolboxes it is very simple to perform complex data processing actions like FFT’s, image processing, Real-Time control, neural networks etc. ME2110 is going to use only the very basic capabilities of the myRIO, but by doing so the students will be more familiar to high level devices to use in their future studies.” While the above is true, the myRIO and LabVIEW are not used extensively in industry outside of academic and research applications. Furthermore, many students have already been exposed to some high-level, general purpose programming language such as Java, Python, or MATLAB and will have some familiarity with coding, rather than having to learn the nuances of LabVIEW’s graphical coding scheme. The Arduino is arguably the simplest option to introduce students to programming and electromechanical systems. It uses a variant of C++ that is similar to Java and, to an extent, Python. Students who have had a course using MATLAB will have some familiarity with C++ functionality. Arduino also has an incredibly large support network; If you run into a coding or setup issue, there is likely an answer available online. The aim of using Arduino and the pre-coded libraries to minimize the coding burden as much as possible. However, we encourage you to continue exploring code, controls, and 7

electronics as the lines between mechanical engineering, electrical engineering, and computer science blur even further.

The ME 2110 Arduino Interface Board A custom circuit board has been designed and developed for this course. It connects directly to the Arduino’s header pins and uses two-piece prong connectors to attach to sensors and actuators. The tables and image below describe the connection points. Digital inputs

Connect to buttons, switches, banana plugs

Sensors (labelled)

Connect to encoder, IR sensor, potentiometer

Reset

Resets the program to run from setup()

LEDs (Colors vary)

Programmable indicators

Motor Pins (M1 & M2)

Connect to motors

Digital Outputs

Connect to valves, solenoids

It is important to note that the sensors (IR sensor, potentiometer, and encoder) require very specific wire connections. Failure to connect the correct wires to the corresponding terminals can result in poor readings or damage to components. See the Electromechanical Components Section of the manual to learn more about these connections. 8

Writing an Arduino Sketch Programs in Arduino are called “sketches.” This is where the microcontroller will read sensors and control actuators. The ME2110 library downloaded from GitHub handles most of the coding required, reducing the overall complexity of the coding portion. An in-depth discussion of the functions within the library is included later in this manual. Each time you initialize the Arduino IDE a new, blank sketch is opened for you. Every sketch in Arduino has two core functions prepopulated: 1. A s  etup function a. Anything you want to set up (variables, initial variable states, etc.) will be done here and run only once. 2. A l  oop function a. Once the setup function has run, the microcontroller will run this loop repeatedly. Generally, the bulk of your code will reside here.

Blank Arduino Sketch

Arduino programming basics As mentioned previously, Arduino uses a variant of C++ to run its programs. This manual will not go in-depth on programming C++ but for those who are interested, there are numerous tutorials and guides found online. The following is a brief outline of core structures and background information to set up your Arduino. Syntax Learning to write in C++ is somewhat similar to MATLAB. Key things to note are to remember to declare any variables and their type (int, char, etc.) before using them, use opening and closing curly braces ({}) for functions such as if   statements, and include semicolons at the end of function calls. 9

If-else Conditions An if statement is one of the basic logic building blocks - it is one of the ways you can use Python to make decisions. The basic layout of an if statement in English can be viewed as: If this condition has been met, then do task 1. If this other condition has  o task 3. been met, do task 2. O  therwise d Programmatically it can be represented in pseudocode as: if (c  ondition == True) { do task 1; } else if (other condition == True) { do task 2; } else {  do task 3; }

You can use multiple conditions to be met using and and or between conditions. More details can be found in the link below. https://www.arduino.cc/reference/en/language/structure/control-structure/if/ Loops Loops are an implementation of “if-else” statements. The code inside a loop will be run continuously until a number of iterations have passed (for loop) or until a condition is no longer true (while loop). The l  oop function that almost every Arduino program uses is an example of an infinite while loop. An example of a for loop could be: Do t ask 1 until the 5 iterations have passed Programmatically: for (int i = 0;  i...


Similar Free PDFs