[PDF] Arduino Programming Language - MR FERGUSON



Previous PDF Next PDF







Arduino - Reference

Reference Language (extended) Libraries Comparison Board Language Reference See the extended reference for more advanced features of the Arduino languages and the libraries page for interfacing with particular types of hardware Arduino programs can be divided in three main parts: structure, values (variables and constants), and functions



Arduino Programming Language - MR FERGUSON

Introduction to Haptics Arduino Programming Language Allison M Okamura Stanford University (optional material for beginning programmers)



Arduino : Introduction & Programming

setup : It is called only when the Arduino is powered on or reset It is used to initialize variables and pin modes • loop : The loop functions runs continuously till the device is powered off The main logic of the code goes here Similar to while (1) for micro-controller programming



Arduino Programming Cheat Sheet - PatCostacom

- Arduino board drawing original by Fritzing AREF GND DIGITAL (PWM~) 13 12 ~11 ~10 ~9 8 7 ~6 ~5 4 ~3 2 TX→1 RX←0 L TX RX POWER ANALOG IN IOREF RESET 3 3V 5V GND GND Vin A0 A1 A2 A3 A4 A5 ON WWW ARDUINO CC - Made in Italy RESET ICSP 1 int1 int0 SDA SCL SCL SDA DC in sugg 7-12V limit 6-20V ATmega382: 16MHz, 32KB Flash (prog ), 2KB SRAM



Arduino Cheat Sheet-final-01

Title: Arduino_Cheat_Sheet-final-01 Created Date: 6/22/2011 3:35:13 PM



SCIENTIFIC ARDUINO PROGRAMMING

