Benutzer-Werkzeuge

Webseiten-Werkzeuge


knowledgebase:arduinoide

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen Revision Vorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
knowledgebase:arduinoide [2017/11/29 14:22]
rolex
knowledgebase:arduinoide [2017/12/19 11:38] (aktuell)
rolex
Zeile 1: Zeile 1:
 ==== Arduino IDE syntax ==== ==== Arduino IDE syntax ====
 == General Structure == == General Structure ==
-  setup() +setup() Run code once at beginning of program 
-Run code once at beginning of program\\  +| loop() | Loop code continuously | 
 +| #define X value | Replace all references to X with value at compile time | 
 +| #include library | Include library in sketch and access its functions |
  
-  loop() +== Control Structures == 
-Loop code continuously\\ +| if (expression A) {do thing A} | Do thing A if expression A is true | 
 +| else if (expression B) {do thing B} | Do thing B if expression A is false and expression B is true |  
 +| else {do thing C} | Do thing C if all the above "if" and "else if" blocks are false |  
 +| 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 | 
 +| do{statement}while(expression); | Like while loop, except expression is evaluated after statement runs once | 
 +| switch(var){case X: statement X break; case Y: statement  break;} | Run statement X or Y depending on whether var is X, Y or a different value | 
 +| 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 | 
 +| return value; | Terminate the function and optionally return value to the function that called it | 
 +| goto label; |Send the program flow to `label:` |
  
-  #define constantName value +== Comparison Operators == 
-Replace all references to constantName with value at compile time// +| == | Equals | 
-  #include library +| != | Is not equal to | 
-Include library in sketch and access its functions/+| < | Less than | 
 +| > |Greater than | 
 +| <nowiki> <= </nowiki> | Less than or equal to | 
 +| >= | Greater than or equal to |
  
-== Control Structures == +== Boolean Operators == 
-  if (expression A) {do thing A} +| && | And | 
-Do thing A if expression A is true// +<nowiki|| </nowiki> | Or 
-  else if (expression B) {do thing B} +Not | 
-Do thing B if expression A is false and expression B is true//  + 
-  else {do thing C} +== Bitwise Operators == 
-Do thing C if all the above "if" and "else if" blocks are false//  +And | 
-  for(int x = 0; x < 100; x++){println(x)} +<nowiki> | </nowiki>Or | 
- Set x to 0, then while x is less than 100, print X and increment x by 1 +Not | 
-while(statement){expression} +<< Bitshift left | 
- Keep doing expression while statement is true +>> Bitshift right | 
-do{statement}while(expression); + 
- Like while loop, except expression is evaluated after statement runs once +== Compound Operators == 
-switch (var) {case 1: statement A break; case 2: statement B break; default: statement C break} +x ++ x=x+1 | 
- Run statement A, B or C depending on whether var is 1, 2 or a different value +x -- x=x-1 | 
-break; +x +=y x=x+y | 
- Exit a for, while, do while loop or switch statement +x -=y x=x-y | 
-continue; +x *=y x=x*y | 
- Skip rest of current iteration of for, while, or do while loop, start next iteration +x /=y x=x/y | 
-return value; +x %=y x=the remainder of x/y | 
- Terminate the function and optionally return value to the function that called it +x &=y x=x&y | 
-goto label; + 
- Send the program flow to `label:` +== Constants == 
-Comparison Operators +HIGH/LOW Pin input or output voltage is high or low | 
-== +true/false Boolean values | 
- Equals +LED_BUILTIN Pin where built-in LED is connected | 
-!= +pinMode(pin, mode) Set pin to either INPUT, OUTPUT, or INPUT_PULLUP | 
- Is not equal to +digitalWrite(pin,value) Set pin to either HIGH or LOW| 
-< +digitalRead(pin) Read value of pin, which will be HIGH or LOW | 
- Less than +analogReference(type) Configure refence voltage used for analog input | 
-> +analogRead(pin) Return input voltage of pin as integer between 0 and 1023 | 
- Greater than +analogWrite(pin,value) Output PWM wave to pin with duty cycle of value (between 0 and 255) | 
-<+ 
- Less than or equal to +== Math == 
->+min(x,y) Return the smaller of x or y | 
- Greater than or equal to +max(x,y) Return the greater of x or y | 
-Boolean Operators +abs(x) Absolute value of x | 
-&& +constrain(x,a,b) Limit x to the range a-b, return a or b if x is too small or too large | 
- And +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 | 
- Or +sqrt(x) Square root of x | 
-! +sin(x) / cos(x) / tan(x) Sine, cosine and tangent of x | 
- Not +randomSeed(x) Start the pseudo-random number generator at point x | 
-Bitwise Operators +random(min,max) Generate a pseudo-random number between min (inclusive) and max (exclusive) | 
-& + 
- And +== Time == 
-| +millis() Return milliseconds since program started | 
- Or +micros() Return microseconds since program started | 
-+delay(n) Pause program for n milliseconds | 
- Xor +delayMicroseconds(n) Pause program for n microseconds | 
-~ + 
- Not +\\ 
-<< +\\ 
- Bitshift left +mehr auf [[https://www.arduino.cc/reference/en/ | Arduino Reference ]] und in unseren Arduino Workshops.
->> +
- Bitshift right +
-Compound Operators +
-x ++ +
- x = x + 1 +
-x -- +
- x = x - 1 +
-x += y +
- x = x + y +
-x -= y +
- x = x - y +
-x *= y +
- x = x * y +
-x /= y +
- x = x / y +
-x %= y +
- x = the remainder of x / y +
-x &= y +
- x = x & y +
-|= y +
- x | y +
-Constants +
-HIGH / LOW +
- Pin input or output voltage is high or low +
-true / false +
- Boolean values +
-INPUT / INPUT_PULLUP / OUTPUT +
- Configure pin to sample voltage or provide current to other circuits +
-LED_BUILTIN +
- Pin where built-in LED is connected +
-I/O +
-pinMode(pin, mode) +
- Set pin to either INPUT, OUTPUT, or INPUT_PULLUP +
-digitalWrite(pin, value) +
- Set pin to either HIGH or LOW +
-digitalRead(pin) +
- Read value of pin, which will be HIGH or LOW +
-analogReference(type) +
- Configure refence voltage used for analog input +
-analogRead(pin) +
- Return input voltage of pin as integer between 0 and 1023 +
-analogWrite(pin, value) +
- 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, a, b) +
- 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 +
knowledgebase/arduinoide.1511961738.txt.gz · Zuletzt geändert: 2017/11/29 14:22 von rolex