Example: biology

Arduino - Reference - PlayRobot

ArduinoBuy | Download | Getting Started | Learning | Reference | Hardware | FAQ Blog | Forum | Playground Reference Language (extended) | Libraries | Comparison | BoardLanguage ReferenceSee the extended Reference for more advanced features of the Arduino languages and the libraries page for interfacingwith particular types of programs can be divided in three main parts: structure, values (variables and constants), and functions. The Arduinolanguage is based on C/C++.StructureAn Arduino program run in two parts:void setup()void loop()setup() is preparation, and loop() is execution.

Utilities cast (cast operator) sizeof() (sizeof operator) Reference keywords ASCII chart Atmega168 pin mapping Reference Home Corrections, suggestions, and new documentation should be posted to the Forum.

Tags:

  Arduino, Reference, Home, Arduino reference

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of Arduino - Reference - PlayRobot

1 ArduinoBuy | Download | Getting Started | Learning | Reference | Hardware | FAQ Blog | Forum | Playground Reference Language (extended) | Libraries | Comparison | BoardLanguage ReferenceSee the extended Reference for more advanced features of the Arduino languages and the libraries page for interfacingwith particular types of programs can be divided in three main parts: structure, values (variables and constants), and functions. The Arduinolanguage is based on C/C++.StructureAn Arduino program run in two parts:void setup()void loop()setup() is preparation, and loop() is execution.

2 In the setupsection, always at the top of your program, you would setpinModes, initialize serial communication, etc. The loopsection is the code to be executed -- reading inputs,triggering outputs, DeclarationFunction DeclarationvoidControl whilebreakcontinuereturnFurther Syntax; (semicolon){} (curly braces)// (single line comment)/* */ (multi-line comment)Arithmetic Operators+ (addition)- (subtraction)* (multiplication)/ (division)% (modulo)Comparison OperatorsFunctionsDigital I/OpinMode(pin, mode)digitalWrite(pin, value)int digitalRead(pin)Analog I/Oint analogRead(pin)analogWrite(pin, value) - PWMA dvanced I/OshiftOut(dataPin, clockPin, bitOrder, value)unsigned long pulseIn(pin, value)Timeunsigned long millis()delay(ms)delayMicroseconds(us)Ma thmin(x, y)max(x, y)abs(x)

3 Constrain(x, a, b)map(value, fromLow, fromHigh, toLow, toHigh)pow(base, exponent)sqrt(x)Trigonometrysin(rad)cos( rad)tan(rad)Random NumbersrandomSeed(seed)long random(max)long random(min, max)Serial CommunicationUsed for communication between the Arduino board and a== (equal to)!= (not equal to)< (less than)> (greater than)<= (less than or equal to)>= (greater than or equal to)Boolean Operators&& (and)|| (or)! (not)Compound Operators++ (increment)-- (decrement)+= (compound addition)-= (compound subtraction)*= (compound multiplication)/= (compound division)

4 VariablesVariables are expressions that you can use in programs tostore values, such as a sensor reading from an analog are particular values with specific | LOWINPUT | OUTPUT true | falseInteger ConstantsData TypesVariables can have various types, which are described intlongunsigned longfloatdoublestringarrayReferenceASCII chartcomputer or other devices. This communication happens viathe Arduino board's serial or USB connection and on digitalpins 0 (RX) and 1 (TX). Thus, if you use these functions,you cannot also use pins 0 and 1 for digital (speed)int ()int () () (data) (data)Didn't find something?

5 Check the extended Reference orthe HomeCorrections, suggestions, and new documentation should be posted to the text of the Arduino Reference is licensed under a Creative Commons Attribution-ShareAlike License. Code samples inthe Reference are released into the public Page | Page History | Printable View | All Recent Site ChangesArduinoBuy | Download | Getting Started | Learning | Reference | Hardware | FAQ Blog | Forum | Playground Reference Language (extended) | Libraries | Comparison | BoardArduino Reference (extended)The Arduino language is based on C/C++ and supports all standard C constructs and some C++ features.

6 It links against AVRLibc and allows the use of any of its functions; see its user manual for Arduino , the standard program entry point (main) isdefined in the core and calls into two functions in a () is called once, then loop() is called repeatedly(until you reset your board).void setup()void loop()Control whilebreakcontinuereturnFurther Syntax; (semicolon){} (curly braces)// (single line comment)/* */ (multi-line comment)#define#includeArithmetic Operators+ (addition)- (subtraction)* (multiplication)/ (division)% (modulo)Comparison Operators== (equal to)!

7 = (not equal to)< (less than)> (greater than)<= (less than or equal to)>= (greater than or equal to)FunctionsDigital I/OpinMode(pin, mode)digitalWrite(pin, value)int digitalRead(pin)Analog I/OanalogReference(type)int analogRead(pin)analogWrite(pin, value) - PWMA dvanced I/OshiftOut(dataPin, clockPin, bitOrder, value)unsigned long pulseIn(pin, value)Timeunsigned long millis()delay(ms)delayMicroseconds(us)Ma thmin(x, y)max(x, y)abs(x)constrain(x, a, b)map(value, fromLow, fromHigh, toLow, toHigh)pow(base, exponent)sqrt(x)Trigonometrysin(rad)cos( rad)tan(rad)Random NumbersrandomSeed(seed)long random(max)long random(min, max)External InterruptsattachInterrupt(interrupt, function, mode)detachInterrupt(interrupt)Boolean Operators&& (and)|| (or)!

8 (not)Pointer Access Operators* dereference operator& Reference operatorBitwise Operators& (bitwise and)| (bitwise or)^ (bitwise xor)~ (bitwise not)<< (bitshift left)>> (bitshift right)Port ManipulationCompound Operators++ (increment)-- (decrement)+= (compound addition)-= (compound subtraction)*= (compound multiplication)/= (compound division)&= (compound bitwise and)|= (compound bitwise or)VariablesConstantsHIGH | LOWINPUT | OUTPUT true | falseinteger constantsfloating point constantsData Typesvoid keywordbooleancharunsigned charbyteintunsigned intlongunsigned longfloatdoublestringarrayVariable Scope & QualifiersstaticvolatileconstPROGMEMI nterruptsinterrupts()noInterrupts()Seria l (speed)int ()int () () (data) (data)Utilitiescast (cast operator)sizeof() (sizeof operator)

9 ReferencekeywordsASCII chartAtmega168 pin mappingReference HomeCorrections, suggestions, and new documentation should be posted to the text of the Arduino Reference is licensed under a Creative Commons Attribution-ShareAlike License. Code samples inthe Reference are released into the public Page | Page History | Printable View | All Recent Site ChangesArduinoBuy | Download | Getting Started | Learning | Reference | Hardware | FAQ Blog | Forum | Playground Reference Language (extended)

10 | Libraries | Comparison | BoardLibrariesTo use an existing library in a sketch, go to the Sketch menu, choose "Import Library", and pick from the libraries will insert one or more #include statements at the top of the sketch and allow it to use the libraries are uploaded to the board with your sketch, they increase the amount of space it takes up. If a sketch nolonger needs a library, simply delete its #include statements from the top of your LibrariesThese are the "official" libraries that are included in the Arduino - reading and writing to "permanent" storageSoftwareSerial - for serial communication on any digital pinsStepper - for controlling stepper motorsWire - Two Wire Interface (TWI/I2C)


Related search queries