Vous êtes sur la page 1sur 5
Arduino : Reference / Reference Reference Lanuuasc (extended) | branes | Comparsos | Board Language Reference See the extended reference for more advanced features ofthe Arduino languayes and the Ubvariss page for interfacing with parscuar types of herdware. Arduino programs ca “The Arduino fanguoge Is based on C/G Structure an Arduino program run la two parts: + void setae) vols lasa0) setup) 6 preparation, and loop) is execution. In the ‘Setup Section, always at the top of your program, You [Nould set pstiades,intalize serial communication, ete ‘The loop section isthe code to be executed ~ reading Inputs, tggering outputs, ete + Yasiable Dectaration| * function Declaration pend Control Structures: si 1D ittie Further Syntax + 4 (semicolon) + Ba (eur braces) + Ztsinate tne comment) + eZ (muting comment) Arithmetic Operators tadattion. 1 Fteubtraction) 2 (enutipieation) Lterision) $i (modo) Aivided in three main parts: structure, values (varaties and constants), and functions. Functions Digital 1/0 + intlade(pin, mode) * flatalite(pn, value) + Int cigtalRead(pin) ‘Analog 1/0 ‘int analoatead (in) 1 analaalnte(pin, value) ~ Pat ‘Advanced 1/0 *ESIROut(detaPin,cockPin,bitOrder, value) 1 nsioned long allsal(pin, vale) unsigned ing elt) Ca le) 1 douvticrseconds(us) math mia ¥) + max ¥) + ae) Constalas, a, 6) { man(vatie, romtow,fromHigh, tolow, toHigh) + pan(base, exponent) + sank) Trigonometry ‘strad) Sas(rad) + antres) Random Numbers ‘+ candomseed(seec) * Tong candam(max) * tong gaadam(min, max ‘Serial Communication ‘Used for communication between the Arduino board ‘and-a computer or other devices. This communication FRappens va the Arduno board's serial or USB ‘Comparison Operators connection and on digital pins O (RX) and 4 (TX). Thus, Ir you use these functions, you cannot aso use pins 0 “+ == (equal to) m0 for cgi Yo. + TE (not equal to) ‘(less than) 1S (greater than) *t a (less than or equal to) [BE (greater than oF equal to} ‘Boolean Operators 8 (and) + Le6n) + L(oot) Compound Operators + £4 (increment) (decrement) ‘(comoound subtracton) (Compound muttpication) 1 EE (compound division) ‘Variables “Variables are expressions that you can use in presrams. ‘to store values, such as a sensor reading from ar “Snaleg pin Constante Constante are particular values with specific meanings. Data Types Variables can have various types, which are described below. boolean, ‘char bus iat Reference Arduino : Reference / Extended Reference [Reference Languane (extended) | Litades | Comparisan | Soars Arduino Reference (extended) The Arduino language Is based on C/C++ and supports al standard C constructs and some C++ features. I links against AVR ibe and allows the use of any of ts functions; see Its user manual for details. Structure Functions In Arduino, the standard program entry point (main) is Bh at 1/0 Gefned inthe core ond cals into two furctons In 8 ‘atine(pin, mode) Sketch, setup() Is called once, then loop()'S ced > -ggtallisnpin, vide) epeatdy (ath you reset your beard), + neiataisesatpn) + void stun) Analog 1/0 + voi ane) * snalogefecenceltype) + Ineanalsaeaaton Control Structures + analeate(pn, value) - Pw “ Advanced 1/0 ise GOA Catain, clckfin, border, valued : + Gnsloned Fong pusein(, vue) 1 sich case his Time 2 dante unsigned fong mist) 1 he + telains) + coiinue 1 delntlecnascandsus) es Math Further Syntae + mints 1) + iaxo.) +: (eemislon) abate) 2 LGhy oreces 1 Eonstzan(s, a, ©) © Z.Gingle tne coment) 1 ImanWolue romtow,tretigh,toLow,tobigh) 2 EP Goutesine conmenty 5 naitbase exponent) + etn + sate) + ocude Arithmetic Operators + (adettion) + tantrad) 1 Ffeubtraction) a + Egutston Random Numbers + Se (modulo) + randomSend{seed) + Tong random(max) oe * tong candom(min, max) External Interrupts (equal ts) at equal to) (less than) (oreater than) Seas than or equal to) ‘greater than or equal to) attachluteruntinterrup, function, mode) * defachiateruitinterupt) Interrupts: Boolean Operators 1 Maines) + AB (ancy Serial Communication + He + L(000) + Setialbeain(speed) 1 int Serahavallapie() Pointer Access Operators 1 int Senabeeadt) 1 Sacatush0) = *cecoforence soerator 1 SteaLoint data) 1 Ritnterence operator + SeciaLacintin(¢ata) Bitwise Operators (bitwise and) L (bitwise on Ai(eitwise er) = (bitwise ret) Ze (ote) + EE (oitshin righty ‘+ Rost Manipulation Compound Operators (compound aadtien) {compound subtraction) (compound multipication) + (compound division) ‘= (compound bitwise and) 1 15 (compound bitwse or) ‘Variables stoca (Variable Scope & Qualifiers Utilities ‘+ cast (cast operator) * szeaf( (sizeof operator) Reference Corrections, suagestions, and new documentation should be posted tothe Eacum. “The text ofthe Arduino reference is licensed under a Creative Commons Attibution-ShareAlle 2.0 License. Code samples n the reference are released into the publle main ey

Vous aimerez peut-être aussi