The design of Arduino boards is such that its form factor is (almost) independent on the Arduino version The rst Arduino boards used a microcontroller whose chip took a somewhat large space; nowadays the same chip is available in a much smaller form factor, however the size and the shape of the Arduino board is still the same (and in



Arduino: A Technical Reference

J M Hughes Arduino: A Technical Reference A Handbook for Technicians, Engineers, and Makers Beijing Boston Farnham Sebastopol Tokyo



Arduino Programming Cheat Sheet Primary source: Arduino

WWW ARDUINO CC - Made in Italy RESET ICSP 1 i n t 1 i n t 0 S D A S C L S C L S D A DC in sugg 7-12V limit 6-20V ATmega382: Arduino Language Reference http

[PDF] reference arduino francais pdf

[PDF] arduino pour les nuls pdf download

[PDF] arduino pour les nuls pdf gratuit

[PDF] programmation arduino pour les nuls pdf

[PDF] comment dessiner un cube sur papier

[PDF] patron d'un rectangle avec languette

[PDF] patron d'un parallélépipède rectangle

[PDF] construire un parallélépipède rectangle

[PDF] cylindre face arête sommet

[PDF] nombre d'arête d'un cone

[PDF] solides faces arêtes sommets

[PDF] face arête sommet exercices

[PDF] qu'est ce qu'une arête en géométrie

[PDF] solide 8 faces 12 sommets 18 aretes

[PDF] parallélépipède non rectangle

Arduino Programming Language - MR FERGUSON

Introduction to Haptics

Arduino Programming Language

Allison M. Okamura

Stanford University

(optional material for beginning programmers)

Programming Guidance

Stanford University Introduction to Haptics © Allison M. Okamura, 2014

Potential resources:

•Online courses (e.g., EdX, Udacity) •Web tutorials (Java or C programming languages are most appropriate) •Arduino-specific tutorials

In this class:

•You will start from existing programs (sketches) and modify them •The complexity of the programming you will do is low •Debugging can be difficult because of the real-time nature of haptic interaction •You should learn by doing. There is little you can do to damage your

Hapkit through programming mistakes!

We will start by going through some examples at

http://www.learn-c.org/

Arduino Programming Language Components

Stanford University Introduction to Haptics © Allison M. Okamura, 2014

Arduino reference materials obtained from http://arduino.cc under a Commons Attribution-ShareAlike 3.0 License.

StructureVariablesFunctions

Basic syntax

Arithmetic operators

Control structures

Comparison Operators

Boolean Operators

Constants

Data types

Scope

Digital I/O

Analog I/O

Math

Serial communication

Defining your own

Arduino Programming Language Components

Stanford University Introduction to Haptics © Allison M. Okamura, 2014

Arduino reference materials obtained from http://arduino.cc under a Commons Attribution-ShareAlike 3.0 License.

StructureVariablesFunctions

Basic syntax

Arithmetic operators

Control structures

Comparison Operators

Boolean Operators

Constants

Data types

Scope

Digital I/O

Analog I/O

Math

Serial communication

Defining your own

Structure: Basic Syntax

Stanford University Introduction to Haptics © Allison M. Okamura, 2014

Arduino reference materials obtained from http://arduino.cc under a Commons Attribution-ShareAlike 3.0 License.

Each statement ends in a semicolon. For example: int a = 13; Curly braces always come in pairs; they are used to define the start and end of functions, loops, and conditional statements. For example: while (boolean expression) statement(s)

Single line comment

Multi-line comment

Used to give a name to a constant value. For example: #define ledPin 3 #define

Structure: Arithmetic operators

Stanford University Introduction to Haptics © Allison M. Okamura, 2014

Arduino reference materials obtained from http://arduino.cc under a Commons Attribution-ShareAlike 3.0 License.

Assignment operator stores the value to the right of the equal sign in the variable to the left of the equal sign: sensorVal = analogRead(FSRPin); Addition, subtraction, multiplication, and division. For example: result = value1 + value2; result = value1 - value2; result = value1 * value2; result = value1 / value2; where value1 and value2 are any variables or constants Tips: •Choose variable sizes that are large enough to hold the largest calculated result •For math that requires fractions, use float variables (but there are drawbacks) •Check for order of operations; use parentheses to enforce order

Structure: Control structures

Stanford University Introduction to Haptics © Allison M. Okamura, 2014

Arduino reference materials obtained from http://arduino.cc under a Commons Attribution-ShareAlike 3.0 License.

Tests whether a certain condition has been reached. Used in conjunction with a comparison operator. For example: if (someVariable > 50) // do something here

Allows you to do multiple tests. For example:

if (force > 1) // action A else // action B if if...else

Structure: Control structures

Stanford University Introduction to Haptics © Allison M. Okamura, 2014

Arduino reference materials obtained from http://arduino.cc under a Commons Attribution-ShareAlike 3.0 License.

Creates a loop for repetitive operations.

for (initialization; condition; increment) { //statement(s); for

Structure: Control structures

Stanford University Introduction to Haptics © Allison M. Okamura, 2014

Arduino reference materials obtained from http://arduino.cc under a Commons Attribution-ShareAlike 3.0 License.

Allows you to specify different code that should be executed in various conditions. For example: switch (var) { case 1: //do something when var equals 1 break; case 2: //do something when var equals 2 break; default: // if nothing else matches, do the default // default is optional switch case

Structure: Comparison Operators

Stanford University Introduction to Haptics © Allison M. Okamura, 2014

Arduino reference materials obtained from http://arduino.cc under a Commons Attribution-ShareAlike 3.0 License.

The result of a statement with a comparison operator is either TRUE (1) or FALSE (2) x == y (x is equal to y) x != y (x is not equal to y) x < y (x is less than y) x > y (x is greater than y) x <= y (x is less than or equal to y) x >= y (x is greater than or equal to y) Tips: •Be careful not to accidentally use the assignment operator = instead of ==. •Cannot use statements such as 0 < x < 1; need to do each comparison separately

Structure: Boolean Operators

Stanford University Introduction to Haptics © Allison M. Okamura, 2014

Arduino reference materials obtained from http://arduino.cc under a Commons Attribution-ShareAlike 3.0 License.

Logical AND. True only if both operands are true, e.g. if (digitalRead(2) == HIGH && digitalRead(3) == HIGH) { // do this only if both inputs are high

Logical OR. True if either operand is true, e.g.

if (x > 0 || y > 0) { // do this if either x or y is greater than 0

NOT. True if the operand is false, e.g.

if (!x) { // do this if x is false (0)

Arduino Programming Language Components

Stanford University Introduction to Haptics © Allison M. Okamura, 2014

Arduino reference materials obtained from http://arduino.cc under a Commons Attribution-ShareAlike 3.0 License.

StructureVariablesFunctions

Basic syntax

Arithmetic operators

Control structures

Comparison Operators

Boolean Operators

Constants

Data types

Scope

Digital I/O

Analog I/O

Math

Serial communication

Defining your own

Variables: Constants

Stanford University Introduction to Haptics © Allison M. Okamura, 2014

Arduino reference materials obtained from http://arduino.cc under a Commons Attribution-ShareAlike 3.0 License.

When reading or writing to a digital pin, there are only two possible values a pin can take (or be set to): HIGH and LOW

Logical levels (result of a comparison):

false is defined as 0 true is defined as 1 (but more broadly, anything but 0) HIGH LOW true false 10.0

2.34E5

67e-12

2 101
3200
Decimal integersIn addition, integer and floating-point constants can be used:Floating point

Variables: Data types

Stanford University Introduction to Haptics © Allison M. Okamura, 2014

Arduino reference materials obtained from http://arduino.cc under a Commons Attribution-ShareAlike 3.0 License.

Used in function delcarations to indicate that the function returns no information. For example: void setup() void loop() A boolean holds one of two values, true or false. For example: boolean running = false; if (running) { // do something void boolean

Variables: Data types

Stanford University Introduction to Haptics © Allison M. Okamura, 2014

quotesdbs_dbs2.pdfusesText_2