User Tools

Site Tools


projekte:sekwai:rp2040_arduino

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
projekte:sekwai:rp2040_arduino [2025/08/01 20:55] – [FQBNs] dominikprojekte:sekwai:rp2040_arduino [2025/08/02 06:23] (current) – [Bootmodus RP2040] dominik
Line 1: Line 1:
 ====== RP2040 Arduino ====== ====== RP2040 Arduino ======
 +
 +===== Automount RPi Headless =====
 +  * https://github.com/fasteddy516/pi-usb-automount
 +  * ''cd ~ && wget https://github.com/fasteddy516/pi-usb-automount/releases/latest/download/pi-usb-automount.deb''
 +  * ''sudo dpkg -i pi-usb-automount.deb''
 +
 +===== Bootmodus RP2040 =====
 +Der RP2040 (und RP235x) können in den Bootmodus versetzt werden wenn die serielle Schnittstelle eingebunden ist (die über USB). 
 +Dann reicht ein Baudrate setzen auf 1200 und Port Close um den Bootmodus zu aktivieren. 
 +
 +  * ''sudo apt install python3-serial''
 +  * <code python | boot.py>
 +import serial
 +import sys
 +
 +if len(sys.argv) != 2:
 +    print("Usage: python reboot_to_bootloader.py <serial_port>")
 +    sys.exit(1)
 +
 +port = sys.argv[1]
 +try:
 +    ser = serial.Serial(port, 1200)
 +    ser.close()  # Closing the port triggers the reboot to BOOTSEL mode
 +    print(f"Rebooted {port} to BOOTSEL mode")
 +except Exception as e:
 +    print(f"Error: {e}")
 +    sys.exit(1)
 +</code>
 +  * ''python boot.py /dev/ttyACM0''
 +
 +**Bootmodus verlassen**
 +  * ''picotool reboot -a''
  
 ===== Installation CLI ===== ===== Installation CLI =====
Line 28: Line 60:
   * <code c++ | ws2812.ino>   * <code c++ | ws2812.ino>
 #include <Arduino.h> #include <Arduino.h>
- 
-// WS2812 LED an GPIO16 (bit-banging, da keine Lib) 
-#define LED_PIN 16 
-#define LED_COUNT 1  // Eine LED 
- 
-// Funktion zum Senden eines Bits an WS2812 (Timing für RP2040 angepasst) 
-void sendBit(bool bit) { 
-  if (bit) { 
-    digitalWrite(LED_PIN, HIGH); 
-    delayMicroseconds(800);  // High für 0.8us (1-Bit) 
-    digitalWrite(LED_PIN, LOW); 
-    delayMicroseconds(450);  // Low für 0.45us 
-  } else { 
-    digitalWrite(LED_PIN, HIGH); 
-    delayMicroseconds(400);  // High für 0.4us (0-Bit) 
-    digitalWrite(LED_PIN, LOW); 
-    delayMicroseconds(850);  // Low für 0.85us 
-  } 
-} 
- 
-// Funktion zum Senden einer Farbe (GRB-Format für WS2812) 
-void sendColor(uint8_t r, uint8_t g, uint8_t b) { 
-  // Sende G (8 Bits) 
-  for (int i = 7; i >= 0; i--) sendBit((g >> i) & 1); 
-  // Sende R 
-  for (int i = 7; i >= 0; i--) sendBit((r >> i) & 1); 
-  // Sende B 
-  for (int i = 7; i >= 0; i--) sendBit((b >> i) & 1); 
-  delayMicroseconds(50);  // Reset-Pause 
-} 
  
 void setup() { void setup() {
   Serial.begin(115200);  // Serieller Port initialisieren   Serial.begin(115200);  // Serieller Port initialisieren
   while (!Serial);  // Warte auf Verbindung   while (!Serial);  // Warte auf Verbindung
- 
-  pinMode(LED_PIN, OUTPUT); 
-  digitalWrite(LED_PIN, LOW); 
- 
   Serial.println("RP2040 Zero Demo Started");   Serial.println("RP2040 Zero Demo Started");
-  Serial.println("LED an GPIO16 wird blinken (Rot, Grün, Blau)"); 
 } }
  
 void loop() { void loop() {
-  // LED Rot blinken +  Serial.println("PING");   delay(1000); 
-  sendColor(255, 0, 0);  // Rot +  Serial.println("pong");   delay(1000);
-  Serial.println("LED: Rot"); +
-  delay(1000); +
- +
-  // LED Grün +
-  sendColor(0, 255, 0);  // Grün +
-  Serial.println("LED: Grün"); +
-  delay(1000); +
- +
-  // LED Blau +
-  sendColor(0, 0, 255);  // Blau +
-  Serial.println("LED: Blau"); +
-  delay(1000); +
- +
-  // LED Aus +
-  sendColor(0, 0, 0); +
-  Serial.println("LED: Aus"); +
-  delay(1000);+
 } }
 </code> </code>
-  * ''arduino-cli compile %%--%%fqbn rp2040:rp2040:generic . -v %%--%%build-path ./build'' \\ **Hinweis:** Der //Dateiname//.ino muss gleich dem Pfad sein!+  * ''arduino-cli compile %%--%%fqbn rp2040:rp2040:waveshare_rp2040_zero . -v %%--%%build-path ./build'' \\ **Hinweis:** Der //Dateiname//.ino muss gleich dem Pfad sein!
   * RP2040 in Bootmodus versetzen ...    * RP2040 in Bootmodus versetzen ... 
-  * Flashen : ''arduino-cli upload %%--%%fqbn rp2040:rp2040:generic -v .''+  * Flashen : ''cp ./build/rp2040_zero_demo.ino.uf2 /media/usb0/firmware.uf2 -v''
  
projekte/sekwai/rp2040_arduino.1754074533.txt.gz · Last modified: by dominik

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki