Benutzer-Werkzeuge

Webseiten-Werkzeuge


knowledgebase:arduinoide

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

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