Benutzer-Werkzeuge

Webseiten-Werkzeuge


knowledgebase:arduinoide

Dies ist eine alte Version des Dokuments!


Arduino IDE syntax

General Structure
setup() Run code once at beginning of program
loop() Loop code continuously
#define constantName value Replace all references to constantName with value at compile time

==

Equals

!=

Is not equal to

<

Less than

>

Greater than

Less than or equal to

>=

Greater than or equal to

Boolean Operators &&

And

||

Or

!

Not

Bitwise Operators &

And

|

Or

^

Xor

~

Not

«

Bitshift left

»

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

x |= y

x = 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.1511961933.txt.gz · Zuletzt geändert: 2017/11/29 14:25 von rolex