270 likes | 402 Vues
智慧電子應用設計導論 (1/3) Arduino Programming Language. Chin-Shiuh Shieh ( 謝欽旭 ) http://bit.kuas.edu.tw/~csshieh Department of Electronic Engineering National Kaohsiung University of Applied Sciences, Taiwan. Arduino Programming Language. Arduino – Tutorials http://arduino.cc/en/Tutorial/HomePage
E N D
智慧電子應用設計導論(1/3)Arduino Programming Language Chin-Shiuh Shieh (謝欽旭) http://bit.kuas.edu.tw/~csshieh Department of Electronic Engineering National Kaohsiung University of Applied Sciences, Taiwan C.-S. Shieh, EC, KUAS, Taiwan
Arduino Programming Language • Arduino – Tutorials • http://arduino.cc/en/Tutorial/HomePage • Arduino - Reference • http://arduino.cc/en/Reference/HomePage • Arduino – Libraries • http://arduino.cc/en/Reference/Libraries C.-S. Shieh, EC, KUAS, Taiwan
Structure • setup() • loop() C.-S. Shieh, EC, KUAS, Taiwan
Structure - Control Structures • if • if...else • for • switch case • while • do... while • break • continue • return • goto C.-S. Shieh, EC, KUAS, Taiwan
Structure - Further Syntax • ; (semicolon) • {} (curly braces) • // (single line comment) • /* */ (multi-line comment) • #define • #include C.-S. Shieh, EC, KUAS, Taiwan
Structure - Arithmetic Operators • = (assignment operator) • + (addition) • - (subtraction) • * (multiplication) • / (division) • % (modulo) C.-S. Shieh, EC, KUAS, Taiwan
Structure - Comparison Operators • == (equal to) • != (not equal to) • < (less than) • > (greater than) • <= (less than or equal to) • >= (greater than or equal to) C.-S. Shieh, EC, KUAS, Taiwan
Structure - Boolean Operators • && (and) • || (or) • ! (not) C.-S. Shieh, EC, KUAS, Taiwan
Structure - Pointer Access Operators • * dereference operator • & reference operator C.-S. Shieh, EC, KUAS, Taiwan
Structure - Bitwise Operators • & (bitwise and) • | (bitwise or) • ^ (bitwise xor) • ~ (bitwise not) • << (bitshift left) • >> (bitshift right) C.-S. Shieh, EC, KUAS, Taiwan
Structure - Compound Operators • ++ (increment) • -- (decrement) • += (compound addition) • -= (compound subtraction) • *= (compound multiplication) • /= (compound division) • &= (compound bitwise and) • |= (compound bitwise or) C.-S. Shieh, EC, KUAS, Taiwan
Variables - Constants • HIGH | LOW • INPUT | OUTPUT| INPUT_PULLUP • true | false • integer constants • floating point constants C.-S. Shieh, EC, KUAS, Taiwan
Variables - Data Types • void • boolean • char • unsigned char • byte • int • unsigned int • word • long • unsigned long • float • double • string - char array • String - object • array C.-S. Shieh, EC, KUAS, Taiwan
Variables - Conversion • char() • byte() • int() • word() • long() • float() C.-S. Shieh, EC, KUAS, Taiwan
Variables - Variable Scope & Qualifiers • variable scope • static • volatile • const C.-S. Shieh, EC, KUAS, Taiwan
Variables - Utilities • sizeof() C.-S. Shieh, EC, KUAS, Taiwan
Functions - Digital I/O • pinMode() • digitalWrite() • digitalRead() C.-S. Shieh, EC, KUAS, Taiwan
Functions - Analog I/O • analogReference() • analogRead() • analogWrite() - PWM C.-S. Shieh, EC, KUAS, Taiwan
Functions - Advanced I/O • tone() • noTone() • shiftOut() • shiftIn() • pulseIn() • pulseIn(2,HIGH); C.-S. Shieh, EC, KUAS, Taiwan
Functions - Time • millis() • micros() • delay() • delayMicroseconds() C.-S. Shieh, EC, KUAS, Taiwan
Functions - Math • min() • max() • abs() • constrain() • map() • pow() • sqrt() C.-S. Shieh, EC, KUAS, Taiwan
Functions - Trigonometry • sin() • cos() • tan() C.-S. Shieh, EC, KUAS, Taiwan
Functions - Random Numbers • randomSeed() • random() C.-S. Shieh, EC, KUAS, Taiwan
Functions - Bits and Bytes • lowByte() • highByte() • bitRead() • bitWrite() • bitSet() • bitClear() • bit() C.-S. Shieh, EC, KUAS, Taiwan
Functions - External Interrupts • attachInterrupt() • detachInterrupt() C.-S. Shieh, EC, KUAS, Taiwan
Functions - Interrupts • interrupts() • noInterrupts() C.-S. Shieh, EC, KUAS, Taiwan
Functions - Communication • Serial • Stream C.-S. Shieh, EC, KUAS, Taiwan