Програмування
Матеріал з мікроАмпер
Версія від 15:41, 22 червня 2016, створена Oogway (обговорення • внесок)
Мова програмування Arduino має три головні розділи: структура, дані (змінні та константи) і функції.
| Структура | Дані | Функції |
|
Константи | Цифрове введення/виведення |
| loop() | ||
| LOW | pinMODE() | |
| Оператори керування | OUTPUT | INPUT_PULLUP | digitalWrite() |
| LED_BUILTIN | digitalRead() | |
| if | false | |
| if...else | integer constants | Analog I/O |
| for | floating point constants | |
| switch case | analogReference() | |
| while | Типи даних | analogRead() |
| do... while | analogWrite() - PWM | |
| break | void | |
| continue | boolean | Лише для Due & Zero |
| return | char | |
| goto | unsigned char | analogReadResolution() |
| byte | analogWriteResolution() | |
| Синтаксис | int | |
| unsigned int | Розширене введення/виведення | |
| ; (semicolon) | word | |
| {} (curly braces) | long | tone() |
| // (single line comment) | unsigned long | noTone() |
| /* */ (multi-line comment) | short | shiftOut() |
| #define | float | shiftIn() |
| #include | double | pulseIn() |
| string - char array | ||
| Арифметичні оперетори | String - object | Час |
| array | ||
| = (assignment operator) | millis() | |
| + (addition) | Перетворення типів | micros() |
| - (subtraction) | delay() | |
| * (multiplication) | char() | delayMicroseconds() |
| / (division) | byte() | |
| % (modulo) | int() | Математичні дії |
| word() | ||
| Оператори порівняння | long() | min() |
| float() | max() | |
| == (equal to) | abs()- | |
| != (not equal to) | Область видимості змінної та специфікатори | constrain() |
| < (less than) | map() | |
| > (greater than) | variable scope | pow() |
| <= (less than or equal to) | static | sqrt() |
| >= (greater than or equal to) | volatile | |
| const | Тригонометрія | |
| Оператори Boolean | ||
| Допоміжні функції | sin() | |
| && (and) | cos() | |
| || (or) | sizeof() | tan() |
| ! (not) | PROGMEM | |
| Символи | ||
| Вказівники доступу | isAlphaNumeric() | |
| isAlpha() | ||
| * dereference operator | isAscii() | |
| & reference operator | isWhitespace() | |
| isControl() | ||
| Бітові оператори | isDigit() | |
| isGraph() | ||
| & (bitwise and) | isLowerCase() | |
| | (bitwise or) | isPrintable() | |
| ^ (bitwise xor) | isPunct() | |
| ~ (bitwise not) | isSpace() | |
| << (bitshift left) | isUpperCase() | |
| >> (bitshift right) | isHexadecimalDigit() | |
| Складені оператори присвоєння | Випадкові числа | |
| ++ (increment) | randomSeed() | |
| -- (decrement) | random() | |
| += (compound addition) | ||
| -= (compound subtraction) | Біти та байти | |
| *= (compound multiplication) | ||
| /= (compound division) | lowByte() | |
| %= (compound modulo) | highByte() | |
| &= (compound bitwise and) | bitRead() | |
| |= (compound bitwise or) | bitWrite() | |
| bitSet() | ||
| bitClear() | ||
| bit() | ||
| Зовнішні переривання | ||
| attachInterrupt() | ||
| detachInterrupt() | ||
| Переривання | ||
| interrupts() | ||
| noInterrupts() | ||
| Комунікація | ||
| Serial | ||
| Stream | ||
| USB (Лише для Due/Zero та плат на 32u4) | ||
| Keyboard | ||
| Mouse |
