0% found this document useful (0 votes)
15 views

BAPP [Com App] (1)

The document provides an overview of the Arduino platform, including its history, features, and programming basics. It covers the importance of microcontrollers, the open-source nature of Arduino, and how to create and upload sketches. Additionally, it discusses the use of shields to enhance functionality and the basic structure of Arduino programming language.

Uploaded by

agustinmakmak10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
15 views

BAPP [Com App] (1)

The document provides an overview of the Arduino platform, including its history, features, and programming basics. It covers the importance of microcontrollers, the open-source nature of Arduino, and how to create and upload sketches. Additionally, it discusses the use of shields to enhance functionality and the basic structure of Arduino programming language.

Uploaded by

agustinmakmak10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 54
Basic Arduino Platform Programming ROMEO G.. ANCHETA - ;zouzne Objectives + Learn the basics of Arduino and the features of the platform * Gain knowledge of the basic coding for sketches * Apply the knowledge on basic coding for simple applications * Analyze structures, variables and functions of a program or sketch * Upload sketches to the Arduino platform * Learn how to interface instrumentation devices, discrete components, and other third- party hardware with the Arduino platform © Create advanced codes capable of making decisions + Discuss potentials of the Arduino platform for projects * Visualize the applications of Arduino platform for automation of processes ARDUINO pileteconstol ei * Small computers * Microprocessors * Brain * Controb.unit * Program/Data storage * Peripherals (Input/Output) * Generally, a low cost computer Microcontrollers * History of Microcontrollers 1971 : '* Intel 4004 was released first microprocessor, ©1972 ‘ * 8008 was released and then 8080 +1975 t i * Intel 8048 was released + Intel President, Luke J. Valenter red RDUINS ae 1976 Se Flag, founded by. Eacehcs Fagin ¥ * Z80_ * Used in Gameboy = 1979 * Introduced Z8 2nuze0 Microcontrollers ° 1993 * Microchip eae 2 _ * PICL6x84 was feleased : LAY __ * First with EEPROM program memory Microcar +1993 = * Atmel * First mmlerocontroller with Flash memory Ait L ¢ At present mne * Companies follow what Atmel has started — zovz~e Why is it important? * Used in: * Automotive systems. * Airplanes P * Toys * Medical devices * instrumentation OO. Arduino sapuzweArduino: Start of infinite possibilities ¢ Hernando Barragan * Colombian student at Interaction Design Institute Ivrea {ivrea, Italy) * Thesis : “Arduino- The Revolution of Open Hardware” (2005) * Developed the programming platform : Wiring = ~J +) suzwo Arduino : An Introduction * Massimo Banzi, David Cuartielles, Tom Igoe, Gianluca Martino, and David Mellis. + New prototype board, later coined as: “Arduino” DUINO Arduino : An Introduction * ARDUINO + Named after a local bar in ivrea * “Arduino” is an italian masculine first name, meaning “strong friend" Arduino Team: )zoueno Arduino : An Introduction * Alternative to other Input/Output module e.g. National Instruments C wat National instruments SSSS * “Interactive Device” pattern: * Circuit that is able to sense the eqvicnifient using components called “sensors” and processing the information through “behaviour” implemented as software * Interact back with the world using “actuators” ee Behaviour Arduino : An Introduction Features: « USB programmable * Large community (supports open sourcing) * Inexpensive platform =e AnD uino : An Introduction ~~~ Atmel 328 Microcontroller ARDUINO Arduino Board Overview poe £ 3 = g lnirankicabebonde “ot t “ree zxo Arduino : An Introduction © ports - receive electrical signals from sensors and provide electrical signals to devices such as motors and relays Digital Ports Analog Ports = oe sRDUENO Arduino : An Introduction ARDUINO FAMILY Pro Mini Nano Micro ec Arduino : An Introduction * Arduino “clones” * Derivatives of the Arduino board * Boards designed by open source community as a result of Arduino’s “revealing the schematics of their own Arduino board * Derived from the Arduino hardware design but they innovate either by providing a different layout and features often to better serve a specific market * Production allowed by Arduino iu Arduino : An Introduction » Derivatives: * Boarduino * Funduino * Gizduino * Aceduino * Tinkduino *... “duino” ° “Ardu-”... * Specs may vary from variant to other variant red S OO: ino 168 ve Atmel. 168 Microcontroller wy Use Arduino? * Inexpensive alternative * Clones are: cheaper : t * Powerful board 5 * Capable of handling various inputs and outputs * Cross-platform (Windows, Mac, Linux) ¢ Open source © * Considers user experience (out-of the-box experience) * Appears less complex * Bare circultry (no enclosures) = simplicity Implied | ae Cheaper alternative to industrial system oO Why Use Arduino? * Progressing continuously * Future-proof OPENSOURCE? * Files are free! * Go to Arduino website and get what you need * Instructions * Schematics * Large community world wide which supports open source * Sharing of technology and projects * DIY; everyone has an opportunity to experience building their ideas into reality OPENSOURCE? MICROSOET YS APPLE * Take advantage of the technology being OPENSOURCE + “Free gift” to everyone oO * Development of Arduino reinforced the open source community ~ ¢ Developers share their-projects to the public ¢ Community helping each other * Teaching others how to deal with electronics the easy way * Learning by looking on the works of others OPENSOURCE? oO. Shields * Adds more function to the bare Arduino board * Extends the capability of the Arduino board * Can be plugged on top (or bottom) of the Gizduino * Different shields follow the same philosophy as the original toolkit: they are easy to mount, and cheap to produce * Stacking of shields use common pins with Arduino board a Shields * Data logger * Motor driver (servo, stepper, DC motor, etc.) * Relay driver * Timed circuits * DIY cellphone * Visualizer (LCD or LEDs) * Bluetooth controlled device * Transforms the Arduino board into: * More functions as you stack more types of shields oO. Shields * You can create your own shield! 3 MICROSD+LCD Shield CO. Creating your Shield using Fritzing * Free software for creating PCB * Install USB-to-Serial driver * Before installing the PL- 2303 Driver installer.exe, Rare aig make sure that the Pa Arduino board is [i Biren unplugged from your | amex os computer. | petnioe oe + Afterinctaflationof | yan em driver, plug the Arduino bh into the USB port = ¢ Go to Control Panel >> Device Manager. * Under the Ports section, check the COM Port for your Arduino. * Serial Port that you would connect to when uploading your code Hane drivers “p eomples “e hrdware Sina ary of libraries “reference J tools B ucuine Bleysicony-2all 8 cygwin. * Run the ARDUINO INTEGRATED DEVELOPMENT ENVIRONMENT (IDE) or the “arduino.exe’ file pivot dene FF ters OMELET _D Proc Ut SalCarn Pst COM . © Set appropriate Serial Port * Should be the same port number as shown in the device manager ed Arduino Development Environment * Interface for editing codes/programs for the Arduino board * Communicates to the board through the computer’s serial port * Codes are called Sketches * Language: Based on C & Wiring This is where you would code your programs cr sketches, |. Verify - Scans code for errors. 2. Upload - Compiles code and uploads it to the Arduino I/O board . New - Creates a new sketch. |. Open - Presents a menu of all the sketches in your sketchbook . Save - Saves sketch. . Serial Monitor - Opens serial monitor. ered, Ot? Arduino Development Environment structure The basic structure of the Arduino programming language is fairly simple and runs in at least two parts “functic seid soup H function to run in the program stun only once & cused to sat pin mode or initialize serial * statements; 2 ‘communication and/or global variables ‘yid.\ool..<. *Includes code to be executed { : continuously: reading inputs, triggering } statenents; = outputs, ete. ie score of all Arduino programs, does the bulk of the work. Both functions are required for the program to work Arduino Development Environment * void setup() and void loop () are required for the sketch to work * always enclose the statements with {} * void setup () initial setup which runs only during startup of the Arduino; initializes pin modes, variables, etc. * void loop () > loops the commands infinitely GO. Arduino Development Environment * Commenting on codes * For side notes, useful for debugging and analysing codes * Denoted by double slash called line comments( //) or enclosed by /* and */ called black comments. eo. /* Sample program. For workshop 1. void setup() { r ?/ put your setup code here, to run once: ) void loop() { // put your main code here, to run repeatedly: ) Arduino Development Environment OO Arduino Development Environment semicolon A semicolon must be used to end a statement and separate elements of the program. * Declaring variables ° Necessary when using the pins of Arduino board * Should start with a-character in the alphabet ¢ No spaces, no special character _ int Timetnitial; int Timelnitial = 0; int > integer type (whole numbers) float ® float type (include non-integer values) NOTE: always end a line with a semi-colon (;) OO. Arduino Development Environment arithmetic Arithmetic operators include addition, subtraction, multiplication, and division. They return the sum, difference, product, or quotient (respectively) of two operands. yey+3; X=X-7; i=} *6; rat /5; Inteinteger Float incides non integer Some basic commands * pinMode(pin, type) - sets pin as input or jue Ex. pinMode(13,OUTPUT); =i tpu * digitalWrite(pin,state)— writes the state to digital pin * LOW or HIGH = OFF or ON Ex. — digitalWrite(13,HIGH); digitalWrite(13,LOW); “> » analogRead(pin) - reads the ansiog value on the pin Ex. analogRead(A0); “Preacis a a + delay(millis) - pauses fora given time {inlitseconiis) Ex. delay(1000); “# pax. NOTE: coding is CASE-SENSITIVE!!! scond OO Some basic commands * analogWrite(pin,state)~ writes the value to a pulse width modulation (PWM) pin * 0-255 (LOW >>> HIGH) Ex. analogWrite(9,255); "Turn ON (1 analogWrite(9,0); furn OFY (0% analogWrite(9,127); turn OFF (50%) * digitalRead(pin) - reads the digital value on the pin Ex. digitalRead(2); "Preacs analog pin 2 NOTE: coding is CASE-SENSITIVE!!! CO Some basic commands comparison oper 01 Comparisons of one Variable or constant against another are often used in f statements to test if a epedified condition Is true. In the examples found on the following rages, 2? is Used 10 | aiy oe fellowing condone: Mf x ds: equal, // x is notvequal 4 // x as Less: ‘than. y- // x is greater than y” 7/ x 4s less than or equal to y 77x is greater than or saa toy wi HO C98 WAS. t <<<@8&x <5) © // true only if both ¢/ expressions are true Logical OR: if (x>@[{y> 0) // true if either 4/ expression is true Logical NOT: if (1x > 6) 4/ true only if /? expression is false Ka [s Some basic commands while i ‘while loo2s will loop continuously, and infinitely, until the expression inside the parenthesis becomes false. Something must change the tested variable, or the while loop wif never exif. This could be in your code, suich as an incremented variable, or en extemal condition, such as testing a sensor. waile (someVariable ?7 value) doSomething: “4 The following exampie tests whether 'someVariabic’ is fess than 200 aad if true executes the statements Inside the brackets and will continue looping unt ‘someVariable’ is no tonger fase than 200, while (someVariable < 208) // tests if less than 200 doSomething; {/ executes enclosed statements someVariabler+; 7/ increments variable by 1 e i

You might also like