Skip to content
Snippets Groups Projects
Commit 6ce6e72d authored by Lila Fisch's avatar Lila Fisch
Browse files

Merge branch 'master' of git.card10.badge.events.ccc.de:card10/logix

parents 1766bcda 54c2c4ce
No related branches found
No related tags found
No related merge requests found
Pipeline #2371 passed
# First interhacktions
The easiest way to make some LEDs blink is using python. There are two ways of executing python code: Using an interactive python command line, and saving `.py` files on the card10. The interactive command line is very practical to try out python commands, and debug '.py' files. Directly saving .py files makes the scripts you write available when you have card10 disconnected from your computer.
## Using the interactive command line
You will be working using the command line. Everything that you need to enter in a command line is written like this: `echo "hello"`
<!-- a link to command line tutorials here would be nice -->
You need:
- a laptop with a free USB-A or USB-C port
- depending on what USB connectors are available on your laptop a USB-A to USB-C cable, or a USB-C to USB-C cable
<!-- usb-A to usb-C and usb-C to usb-C photo would be helpful here -->
- an application for opening a serial connection, e.g. screen (installation via command line:`apt install screen`) or picocom (installation via command line: `apt install picocom`)
### Getting to the interactive python command line
Switch on your card10.
If your card10 display shows the text _USB activated._ your card10 is in the _USB storage_ mode, which is the wrong mode for the interactive python command line. If the device is mounted you need to eject it first. A brief press on the _power_ button will exit the _USB storage_ mode.
<!-- a picture here, indicating the right button would be nice -->
To get to the interactive command line, connect your card10 to your laptop. Typically, it will be called `/dev/ttyACM0` or `/dev/ttyACM1`.
You can find out what it is called on your machine by comparing the output of `ls /dev/tty*` before and after you connect your card10 to the laptop.
Depending on which tool you chose, you can open the interactive python command line. You might need to add "sudo" in front of the commands.
- using screen: `screen /dev/ttyACM0 115200`
- using picocom: `picocom -b 115200 /dev/ttyACM0`
If you don't see a line starting with _>>>_, try pressing _Ctrl+C_ (maybe more than once).
<div class="p-notification--information">
<p class="p-notification__response">
<span class="p-notification__status">Note:</span>The first line gives you the version of your firmware, e.g. "MicroPython v1.11-37-g62f004ba4 on 2019-08-17; card10 with max32666".
</p>
</div>
Once you have a line starting with _>>>_, you are ready to start programming in python!
### Making an LED blink
There are some neat python functions prepared for making the leds blink. Let's import the library containing these functions by typing:
```import leds```
Next, we light up one of the r0kets by typing:
```leds.set_rocket(0, 100)```
The first number entered is the index for selecting the r0ket LED. You can choose between 0 (blue, left) , 1 (yellow, middle) and 2 (green, right).
## Using card10 in USB storage mode
### Closing a session
To close a session in screen, press ```Crtl+A``` then `k` then `y`
## Congratulations!
When applying your newly learned card10 skills, please have a look at the [general considerations for designing Interhacktions](/en/interhacktions). Also bear in mind that some blinking patterns have been assigned a special meaning for communicating a traveler's [personal state](/ps).
Hinweis: Die authoritative Seite ist die englische. Wenn du hier etwas inhaltlich änderst, bitte sorge dafür, dass es auch auf der englischen Seite geändert wird.
# Erste Interhacktionen
Die einfachste Art und Weise, um LEDs zum blinken zu bringen, ist, python zu benutzen. Es gibt zwei Möglichkeiten, um Python-Code auszuführen: Entweder du verwendest eine interaktive Python-Kommandozeile oder du speicherst `.py`-Dateien auf dem card10. Die interaktive Kommandozeile ist sehr praktisch, um Python-Kommandos auszuführen und `.py`-Dateien zu debuggen. Wenn du.py-Dateien direkt speicherst, sind die Skripte, die du schreibst auch dann verfügbar, wenn card10 nicht mehr mit deinem Computer verbunden ist.
## Die interaktive Kommandozeile benutzen
Du wirst mit der Kommandozeile arbeiten. Alles was du brauchst, um etwas in einer Kommandozeile einzugeben, wird so geschrieben `echo "hello"`
<!-- hier wäre ein Link zu Kommandozeilen-Tutorials nett -->
Du brauchst:
- einen Laptop mit einem freien USB-A oder USB-C-Port
- je nachdem was du für USB-Konnektoren auf deinem Laptop zur Verfügung hast, ein USB-A-zu-USB-C-Kabel oder ein USB-C-zu-USB-C-Kabel
<!-- usb-A zu usb-C und usb-C zu usb-C photos wären hier hilfreich -->
- Eine Anwendung, um eine serielle Verbindung zu öffnen, zum Beispiel screen (installation über Kommandozeile unter Linux: `apt install screen`) oder picocom installation über Kommandozeile unter Linux: `apt install picocom`)
### Wie man auf die Interaktive Python-Kommandozeile gelangt
Wechsle zum card10
Wenn dein card10-display den Text _USB activated._ anzeigt, ist dein card10 im _USB storage_-Modus. Das ist der falsche Modus für die interaktive Python-Kommaondozeil. Wenn das Gerät als Datenträger angemeldet ist, musst du es zuerst auswerfen. Ein kurzer Druck auf den _power_-Knopf sorgt dafür dass der _USB storage_-Modus verlassen wird.
<!-- hier wäre ein Bild nett, das den rechten Button anzeigt -->
Um auf die interaktive Kommandozeile zu gelangen, verbinde das card10 mit deinem Laptop. Üblicherweise wird es unter Linux `/dev/ttyACM0` oder `/dev/ttyACM1`, auf dem Mac `/dev/tty.usbmodem14101` genannt sein.
Du kannst herausfinden, wie es auf deinem Gerät heisst, indem du die Ausgabe von `ls /dev/tty*` (Mac: `ls /dev/tty.*`) vergleichst, bevor und nachdem du card10 mit deinem Laptop verbunden hast.
Je nachdem welches Werkzeug du benutzt, kannst du die interaktive python-Kommandozeile öffnen. Möglicherweise musst du "sudo" vor die Kommandos setzen
- mit screen: `screen /dev/ttyACM0 115200`
- mit picocom: `picocom -b 115200 /dev/ttyACM0`
Wenn du keine Zeile siehst, die mit _>>>_ beginnst, versuche _Ctrl+C_ zu drücken (vielleicht öfter als einmal).
<div class="p-notification--information">
<p class="p-notification__response">
<span class="p-notification__status">Hinweis:</span>Die erste Zeile gibt dir die Version deiner Firmware, z.B. "MicroPython v1.11-37-g62f004ba4 on 2019-08-17; card10 with max32666".
</p>
</div>
Sobald du eine Zeile hast, die mit _>>>_ beginnt, bist du bereit, mit Python zu programmieren!
### Eine LED zum blinken bringen
Es gibt ein paar nette Python-Funktionen, die bereit stehen, um die LEDs zum blinken zu bringen. Importieren wir erstmal die Bibliothek mit diesen Funktionen, indem wir eingeben:
```import leds```
Als nächstes bringen wir eine der raketen zum leuchten, indem wir eingeben:
```leds.set_rocket(0, 100)```
Die erste Zahl, die eingegeben wird, ist der Index, um die Raketen-LED auszuwählen. Du kannst auswählen zwischen 0 (blau, links), 1 (gelb, mittel) und 2 (grün, rechts)..
## Card10 im USB-Massenspeicher-Modus benutzen
### Closing a session
Um eine Sitzung in screen zu beenden, drücke ```Crtl+A``` dann `k` dann `y`
## Glückwunsch!
Wenn du deine neu erworbenen card10-Skills anwendest, schau dir bitte die [generellen überlegungen, um Interhacktions zu designen](/de/interhacktions) an. Denk ausserdem daran, dass manche blinke-Muster bereits eine besondere Bedeutung haben, um den [persönlichen Zustand](/ps) einer reisenden person anzuzeigen .
......@@ -18,8 +18,8 @@ Switch on your card10.
If your card10 display shows the text _USB activated._ your card10 is in the _USB storage_ mode, which is the wrong mode for the interactive python command line. If the device is mounted you need to eject it first. A brief press on the _power_ button will exit the _USB storage_ mode.
<!-- a picture here, indicating the right button would be nice -->
To get to the interactive command line, connect your card10 to your laptop. Typically, it will be called `/dev/ttyACM0` or `/dev/ttyACM1`.
You can find out what it is called on your machine by comparing the output of `ls /dev/tty*` before and after you connect your card10 to the laptop.
To get to the interactive command line, connect your card10 to your laptop. Typically, it will be called `/dev/ttyACM0` or `/dev/ttyACM1`, on Mac OS X likely `/dev/tty.usbmodem14101`.
You can find out what it is called on your machine by comparing the output of `ls /dev/tty*` (or `ls /dev/tty.*` on Mac OS X) before and after you connect your card10 to the laptop.
Depending on which tool you chose, you can open the interactive python command line. You might need to add "sudo" in front of the commands.
- using screen: `screen /dev/ttyACM0 115200`
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment