Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
knowledgebase:arduinoide [2017/11/29 14:34] rolex |
knowledgebase:arduinoide [2017/12/19 11:38] (aktuell) rolex |
||
---|---|---|---|
Zeile 12: | Zeile 12: | ||
| for(int x = 0; x < 100; x++){println(x)} | Set x to 0, then while x is less than 100, print X and increment x by 1 | | | for(int x = 0; x < 100; x++){println(x)} | Set x to 0, then while x is less than 100, print X and increment x by 1 | | ||
| while(statement){expression} | Keep doing expression while statement is true | | | while(statement){expression} | Keep doing expression while statement is true | | ||
- | | do{statement}while(expression); | + | | do{statement}while(expression); |
- | | | + | | switch(var){case |
- | | switch (var) {case 1: statement | + | |
| break; | Exit a for, while, do while loop or switch statement | | | break; | Exit a for, while, do while loop or switch statement | | ||
| continue; | Skip rest of current iteration of for, while, or do while loop, start next iteration | | | continue; | Skip rest of current iteration of for, while, or do while loop, start next iteration | | ||
| return value; | Terminate the function and optionally return value to the function that called it | | | return value; | Terminate the function and optionally return value to the function that called it | | ||
- | | goto label; | Send the program flow to `label:` | | + | | goto label; |Send the program flow to `label:` | |
== Comparison Operators == | == Comparison Operators == | ||
Zeile 25: | Zeile 24: | ||
| < | Less than | | | < | Less than | | ||
| > |Greater than | | | > |Greater than | | ||
- | | <= | Less than or equal to | | + | | < |
| >= | Greater than or equal to | | | >= | Greater than or equal to | | ||
== Boolean Operators == | == Boolean Operators == | ||
| && | And | | | && | And | | ||
- | | <code>||</code> | Or | | + | | <nowiki> || </nowiki> | Or | |
- | ! | + | | ! | Not | |
- | Not | + | |
- | Bitwise Operators | + | == Bitwise Operators |
- | & | + | | & | And | |
- | And | + | | < |
- | | | + | | ~ | Not | |
- | Or | + | | << |
- | ^ | + | | >> |
- | Xor | + | |
- | ~ | + | == Compound Operators |
- | Not | + | | x ++ | x=x+1 | |
- | << | + | | x -- | x=x-1 | |
- | Bitshift left | + | | x +=y | x=x+y | |
- | >> | + | | x -=y | x=x-y | |
- | Bitshift right | + | | x *=y | x=x*y | |
- | Compound Operators | + | | x /=y | x=x/y | |
- | x ++ | + | | x %=y | x=the remainder of x/y | |
- | x = x + 1 | + | | x & |
- | x -- | + | |
- | x = x - 1 | + | == Constants |
- | x += y | + | | HIGH/ |
- | x = x + y | + | | true/ |
- | x -= y | + | | LED_BUILTIN |
- | x = x - y | + | | pinMode(pin, |
- | x *= y | + | | digitalWrite(pin, |
- | x = x * y | + | | digitalRead(pin) |
- | x /= y | + | | analogReference(type) |
- | x = x / y | + | | analogRead(pin) |
- | x %= y | + | | analogWrite(pin, |
- | x = the remainder of x / y | + | |
- | x &= y | + | == Math == |
- | x = x & y | + | | min(x, |
- | x |= y | + | | max(x, |
- | x = x | y | + | | abs(x) |
- | Constants | + | | constrain(x, |
- | HIGH / LOW | + | | map(value, |
- | Pin input or output voltage is high or low | + | | pow(a, |
- | true / false | + | | sqrt(x) |
- | Boolean values | + | | sin(x) / cos(x) / tan(x) |
- | INPUT / INPUT_PULLUP / OUTPUT | + | | randomSeed(x) |
- | Configure pin to sample voltage or provide current to other circuits | + | | random(min, |
- | LED_BUILTIN | + | |
- | Pin where built-in LED is connected | + | == Time == |
- | I/O | + | | millis() |
- | pinMode(pin, | + | | micros() |
- | Set pin to either INPUT, OUTPUT, or INPUT_PULLUP | + | | delay(n) |
- | digitalWrite(pin, | + | | delayMicroseconds(n) |
- | Set pin to either HIGH or LOW | + | |
- | digitalRead(pin) | + | \\ |
- | Read value of pin, which will be HIGH or LOW | + | \\ |
- | analogReference(type) | + | mehr auf [[https://www.arduino.cc/ |
- | Configure refence voltage used for analog input | + | |
- | analogRead(pin) | + | |
- | Return input voltage of pin as integer between 0 and 1023 | + | |
- | analogWrite(pin, | + | |
- | Output PWM wave to pin with duty cycle of value (between 0 and 255) | + | |
- | Math | + | |
- | min(x, y) | + | |
- | Return the smaller of x or y | + | |
- | max(x, y) | + | |
- | Return the greater of x or y | + | |
- | abs(x) | + | |
- | Absolute value of x | + | |
- | constrain(x, | + | |
- | Limit x to the range a-b, return a or b if x is too small or too large | + | |
- | map(value, fromLow, fromHigh, toLow, toHigh) | + | |
- | Map value from one range of numbers to another | + | |
- | pow(a, x) | + | |
- | Calculate a to the power of x | + | |
- | sqrt(x) | + | |
- | Square root of x | + | |
- | sin(x) / cos(x) / tan(x) | + | |
- | Sine, cosine and tangent of x | + | |
- | randomSeed(x) | + | |
- | Start the pseudo-random number generator at point x | + | |
- | random(min, max) | + | |
- | Generate a pseudo-random number between min (inclusive) and max (exclusive) | + | |
- | Time | + | |
- | millis() | + | |
- | Return milliseconds since program started | + | |
- | micros() | + | |
- | Return microseconds since program started | + | |
- | delay(n) | + | |
- | Pause program for n milliseconds | + | |
- | delayMicroseconds(n) | + | |
- | Pause program for n microseconds | + | |
- | Comments | + | |
- | // stuff | + | |
- | Single-line comment | + | |
- | /* many things */ | + | |
- | Multi-line comment | + |