Grundkenntnisse Programmierung 6 (Arduino Pong Spiel): Unterschied zwischen den Versionen

Aus HSHL Mechatronik
Zur Navigation springen Zur Suche springen
Zeile 18: Zeile 18:


==OLED Display==
==OLED Display==
'''display.clearDisplay()''' = all pixels are off<br>
'''display.clearDisplay()''' --> all pixels are off<br>
'''display.drawPixel(x,y, color)''' plot a pixel in the x,y  coordinates<br>
'''display.drawPixel(x,y, color)''' --> plot a pixel in the x,y  coordinates<br>
'''display.setTextSize(n)''' = set the font size, supports sizes from 1 to 8<br>
'''display.setTextSize(n)''' --> set the font size, supports sizes from 1 to 8<br>
'''display.setCursor(x,y)''' = set the coordinates to start writing text<br>
'''display.setCursor(x,y)''' --> set the coordinates to start writing text<br>
'''display.print(“message”)''' = print the characters at location x,y<br>
'''display.print(“message”)''' --> print the characters at location x,y<br>
'''display.display()''' = call this method for the changes to make effect<br>
'''display.display()''' --> call this method for the changes to make effect<br>

Version vom 29. Juni 2023, 11:36 Uhr

const

  • Das const-Keywort steht für Konstanten.
  • Das bedeutet, dass die Variable wie alle anderen Variablen des gleichen Typs benutzt werden kann, aber dass der Wert unveränderlich ist.

#define oder const

  • Für Konstanten kann entwerder const oder #define verwendet werden.
  • Für Arrays muss const verwendet werden.

unsigned long

  • Kann keine negativen Zahlen speichern.
  • Bereich liegt zwischen 0 und 4,294,967,295 (2^32 - 1)

uint8_t

UINT8_t --> unsigned char
U --> unsigned ohne Vorzeichen
INT --> Integer
8 --> Bit länge
_t --> Kennung das ein Typ ist

OLED Display

display.clearDisplay() --> all pixels are off
display.drawPixel(x,y, color) --> plot a pixel in the x,y coordinates
display.setTextSize(n) --> set the font size, supports sizes from 1 to 8
display.setCursor(x,y) --> set the coordinates to start writing text
display.print(“message”) --> print the characters at location x,y
display.display() --> call this method for the changes to make effect