Instructions
User Manual:
Open the PDF directly: View PDF
.
Page Count: 124 [warning: Documents this large are best viewed by clicking the View PDF Link!]
- 1. - Vorbereitungen
- 2. – LED Animationen mit Micropython
- 2.1 - Module
- 2.2 - LEDs leuchten lassen
- 2.3 Variablen undDatentypen
- 2.4 – Einfache Animation
- 2.5 - Schleifen
- 2.6 - Operatoren und Ausdrücke
- 2.7 - Funktionen
- 2.8 - Ein erstes kleines Skript
- 2.9 - Dateisystem auf dem ESP
- 2.10 - Animationen Teil 2: running dots
- 2.11 - Kommentare in (Micro)Python
- 2.12 - Animationen Teil 3: white level
- 3 - Steuerung der Animationen mit dem Touch Sensor
- 4 – Steuerung der Animationen mit dem WebServer
- 5 - RainbowWarrior als Wecker nutzen

!"##
"$ % $&'%% $()
*+"$ $,#
RainbowWarrior
$
- +$-
$.( +/
0
!"##
"$ % $&'%% $()
*+"$ $,#
Inhaltsverzeichnis
0 1$
00-
0..( +/2
0$)$ 3
00 43
0.#$ #()5
06 $75
081)& 5
02+9
08/$:& 00
080#'00
08.600
08;<) ,0=
088;.+$$>+(09
. ;>#-+.0
.0-$ .0
.00-$ ..
.0.+? -$ ..
..> $ .8
..0:.2
.1 $+.3
.01 .3
..+.3
.8;#@
.80/ @
.2 @
.20: 0
.2.,
.=6+$#$8
.=0#6+8
.=.1 +2
.=>6+2
.3:$=
.30:$+ 5
.5 +8@
.508@
.5.+$$88
.5#$A 88
.9$82
.0@# .A$83
.
!"##
"$ % $&'%% $()
*+"$ $,#
.00*B-C2@
.000D 2@
.00./ E20
.0.# A& ( 2.
$$#$28
0$28
00#$2=
./#&$E1)&$23
=0
8> $ 1 =.
2-$ =8
20 + $(F==
=" >$=5
=0&=9
8;$$#,(38
80,>#<$38
800&-$ 38
80.,(-$ 35
8."->5@
8,(5=
80$" ,(-$ 5=
8.-((++$(55
8#9@
88D&' $:$)$9@
2&, ,$)9.
20)+9.
200,-$ &$ B$ ,-$ C9.
20.)+(98
20>-$ 98
208 -$ 92
202D':$$-$ 9=
202,-+ 93
2.+&-,0@.
2.01$$,(0@
2..1$0@2
2)$,)0@=
20:$0@3
2.:$)0@9
28)$$, 00
28.-$ 003
22# ++0.@
!"##
"$ % $&'%% $()
*+"$ $,#
8
!"##
"$ % $&'%% $()
*+"$ $,#
1. - Vorbereitungen
00-
•.( +/
•>+*=50.%/,!03@ B/ C
•/
•$+&
<)1( (-4 !>$
? ))$)!*+ G ? H"$
(I &1
&!&J6K!& ? + $& +
-)$*+ G+$G
• ? + 03@?03@?0@B/ C
•" ) !+)$ "2@?3@?09@
•- + $B$)4+("!
4<' 'C
•)+B+(C
•
•,!0LB$;&);; C
•>):B&)!! C
!
•>4 !>4)!>4$ )
•" )'!*'-4 !" ))$(
•/ /2!$2
• ++B4$C
•"J +
•M !>$!>$" ))$(
•+$ $(N/*
2
!"##
"$ % $&'%% $()
*+"$ $,#
# $)$ >$?-&
4 !&($!$4,&$
-6)$ :1 ' %!
K $))$: $
=
!"##
"$ % $&'%% $()
*+"$ $,#
0..( +/
/.( +/ $- !$
+$-+$
<.8@-")$ ).2.@*/#-
$B#-O#- #+!
,$)&+ (&&
+$*B*!0*/O0@.8/C$8-/7+BO
76-!+!( !
C
D$1 A"$B &$( +C
$ ).2%")!&'
0@@- .
#$J()&!(
%/#+!+( (
!.8@-")$
.8@!@@@!@@@++$$&N
- $$- !
G G#$1 )$ 4
< $$(+8
%6B% $++$E6$+$C! 8
B - C!
$+&B* +# $C)$/+ ,
:$+$$ !,
-&$: >+
#$JA$+ &!
$/$!" !&$
#$J+$
D$') /$:$($+,>#<
+,>#<B"C<)&(!
1$+/ $
#$. '$-/6B
6+C"$$)$/+ -4
)$#$)$
)4 ( ' .
3
!"##
"$ % $&'%% $()
*+"$ $,#
)$/+ ,"$)$>$$!
>$$$+$$+
-$+,>#</ $
-$/$!
&$$)!$&$)$
6&>+$$
#+,( !,)$
$$# D$') $
(&!$#)$-)+
$)!$4! )- )$+ $&!
$" >N$)$+
.$(#!)&
(:&+A
A#$+
+$&& $ '$P+)&
'$P:&#$$QQE-!
$& $$$#$(
+$ $$BO
( +(C!#$$)!$
.+
"#A-+1(C)
$$!(#' $&
# $!1 ($!&
+ ?
$%&A( +:&$QQ$
P) :&!(" & &$
& $ $N+ $#$$
%$
5

0$)$
- -4 !/ :
+ $" !$$+&
!<)&"&/ $/$)(&
)&+ $!$'1 )$
6+!$P67')$1$4
#$ $$ &-#&$
$+*) +)$1$!&
:$!P<$)7')$
1.3.1 - Terminal önen
N>$?A$+&$G'G# (
%'()*+'*'+$ 4&
,&A,&!GG!'
-6A->$+ )$4!G'G
( / )$+' $>$?1
/ $$-6)$P$$,&(
&
$)#$7$&/ +/P
$I
#$/
$+
+$ '$
D
<$)! (
+$B$
RC# J&
6)!
$ P"
$$STH!&
$!
"1)P
# &D
S,H!)$
! NB& #$+$C

!)$$)!$<$)
&&$&/ $&
1.3.2 - Aktuelles Arbeitsverzeichnis
pwd BO+&C
: K !6P!
pwd!&&$ S$
#()$H
1.3.3 - Ordnerinhalt au$isten
ls BO C
-/ ls 6$<$ls!6+!
$ #()!&'
$ ls /home/$USER/Bilder
$'()#())$/+ 6
G/ G1)$ /$)BOUNC$
1.3.4 - Verzeichnis wechseln
cd BOC
NN())$& !$/ !
$<N()>))&
(I
$ cd Bilder
& NG/ G!$
#()P$
++$ A-$/$
1)-* $#/
#$(( '$;
1)D #!P

-4)1)& !!
(+ 1)+- $ /(
!$)$ !$N()
$ cd /tmp
& $+'1)G+G!
1)BN?VW$( )$,&XGAYG>$&
N&Z1))$& !cd ..
$ cd ..
1.3.5 - Dateien kopieren
cp BO+C
N)$+!$)/ cpCBO+C")$&
6& !P
# J$&A
$ cp dateiname.html /home/$USER/htmlFiles
/ $ !$>)A
/ cp!!+&
!+& B /+ AG GC
+ )$D BEEUNE : C
, 6 (+4!$6+-
r !&$(!/ '&&6
$( $6+
%)$A
$ cp -r htmlFiles /home/chrissi
#$I&N)& $P
/$)7'A $!&&I
(4 !/ $/'$
&<E+$Q#())
&I ! ++
D$% $- I 4
41( $>$
6$!&&$
./I
& &/ !&
)$P,/ & $
'

08/$:&
1.4.1 - Abhängigkeiten
/( /$-+:&
( B&C&!
$B-C)$4$>!
1$)$$)$$$)/)$
#$J&:&$
N>$?&)$ 4$ /
<KD $'&#$A
/ )&D IA
$ sudo apt-get install git wget make libncurses-dev flex bison
gperf python python-serial python-pip rsync
$ sudo pip install --upgrade pip
$ sudo pip install esptool –upgrade
N-6 / 4B%&'I: & →
% CA
$ sudo easy_install pip rsync
$ sudo pip install pyserial
1.4.2 - freeRTOS
:6B 6+C&
)!)$- $
- $$&$$(- +
<$&* [
* !$/&<!*!
")K/"&)$
!$JD$$"&
$!* $!&& )) !
& +$)!&"&)
$)$&
: )$') >!)$') A

https://de.wikipedia.org/wiki/FreeRTOS
https://www.searchdatacenter.de/denition/Kern
el
1.4.2.1 - USB Port ermitteln
/($:&&!&)$
&!$& N/+&N/%'&
(+) +!(+
&
N>$?!& $$-6!.
GN/@GGN/0G
!$$+A
$ ls /dev/ttyUSB*
$!+ $ %'B+
6E(C!GN/G\ !
D D 4
: / #$ !$
0"$) &$$>$?$
-6/
dmesg 12-#3
N#
* )$
!
/
$(
"&
&$!
$ !
&$
/) - $)
)$ )N/%'
D$/+ 1BO" C

$$!(&B$A.0@.N/N#/
C
:$ )D "G-4567
#8%96G!&$!$%'!'
+.0@? '$!#8%96 &$
:,& VW$( )$
"&B$$'C
$GN/ GG# B6-]>CG%'
!$& %')$N,&N/
%'G6-G$
1.4.2.2 - freeRTOS und das MicroPython Framework
herunterladen
N-:&$)$ )&-4 :
&$) $ '(%B )$1
*+($B% N()$
#()$+ CA
$ git clone
https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo.git
6$
https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo
$/$S & H$ '$ D+
$
$ J+&

1.4.2.3 freeRTOS kon#gurieren
,I ) J$>$?&$
-6
:,&<$)&! 4!& $
>$A
https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/winsetup.
N:&)$ &)&-4 AZ
& )$($ 1)
G-.F+#-G!N()S-F/N>H
& A
$ cd MicroPythonESP32_psRAM_LoBo/MicroPython_BUILD
# (6$: &B:?+ C
4&N>$?$-6$ 1)
*?!* $-$!
4&* $-$4&
# J*
4$ ' I
)$( )$ !K&$)
:$$B * $
* (C!$G:G)$
$ ./BUILD.sh menuconfig
-/ 4$P!$(
$) "&B)// $(E(C!
/B<$)$)&)C$
$):&B&-$ !$&$ JC
(
Hier navigiert man ausschließlich mit den Cursor-Tasten.
6EN$(-+$$)$&' !
Rechts/Links um in der Menüleiste unten zwischen "select" (=Menüpunkt auswählen
/ ändert),
GGBO)$)$-+$
C!
G-GB)$1&$)$,1 C!G7G
B$ *P$B$<C+CGGBO
+*P$ C$)$&'
&$)$! ((
/ )$(& !$&V$&
&
, SH$-+$G-G$$
&! N(-
,$&)$ "4& 4!(
!GG&$'
,V$$PA
USB Port prüfen:
%;:→-
" +&!)$( N/BN/@C $
+)
Webserver-Funktion aktivieren:
"-#→%#%→$ 7
-$$-+$(!$S#HSH!$
,()$((-$ &G\G)SH
SH(-$ !( (&$
$&
Telnet- und FTP-Server-Funktion mit "n" deaktivieren, falls diese aktiviert sind:
"-#→%#%→$ '7
"-#→%#%→$ -7
#$J&!&( +$)
4A
"#→%#→"#-1093
" * (G-"+)G,9=:
: !'&$,)$+
,(-$ 4-$ < =!
(& A
"-#→"→

# A-$ !S?H&!
'! $$$-$ )$ $
'" S H#$&' !
(&
D$ )$- )$>7G& $
'#!$&
P+& !$$'
# J?&' $$P)$
: &#$$ N
!SPH$ +B&
& 1)C)$K$%$ &>
)$+ *+ G+$G: P
(+$)&!$$P)$GG
&!($P&+$&
)^I
$ .BUILD.sh clean
$ ./BUILD.sh
_&_ I
<$!&+[
/: $/'!/$ )
&/$ )1&& $!
#&$!$/'BC$`$ )$&
)$G+ G
Kompiliert wird mit einem sogenannten Compiler.
1.4.3 – Nützliches Wissen
1.4.3.1 - Compiler
+ +) Z)!$+
+B$"+C$
-B +!)(C)
-/ 6$$-+:&P)$
/+ 6X-F.F+#-F>/<$E
-F/N>E+E+E+.X$
?@?@-$ !+$
)$4":
$-J )!
$$!G(G
' $-!$: (/!
& / $+'
-$ !&# +
)$/+ B+!-+<'C
/ $(' #)$!-!
+ &'*+ ($)
$-+$
'(+$$
< /+ !&)$!&
1 GG,)$&&)&,!1
+!
,)$&!1
+&+ )!
($
:$> A
https://de.wikipedia.org/wiki/Compiler
https://de.wikipedia.org/wiki/Maschinensprache
https://de.wikipedia.org/wiki/Register_(Computer
)

Maschinencode Assemblercode Code Erklärung
(Hexadezimal)
382:02 (,6a+8b!. O.c )1 !
$
/
&!
$,.
5/82:5 (?!,6 OQc )
a+5b #d$,
5/22: (?!,6
(1
)
a+8b d$,
@0@ ?!?
(1
#,
(d)$
5982:8 (,6a+
,(#d
)1 !
0.b!? $/
&!
$,(
#d
1.4.3.2 - Interpreter
%))$+ !(#$$
(-+)!
+&'>$)
+&D )$ $
-+)<4/
))$#$$&&
1 (!$(
()$$>$
$Z)$&'>$)!$J
$! '$
!+ +&
&#$$((#&$$
+

1.4.4 – ESP32 mit Computer und LED Strip verbinden
1.4.4.1 - Framework ")ashen"
%$#$7$$&D!$)$+$
)$ JI
# $$1+$!N/* $+$I
,&'&KN/%'(+) +!
(+&
Unter Linux ist dies meist ttyUSB0 oder ttyUSB1.
!$$+A
$ ls dev/ttyUSB*
ls$ !+ $ %'!N/
\ !D D
/(&/$+ 4! 4&( A
$ esptool.py --port /dev/ttyUSB0 erase_flash
A
$ ./BUILD.sh erase
N+ $ A
$ ./BUILD.sh flash

<$[[[
1.4.4.2 - LED Strip an ESP32 anschließen
#
$>+!K
# !21BC!B
C$%$!%<B&)
&JC
J$&)B&JC
* ?W$ B $&
>!$$21#$$%<(
$)# Z+$
N/)$(
$J%)C,A$)$
J$%<?W$
%<($# J
($>+B<C08
& +N/* +$
($
1.4.4.3 - Eine Verbindung zum ESP herstellen - rshell und REPL
"(&& GGBO C!$4 !
1$)$ )$ $$6)$ !
$)$ !)$()$ 4!>)$
4#!&)$/+ $4JB$)O@C
$B+E(EN/@C!&( BE(EN/@C
)$
/& %Q
-BO;( ;+ +C&$)$!$+*) /
$/$)$! :$)$ $!
(+$)$
$ rshell --buffer-size=30 -p /dev/ttyUSB0 -a -e nano
$ repl

#('
$D I
>&
D '
DG>>>G
&J!
! P! /
&/&>%Qd
2. – LED Animationen mit Micropython
-&&'&G+G1(
B1C$/$!$
)!$ &( $/$
#$$!1&$) -$ $:$&'
$!& 4$(&&!
$ E# $ A
8*!&NG&G
+) K%A
http://python4kids.net
http://python4kids.net/how2think/index.htm
#$$$+$$P4
$$+ %P$)$ A
https://www.python-kurs.eu/
python3_kurs.php
.0-$
-$ $&!$
)+$ $N$
(!+ ? '
*+) *+) &
-$ -$ $'(%)$$+
&:' -$ $
(&

https://www.python-kurs.eu/python3_modularisierung.php
N-$ $))$4$G+G/ $
&-)$+'
2.1.1 - Das machine-Modul
N-+$)$$)$44
-$ GG GG$-$ !
&-$ !)$&G* G
https://www.python-kurs.eu/klassen.php
https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/machin
e
-$ )$/+ )&
-")$ 1@A1B-"CD33
$B@13C
#$J $&-$ !)&* G<+? G!
&+P$$$! )$>$4
2.1.2 - Das neopixel-Modul
/(&+ $ 4!& )$-$
$P!&>+
# J$6K(G<+? G)$&
:KG)* G #
)+* #'&( )! &
$% &
$+$ )$$
'$A
https://www.python-kurs.eu/python3_klassen.php.
GimportG/ &>!-$ )$
#$&N<+? >-$ $
& A
https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/neopixel

@1B-E DFB-G-D3P!&
a+F$b!& +B+$C
B$+$C&
@@H8')$/+ ! ( $
B>+C&
%$ / >$'K&
A
>>> import machine
>>> led_pin = machine.Pin(14, machine.Pin.OUT)
N6KG<+? G)$ !#
&$&!+ !
&#) ? $+B: 08? C#$
(&>+ &!$$+(+
G*=50.G,$ ' +eF%/!
>K& :A! $*=50.
G%/,G>!+? $(:<%/$&J!
>$) )$)$A
machine.Neopixel(pin, num_pixels[, type])
&K )1
GE-G+
!$BA08C1
BE-C)$+,$( !&$+'
*+
%$ / !$#) ? 1 G$F+? G
)$+$)* <+? 1 G+G)$
+A

>>> num_pixels = 14
>>> led_pin = machine.Pin(14, machine.Pin.OUT)
>>> strip = machine.Neopixel(led_pin, num_pixels,
machine.Neopixel.TYPE_RGBW)
(' $$)&D !)&)&/
+! &$ !( &
$ A
>strip = machine.Neopixel(machine.Pin(14,
machine.Pin.OUT), 11, machine.Neopixel.TYPE_RGBW)
..> $
I-@1-FBFFF-D3)$'!?
$)$ #$)&#)& !
B* C+
-)?? !:&)&
&<!& :? $
"&(P:(&B&
/+ C!:& "?) &B&+'
'C
B+ C%/,+!& :,J
? $ ,!& &@
)",(@.224 4!&J&
:
fB+ CP!&( ? )&
!$(? !+&$&
0! &'J$? $!$
&$
f-B+ C!? K&
:)& !)& B&$&C!
#)&& : && !
$+O: )$
N ? (): $)$ !
)$') / +&BC4
>>> strip.set(0, strip.NAVY)
' ? +:G<(G $!&'

>> strip.set(0, strip.NAVY, num=num_pixels)
? :G<(G $
2.2.1 - Farben
,&':$(P:
"?) &
N$)$P!& :(! A
%G+G>$ $#/
#$7$ (P,$$
(:$(P,,$&
%J$) :&PA
9+J0FC&'$F($F+&"$F9+8$FK$++HFJKIF")$I'F%&+/$(F)(KF
"(HHIFH+&/$F)($$IF8(+$F'$+FI/K@
# (-4 !:"?) &
)$
%/:&P$,BOC!BOC$
$BOC,)&@$.22 ::
$ O.22!+4,!O@!$O@)&#
AB.22!@!@C%/, $+
"?) &&'Gg::@@@@G!)&@?::@@@@!&DGgG
G@?G$( &!$)$)!$
"?) & Gg::@@@@GXgX D!
D !@?ff@@@@B?) CD &$
D '!(&& $@?ff@@@@

, &) ) G.22G"?) ) &G::G
"?) &:& &! K& :&
!$!) ("?) ) $ J
:GW$G)$/+ %/,B0.3!.22!.0.C*(
&) ,"?) & &@?3:::8B 0.3O
@?3:!.22O@?::!.0.O@?8*(&&$+
"?) &) & &5552=8/,
:)$ '
*($() "?) &$
":$!,,+B&
)$/+ ) ) "?) ) A?B F( $C$$A
B?F( $C( >&A
>>> int(0xff0000)
16711680
hhh
>>> int(0xff)
255
>>> hex(128)
'0x80'
>>>
-4&K%/$+ ! B0.3!.22!.0.C #(&!
&+"?) &(
, &:&)!&(:! :
$>( &G>G$!&
:$@) ,G@?@@G @

.1 $+
/&$) 1 +1 &
$)!$('6K)$+6K4)$/+ )
D &&DBC6$,
X$XX: X
2.3.1 - Variablen in Python
,'++1 ?+ )P&$
$$&'>$)('&!
D$&$D$/+ 1 O0@$
D ! )D ,+'O.!
(+7! % )
-$) D &DBC1
+
--4 !>!$+
1 +
<$->$> 6)
:$1 +I
&$+'*+ )$$)
2.3.2 - Datentypen in Python
2.3.2.1 Primitive Datentypen
9!$ + )&
(,!& D$'!A$:
0@$&!D$
++ )($/B&$&$0$@
)&C" $ +
&))D &4.
&$+(,B$C(@8.989=3.92!
& +( $(,BC(i.08385=85
.08385=83
)% &%4J1 B.
=8/C,/0!2j0@ki82!8j0@k5B7!./C
/2!@j0@ki.80!3j0@k@5B$ !=8/C

J!BODC)) D!&
/$ $D !&) &
%)) - !
$!$!&$$&
$# !)$/+ ,+A
https://upload.wikimedia.org/wikipedia/commons/2/26/Ascii-
codes-table.png
,K/$! J!KD $
K)$$)$4$,#
>!?( $)$$
& 1 $ I
2.3.2.2 - Sequentielle Datentypen in Python
W$ +)+!:
(
%)D! #$(D
W$)() D-?)
D?+&$4 !
),1(/$
/$W$))$$!)$
) /$BW$)C$)$-
& : +(+(
+ #+ +)!$&
&$&)$
* ab- ?$) >
)$$$('
'-!$$+ >' -
?$) )$&$+ $*
BC+$%))$>('
)$') )$,$/)!
6K$$A+ FOlG/
,$GAG$G!G/GAG-$G!m
W$ +)$"
$6KG G!4$
*G-++G!& & $&
-)$)+$
>$A
.8;#
2.4.1 - Blinken
/(> 4!$%
!& $ A
>& )$ D $, !
J&$ <, &!$
&
,> )& !;)
/ )$A
mach alle an
warte
mach alle aus
warte
mach alle an
warte
mach alle aus
<$&'"&$$$' , &>
$,0@@@? !'& +Q+)$$I
#$J&( )$J$$ &I
Viel besser wäre es doch wenn wir sagen könnten:
mach bitte 5x:
mach alle an
warte
mach alle aus
warte.
.2
#$%$
- )$/+ !) $2!
0@!0@@@- $& B%C#$J$
!/ !&$/ !$$& !
&'$J$ B%C
D$/+ A&'$J$ A !
$ &$ A )I, !

#$4& A&I
%$ $ K $ $/$!
, +&$/$)$!&(
/$/ ,$)$!&$!
$)$$&& $
/$)$!&,: )$ $
)$$#$$D
&
2.5.1. - For-Schleife
https://www.python-kurs.eu/python3_for-schleife.php
N)$A 2?$A
>>> for i in range(5):
B2C:$! )D (@8BIIIC
$%$ AB@!2C,$8$2[
2>D !&#) D #
$B2CB)&B@!2CC!D !$2%)
D !@!n2 8!)$&
/$&$A &2?$:K(@n2
#&P &$J [
&$$P
+ !&2?$& !$$1 D
#/&
> $! D GB2CAG
++ +$$ $$!
)$&D ('"$G...GA
#$&&'D & ! $
N: :$ )$!&A

für jedes i von 0 bis < 5 :
gib einmal den Wert von i aus.
N,B?C $)$$):$
+Ba( E?B#$)CbC
D& '$&#
D !+! && !&
$! ( ! 2?$&$
& &$& !4&
'! $&
$ I,&+$>
&!&&/ & $+
& &I
N))$( !& $
-$ GG!)&:$
-E13
@-E14663!') B'- !
$+&C.@@+'P,$
D $& ?
'&
import utime
>>> for i in range(5):
... print(i)

... utime.sleep_ms(200)
$) $ '$)
#'$ 1 & &unsere blinkenden
LEDs!
2.5.2 - While-Schleife
https://www.python-kurs.eu/python3_schleifen.php
!& $,
$")$ )&,&A
while True:
, & $> #&$
$A
mache für immer:
schalte ein – warte – schalte aus – warte.
& J$A
import utime
>>> while True:
... strip.set(0, strip.TEAL, num=num_pixels)
... utime.sleep_ms(200)
... strip.set(0, 0x00, num=num_pixels)
... utime.sleep_ms(200)
,4 & $!
$2?$&
<&!1 ( $$,@
X& Bn2CX! ,( 2!&
$)$$$1
$04&!$
I
>>> while (i < 5):
... i += 1
...

$!+!/$!$
#$$&G& G&,!
$!)&&!&#$$
)
.=6+$#$
N#$$($*$
1 !*!6+$&(:$
#$&$#$$,!1
)$&&&#$$1&$'$
<$ 6+
"&$$&6+
6+#$7$)6+!BC
$,B7C)$!&'>
1 +, +$ $:
)$
2.6.1 - Arithmetische Operationen
Operator Aktion Beispiel
Q # 00OQ
$ 0O
\ -$ + 0.O\
E ( 2OE
EE $(E
%)) (
(
)) #
(: K
6+: ,
!&))
# ( :
$
hhh0@EE
hhh0@@EE
@
o -$ (
B$%)) C
0Oo
B2\0O2!=2O0C
O D$&$(,

2.6.2 - Vergleichsoperatoren
h %4J
n *
hO %4J
nO *
OO %
IO < !$
( 0a0!.!b
2.6.3 - Logische Operatoren
# >N BC
6 >6
< ><
#$7$( ',6+$$ '$
P$ A
https://www.python-kurs.eu/operatoren.php
http://python4kids.net/how2think/kap02.htm

, &$!>)$(DE
(#$$&!
$: D$$
.3:$
$B#C!& !)$(D
(#$& !
:$)$
:$& &GGBOPC #$$
J$A
def funktions_name(parameterliste):
""" funktion_name(parameterlist)
an example function to show structure of functions.
parameterlist: (type of parameter: Text or number) short
description what parameter(s) is / are needed
returns: (type of returned value) if a value is returned,
describe it shortly
"""
Anweisung(en)
(return)
EA,$0 :$
4 !&:$)&&
!)&&#$&$ Seite 35
$ ( !4
&!$:$#&$$)$
/ ? $GG
&$)!$:$$-$ )$-)$
*+ G*G
4 !(/$!
,$ !&)$)$,
:$$$1 +

,P&<)D$/+ $A
http://python4kids.net/how2think/kap05.htm
https://www.python-kurs.eu/python3_funktionen.ph
p
https://www.python-kurs.eu/python3_parameter.ph
p
/(:$+ 4!$*
A
0 , #&$:$&:$
4 &'
. & ,)$4!('
0 :$,)$$B&/$C
, &K)! /+ !:$!)&
,BC& !&&&
(A
1. ,& :$!)&D &
<& GG.
2. D&,)$4$)&$
3. $# )$&
def addieren(a, b):
e = a + b
return e
ergebnis = addieren(a, b)
4& $$/+ 4&
:$$$)$/+ !& :>
D$4& !& > $$& $
A
0 ,& >+ &:$S H
. ,4:$DBQ$C(')$4
&
& #$!$&
&

/ :$&$,:$D
(&$$1 )!,#$$
:$!)&&
#$1 $)$!<)$&' !$
>)$&' $)&$,
-( ))$4!&$
::!1 G G)$:D!
> $ !GFG$:D!> $
!GFG
>>> def blink(color, time_on, time_off):
... strip.set(0, color, num=num_pixels
... utime.sleep_ms(time_on)
... strip.set(0, 0x00, num=num_pixels)
... utime.sleep_ms(time_off)
<$)4 !:&$/ ( D
$)$+
<:$>$ +&$!
_
>>> blink(strip.RED, 200, 10)
$$
%& $:&?+
&<)P$ $G? +GBO
?) :&' C-4 !&:
"?) &)$
*! 1$:$4: +
+&$'$>+)I
2.7.1 - Funktionen mit optionalen Parametern
$ !:$+BC!: !
> ) & !#) )$ >
G$OG&
" $+ !$$
+!&&B$ ,C$)
4!/('&

,1 +D,$1$ &$!
+ A
>>> def blink(color, time_on = 200, time_off = 100):
... strip.set(0, color, num=num_pixels
... utime.sleep_ms(time_on)
... strip.set(0, 0x00, num=num_pixels)
... utime.sleep_ms(time_off)
D$ !$ $') )$ )
&! 1 (!G G!
-!+P)&
$+ :$/ :$$$+
!F!F&$:$$$
$$)$&
Da wir nun time_on und time_off als optionale Parameter definiert haben, dürfen
diese genau aus diesem Grund nicht am Anfang stehen. Ansonsten würde die
Gefahr bestehen, dass die Werte falsch zugeordnet werden!
Würden wir nun alle drei Werte nennen, müssten wir die Schlüsselwörter
(time_on / time_off) nicht zwingend mit angeben.
Falls wir aber nur den Wert für time_off ändern wollten, den für time_on aber auf
default lassen würden, können wir time_on also einfach auslassen und die Funktion
mit ...
>>> blink(0x3F03F, time_off=50)
$$
Aufgabe: Blinken in zwei Farben
Schaffst du es auch, den Strip anstatt ein- und auszuschalten zwischen zwei Farben
wechseln zu lassen?
Oder abwechselnd in zwei Farben blinken zu lassen?

.5 +
>)&$$) !K&!
( 4++$ &&'
$:$$$+ ?&$$
( !+)$4!&$$
?$
2.8.1 - Editor
")$&# ?$)!'J$
K/( # ( !)$
$)!$&$ )$/+ #!
(
$
https://atom.io/
$ &
#, $)&/A
/!GKG!/K
) !&$
+ 4& $
$!:!)$
NK)$ !)&$)$&' !
-$GKG: $&' +&-$G#K
: G

: +6+)K(
!+P ! 6)$
)$/+ "1)6GG
+B ) : C$KB6C
+
<&' ! K
K
-4 $ K$ !
!-$*?
K4$G&: G&' # (
K
:' 4!< $(
$B+C&$
/P ?"&
4BKCB '+C)
#$J&$!$!+! !
&&> !
1 A
$"($&?$#( $$
&)$/+ &4B+!!C )#
:$!*$!&,)
#$D ) &(1 !&)$
? B ++ C
<$ $+&$!&
& $)

# !
+&K
#()4
XQXD $
1$4&( 1$)$ A
$ rshell --buffer-size=30 -p /dev/ttyUSB0 -a -e nano
(&>!+& +$A
$ cp animations.py /flash
# J&$")$/$BC
$ $
<$4&>-# &G+ G
$'
N$:$ )$!$+)$+
>>> import animations
,$&)$!$$ ,&$
(-$ &$!&
) --$ &$I
)&$$:$!&
I
6+I X: $ X ,P
: [
#& !&)$D )$I
/: $$)$ )D
(
)#: !$&$AS( ?H
?: D !& $&
D )$: D 00
# &&/ +

@-E1E3D 00 $*?:
)$PI: $ D $
-@16FF2E-D 0@P(&I
* &$4!& I
+(!$ D D 00
/ !&* !
?: ND 00 : &$!
&$$D 00I
6(! !$: ( ))$
4 / $D $!
)P"&/$
&1 $B($ C
#)$:$E-$ !D$:
$$&$
+K:$K-$ !D$)
!&$ ( !&
+$ !&)$:
$)!$)- (
+ $$!$ !$)$
$
)A$ ((
&$ $
)($!$KBC&
$!E*4D&
( INA(I&P(
)$ : $++&I
# * ++ %Qd>
+$+$>&$
++G$ GA-/ $$D +I>$?
++>$?&$+
+B$JC&D GLG
(!$+ +)$ !/
$)$ $ )$$)!
/ )$*+$$>)$$D $
XLX&A
$ cp animations.py; repl
#$& 4$D B/ C)$
!$ -$>-I

&& $!4&/$)$
A
>>> import machine; machine.reset()
<$ ++ $
ZA,$J/BOC&!$
($ -$ $
'!GG>$ J#/
-$ (!&#$(( '$
,GG
2.8.2 - Skript auf dem ESP ausführen
:$-$ &$$!)$-$
! J!$$!:$
* A
>>> import animations
>>> animations.blink(0x00ff00)
<$&)&/ :$! '> &$0?
I
2.8.3 - Aufgabe: Schleifen erstellen
$(/+ / :$!
0@? B $ & C
&
B+ C&:$B $:$$+C!
:$$$P&!& $ $&

.9$
$&$$ ($)$
&)$>%Qd&( $ JG;
7+$.$)$ A
>>> ls /flash
$$$ : +$$
<$G+GP$$ A
G+G
!/1BC
$&" !P $(!
$/))$ J( +$&
$)$K)D+$('!K /
$&&$K $
$N'& G( G!$
)&#$BD C( ')$K
&A
>>> cp /flash/boot.py
[/path/to/your/projectDirectory]/[projectDir]
>>> cp /flash/boot.py
/home/chrissi/coding/microPy/rainbowWarror
+( : !K
? &
"&-$ G#GB#)$C$!$>
+B1 -$ C)$6X X$
: + ?)$&
N$)$P!&$! !/
$-++ $)$&A
https://docs.micropython.org/en/latest/pyboard/library/sys.html
#@-A#$ +$

/$!('>61 +
&!-$ $&+ &K&
B?C-$ 4!-++ $
(!6S7E H+&!
&& $
<> @-#G$&$!&'J:
G@-#G$: (!&$
<$!&@-#[
$!&)& I4
&-$ $$$&!&$/ :$
4&$ +!&& )<$
>!:$G G$/
)
& $G+G!K
+&$)$ )>$D
#4$ )4BD$
C!$+ -!&)&
)4)$ &$G+G!
$)/:
!&(
:$$$+
D&)&$ #$ [:
&1 $K$!&&/ :$
4!& )$&+
&
1<$I"&GG
<)$*7
&4 1 )&
1 G$G
.0@# .A$
-4 !/&$#)$!!&)$
/+ $>)$ DK$$
( $<$&&[
schalte LED an Pos 0 ein
warte
schalte LED an Pos 0 aus
schalte LED an Pos 1 ein
warte
schalte LED an Pos 1 aus
.......
schalte LED an letzter Pos ein
warte
schalte LED an letzter Pos aus
"& & 4!&%)
:$ #) >B $F C# $
$ A
für jedes LED in der range (0, num_led):
schalte LED ein
warte
schalte LED aus
:$&+

def running_dot(color = 0x00FFFF, time_on=50):
while True:
for i in range(num_pixels):
strip.set(i +1, color)
utime.sleep_ms(time_on)
strip.set(i +1, 0x00)
utime.sleep_ms(1)
<$ &&!:$D!> $
!&4!& $F +
O@?@@:::::!FO2@
'$# ()$" $)
(0&!)$ D$&$$+
,& $ !&> 4
:$)$W$ $I
"$$ G/G-+ $
&! '(+I
< &'@)$)' 1@9$
0@DN)&$0@D!&!$ D 0@
D )$
$! & ! P!
?@+&& !
P!?0+
#$+&$!>0 &+O@
+&!> ) +OB$F+? 0C
: I>& +O@
$+O0+&+O$F+? 0( )
> $!& ) )>&$F+?
+
&+BC ?$') Q0I
%&#&G+G + !
$$:$$$)&I
animations.running_dots()
#$ ,$
.00*B-C

<$&$!&!&
)&G$ G& -4 &'!)$
$ $D ! '$%!
D& G(G$ 4
&-4 *
Z &&*)$)$!&
#&'& $
)!$) ((+X X)$
#$ #* 4&!
$&+'&
XX
-$)&)&(#(*A
D $/
2.11.1 - Zeilenkommentare
Zeilenkommentare gehen - wie der Name schon sagt - nur über eine Zeile und
werden gekennzeichnet durch eine # zu Beginn der Zeile / des Kommentars.
-D $+ D &!$$
D # !&gP!& (+
+$$$
# Dies ist ein Zeilenkommentar.
i = x % 5 # hier kann man kurz beschreiben, was passiert
Zeilenkommentare werden nicht nur genutzt, um Codezeilen vom Interpeter
"überlesen" zu lassen, sie werden hauptsächlich eingesetzt, um Codefragmente,
auch Routinen genannt, zu beschreiben. Dies dient dazu, den Code lesbarer zu
machen. Nicht nur für andere, auch für einen selbst. Nach einiger Zeit weiß man
sonst oft nicht mehr, was im entsprechenden Teil geschieht.

2.11.2 - Blockkommentare / Docstrings
/ 4D )$)$/$
/ #$):
""" Dies ist ein Blockkommentar.
Dieser darf auch mehrzeilig sein und wird auch häufig
eingesetzt, um Module, bzw. Funktionen zu beschreiben.
"""
$$&$
$)"&4 +'!&:$
/$ $ !!)$
!$4
)$') !$$
K !: (-(&!
+4#$J (
F$FFFF+BF$FFFFC/$)
$$ &!
&:A
D$$)/$-$ E:$# J
)$$$1 $&+
&
""" running_dot(color = 0x00FFFF, time_on = 50)
Neopixel-Animation, every single LED will light up in the
color specified by color for a time, specified in
time_on. after time has passed, LED is turned off and
next LED will light up.
color: color (hex) of the LEDs
time_on: time (ms) the LED will light up
""""

.0.# A& (
, &$!$!>
$!K>:'!4&(
:*.50.>$)A,JI:&$+BC
X&X,)&@$.22
)&>! &&( !4&)
+O0+
strip.set(i-1, color, white=100)
& >+!$ $
P
strip.set(i-2, color, white = 150)
&>+!)&PI
#A: O0&'.O0(?)$: $
B?>?$C
&!,++ 0$
$4J $F+?
N)$!,0!. @$4J
$F+? !4&-$ 6+! (
)
pos1 = (i - 1) % num_pixels
pos2 = (i - 2) % num_pixels
Da bei der Modulodivision - genau wie bei der normalen Division - die Regel "Punkt
vor Strich" gilt, muss der Ausdruck (i - 1) zwingend in Klammern. Somit haben wir
garantiert, dass pos1 immer kleiner bleibt als num_pixels, da zum Beispiel 6 % 5
=1 (1 Rest 1).
Aber 5 % 5 = 1 Rest 0. Wenn wir Pixel 0 in cyan leuchten lassen, im nächsten
Schritt aber Pixel 1, dann würde jeweils dieselbe LED leuchten. Dafür würde aber
die letzte LED (an Stelle num_pixels) ausbleiben.
NG: G-+ $&$)$!$
++&Q0B!+0Q0!+.Q0!C&A

strip.set(i+1, color, white=white_level, update = False)
strip.set(pos1+1, color, white=white_level, update = False)
strip.set(pos2+1, color, white=white_level, update = False)
3 - Steuerung der Animationen mit dem
Touch Sensor
<$&# !)&& $
& &
< 4&K)!& + !
)$/+ #<0D '$! J#<
.!$&
/&'!&& 4!&'
#
0$
N.+&/!&)$/+
$B/$C
%$&0@$P
@!.!8!0!0.!08!02!.3!$.
/$ $*+)(
:$$$V$ :
N$( B(DC(D
($
)+ $#**+)'
*# ('!
%4J)$$(/$)&
,& $$$$)$
#($
# #(&-$ $
, & $.3$)!&A

import machine
# touch related values
touchPin = 27
touch = machine.TouchPad(machine.Pin(touchPin))
&)$+1 $+
,&$,$$ & !&A
touch.read()
$&#$ )$: B1 $C$
)$!#$$+ ' B&$$
<$&C!&:
: $$+$!+'
&: : )$'$P$ !+P !
$)$$)!& <$$
+1 +&! &
%4J!)$Z$,
N: )$&!($
!$)$ : 4 !B$
C#$
#$ $B?+ C
!#$!&#/
#&#$-/
,&'&#$$ (
+&D D $,:$B$$
-$ C$$&!#$$&D
D $$:$&!+ $&$
# J#$$&D $$
:$
&, $ $ & $,)$
( !& & +
!,2 +$$)$ ! & +,
(.@@

import machine, utime
# touch related values
touch_pin = 27
touch = machine.TouchPad(machine.Pin(touch_pin))
while True:
# try to read touch pin
try:
touch_val = touch.read()
except ValueError:
print("ValueError while reading touch_pin")
print(touch_val)
utime.sleep_ms(200)
/(&$4!&*
$B6.3C<)$$+,B C!
! +$
$+)$
-++!$+!+ $
$& !& ,6
/$&,)&8@@$2@@!/$
)&@$02@,4 K
N$(' (
)& & &! GG !$05@
: &1 $)$& !&)$/+
/$&$& $!
& &$!
&
3.1.1 - Animationen mit dem Touch Sensor starten
N#$)$!& K- !&
& &$&$!'#
N $$)$!&/$)$!$)
#&$!$1)&$
4&A
Wenn der Sensorwert kleiner ist als Schwellwert:
starte die nächste Animation.

./#&$E1)&$
$($#&$B
1)&$C !$$/$$&
>/$(!&$# (B
$C $&
#$A1)&$ !& ()&B$C
B# (C#'(BC
/$$&
4)A
Wenn dies: mache das.
)$4PA
Wenn dies nicht: mache was anderes.
6&/$:4A
Wenn dies: mache das
Wenn dies nicht sondern das: mache jenes
wenn dies und das nicht: mache was anderes.
")$$)#&$
<&!&),1 G&G
+, &)$/+ !$-#)
!B$ C
&A
if weekday == "monday":
print("today is monday. ")
6+GOOG% ++!
,B($C /$ !&$)$
!/$&&$ / $
&

, &!#$$ !&,-!
4&$% % ++#
/$")$$)GIOGBO$ CA
if weekday != "monday":
print("today's not monday")
: &$ $! $
,$!,A
if weekday == "saturday":
print("today is saturday")
elif weekday == "sunday":
print("today is sunday")
else:
print("no weekend today")
B#)$( C&$$!&/$BC
)$
$&$$!&& $ )$
- ()&

$$$A
touch_threshold = 180
while True:
# read touch pin
try:
touch_val = touch.read()
expect ValueError:
# if ValueError occures print on terminal and blink
3 times in red
print("TouchPad Error")
animations.blink(color=0xff0000, count=3,
time_on=50, time_off=50)
# check if touch was registered
if touch_val < touch_threshold:
# print output and start function handleAnimations()
without argument to start next animation
animations.next()
utime.sleep_ms(200)
)&?BC:$?$!
+I&
+$
,<! :$'#
$$
#!& :$>
!)A<'I
:K)1&$)&&>$#&
)+'$&& !&&(&
+'&&, !$#
$)$&' !&&$
D$$A
)$$!)$K, &
4!,$$
+ & )$!&
4& (#!)$
& <# +

,!1 :$!)&
! &/+: +&(
$ 1 $:$ ,&)$/
!&+:$$
: &1 $)$4?BC
:$+
# saves all animations in a dictionary
animation_dict = ["blink" : blink, "running_dot" :
running_dot, "crossing_dot" : crossing_dots,
"rainbowCycle" : rainbow_cycle ]
,!&$/):$+
,&G BCGG G!&)$#$$
:$!&&&
# J &$!&$:$?BC
:$4&!!&:$$$
&$!>&: 1
&$! K& '&
!+ )>4$&'!&)$/+ !
BC#<@!$FBC#<0BC!&'D'
$)'

D!$ >B' C
)!$' &
for i in range(3):
print(i)
4$ JA
numbers = [0,1,2]
num_iterator = iter(numbers)
while True:
try:
num = num_iterator.__next__()
except StopIteration:
break
print(num)
-)&+ )! &$:
P(,
D$$E?+/,&$ !
&)$: $B+C$ )$N$
! &!)&
,4!!& )#
,& !!& ) &$!
&((# &$ A
, $I
$)$&! &$A

8> $ 1
1 !:$P!$
1 +?$ :$
-)& :$$1 !$J :$
P&$!)$!$('1'$
7$$1 $J
+&1 ?$J :$,0@!&
:$$. !1 $J :$
,0@!&'1 ?:$,2
,&/+ $:$)$PA
https://www.python-kurs.eu/python3_global_lokal.php
1 F&$J :$?BC
BO C,&#$$:$ !&
$!!K#$$@&
&$&@)$?+
/ $ $('!&)$: $
B1 )( &$C!&1 )$
(&$ J('%$+
&I
&:$!$
1
#(' F&:$
$$!('$F

# saves all animations in a dictionary
animation_dict = ["blink" : blink, "running_dot" :
running_dot, "crossing_dots" : crossing_dots, "rainbowCycle" :
rainbow_cycle ] animation_iterator = iter(animation_dict)
def next():
global animation_iterator
try:
running_function = animation_iterator.__next__()
running_function()
except StopIteration:
animation_iterator = iter(animation_dict)
next()
E2E@EEEE13&!'
:$1 $F$+&
-E13&$
$?+/ $<$)
XX+!4&$:$$ $$
,:$ $$$(:$
K$$ + !(&$`$
!$&)$ A
https://www.python-kurs.eu/rekursive_funktionen.php
http://python4kids.net/how2think/kap04.htm
:I
# !+!)$ & $+!+
!$
<$ 4 !#$)$
/$/$ $ $#++$
$

# &$I
$I
&!&#$$(+$
#&$# '$
$!4 !
$)$ $#($J)$
< 4&K)!&)#$$
#! $.@- $&#
&!&&#& 4[
N)W$+ $ )$4!
)+-$
2-$
-$ && &/
-$ I
-$ &W$ )
$
`$ )$! $& )$
!/!K&
ND)$+&+D!NB
)C+$, $)
D!N&
-$ (' ' !$)&
!+ $!(!
(#$ &!+ )$
/ '$$!,
4&$)$
"$)-+-$ F
:$& 1 ( 'A
https://www.python-kurs.eu/threads.php
# 4&/+ &!-+
#+1(

-$ /$)$F $(/+ PA
https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/thread
N:$)$!$)
thread = _thread.start_new_thread(th_name, th_func,
args [, kwargs])
E<! B ++
#$)C)$
E:$!& " $
/)!* $#$
&! (!#$ $+
: #$&!$ *
: $#$&!$( J
* * $+ $
,D$/+ B0!C
+ "&+
& &
/+AlG0GA( $0!G.GA( $.m
:$#$$)$!1
BAC+&
&4!$#$$$)$)&
)$++
E@-1E3$E@1E3&#$$
$$ J&)
$ $!&$)$:$
N$E@-1'3 $&$
-4++!E@-1E3$)
$& $/$I
$(&!$!&
!:$:2E@:13$&
P ,!$FdBd
1 *,<,
$)')$>C# ($
E@13$)+!:$
($ +FB$C)&!&'

$)/$ &4$$
&'#$4
$ &$&) $ B
C&( &
3.5.1- Implementierung von _thread
,$#/(&$K
) +!/$ &$!+&)
:$
4)$$ !
(:$& &$ $ B
$ +F) C# $:$ &!&
$
& &+!/$( ,
/$Fd!& &)$!
#$$# $&$
4&A
def waitForExitNotification(timeout):
notification = _thread.wait(timeout)
if notification == _thread.EXIT:
return True
else:
return False
N:$#$)$$$$,)$
(4&$F +FB$C$ )A
exit = waitForExitNotification(timeout)
if exit:
return
&K) ($ +FK#!
'$<(A,($I
)&$:$+!
/$$4<$&!
$++&

NK) #F )$!4&
!?BC& #$$
# (?BC
# )&+?BC$
animation_thread = _thread.start_new_thread("animation",
animations.next, () )
)&# !#$I
,&#>$$&)$
!&1 F
+( &$I
1 !&4 !)$/:$
-$ !&)$#4!
+'(B&: FC
# &&+$)$/
1 $)$,0@@)$&
F+BFC&D D !
&!)

" + +A
import machine, utime, _thread
import animations
touch_pin = 27
touch = machine.TouchPad(machine.Pin(touch_pin))
touch_threshold = 180
animation_thread = 100
while True:
try:
touch_val = touch.read()
except ValueError:
print("ValueError while reading touch_pin")
if touch_val < touch_threshold:
print("touched!!")
_thread.notify(animation_thread, _thread.EXIT)
utime.sleep_ms(50)
animation_thread =
_thread.start_new_thread ("animation",
animations.next, () )
utime.sleep_ms(200)
=" >$
/$ !& > $4"
('I
(Neopixel.brightness(brightness_value)
!& > $ F( $,
)&@$.22
%&+ $+&I# + !
$ >(' )$!$% )$!
&& ,+
>>> import machine, animations
>>> animations.running_dot()
>>> animations.strip.brightness(1)
3.6.1 - Der Photowiderstand
(' ,$ P#( &'
!&$!'(N$ !
&&$++I
")$$)&
&" !,'(
N$ &$>BO>+C
& / $$'!: &'!'$
$ >(&
N&)$)$&!
$') $ $#$' 4
$/'$$
3.6.1.1 - Analog Digital Converter - das ADC Modul
# )$# , !$#BO#
(C
#P& !&)$$-$ A
https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/adc
-$ $ (+ ?$-!
( )$$
#&)$4/$!$N$ )$
D$ !)&#(##0$#.
& $(#. $$)!&,>#<
(&,>#<:$+'$&!$)&
#0
$.5$)

)# &2@+(1-BFD3!&$
'J0B#0C$&
E72@13 +$B1C! $
+ F(
#$-$ $B#(C(!+$
,)&@$00@@1!&@ $ $
00@@ )$+
,4& 0A0$)!$" >)$
)!$,)&@$.22)+:#
!,$" &)$G++G
)-A
F( O F( E00@@\.22
,>$,(3@@!& 0=.!.3.3.3.3
$ A<+? $)
D !$I
1 E73!$
% ) 0=.!.3.3.3.3%)) 0=.&
"& $I,&*
!&)D &
/$$( 'N% ) )$
$!:$-$
F( 4&$:$+!
" +)
:$!$" +)$))$A
def set_brightness(brightness_val):
strip.brightness(brightness_val)
#$$&+ A
while True:
ldr_val = ldr.read()
brightness_val = int(ldr_val / 1100 * 255)
(D $$)&+I
while True:
animation.set_brightness(int(ldr.read() / 1100 * 255)t)
3.6.1.2 - Photowiderstand mit ESP verbinden
N&$'J$)$ !&
+$ $")$4&
&$>$!$,)$
+$W$ 1$+,B0pC
>(& 1#$!&
,($&$(&%<$
)$ JN,$)$ !&$
#B=C)&>$,(
- / $)$)A

3.6.1.3 - Das Breadboard
D$1'A / > $
>+!/ . >+
N $)$(!$&!&Breadboard
aufgebaut ist:
/$( + ')!$
,($A
#$ $P+ ')!1
%<)&+ ')K&
($!&)& %<$!
%<((%$(%<
>&%<>%<# $
/$ (&
K& + ')$$$
&($&>!
,$* )$#$ ,
!$)$(
3.6.1.4 - LDR testen
<>$'J &$$$
+&$!$&
)$>"!>$W$
>$)
, &$! > $!K
N$

4 – Steuerung der Animationen mit dem
WebServer
,(!, N$
,)$)$4!($ !
$$4! <)&BCP
,& ,($)!$,$#
$)$&'
N)$4 !$)$!
+("&
-$ )$'
80,>#<$
4.1.1 - Das network-Modul
&-$ -4 !,>#<1$
)$ $-4 !:(B)$/ $(
BCC! (B$* )$
C!-` B)$$+(<
:-$))$/+ -` C<
(B)$<$74$+$N>#$
$)$(C,'$($,>#<
(
https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/network
N )$ !& + !$
)$ &P+ (' &$
! -$ )$A
import network, utime
- B#C$)!&$!
#B$)$/+ C(
! #B#C!&$%'B&$+$
- C(4! *$
!&$!$($ )
#

4.1.1.1 - AP-Mode
N ,($))$4!&)(
,>#<#-$)A
ap = network.WLAN(network.AP_IF)
Dadurch wurde das WLAN-Interface allerdings noch nicht gestartet! Dies
geschieht erst durch
ap.active(True)
D$&B(PO<,>#<
<)&C$)$4&P" $
*!J& A
AP_SSID = "esp32"
AP_PASS = "HuchEinPw"
$$ A
ap.config(essid=AP_SSID, password=AP_PASS)
# J *P$B&)$/+ #!$
C+B+BCC $
$! #&$!&($ '$
4&D!)&/ (
,>#<B: C&#-&$!
($G: G&!:$$$)$!&
#-&$
timeout = 50
while not ap.isconnected(True):
utime.sleep_ms(100)
timeout -= 1
if timeout == 0:
break
print("\n======== AP started =======\n")
print(ap.ifconfig())
/D G\nG $+W$)
&)$$)!G$G$D $)$
,)$A

https://de.wikipedia.org/wiki/Escape-Sequenz
N$)$ !$!
)$++ +)$
<$+$$$ &$
:$ '+!(,>#<<)&+
/P<)&G+.G$
&(!$I
4.1.1.2 - STA-Mode
'K!N' &!
#-)$'!)&,>#<
($!K($)$!
%'$&B$ C
<)&(6!($
$&$!&$,$$/
$B: P$C$,(
)$
&&)!- #-!$(
A
sta = network.WLAN(network.STA_IF)
sta.active(True)
#$&$& (
$A
STA_SSID = "DeineSSID"
STA_PASS = "DeinPw"
N: $)$(!$4!
&")! (+!
<($$($!1$
)$ #$ K&D!($
A
networks = sta.scan()
for nets in networks:
if nets[0] == bytes(STA_SSID, 'utf-8'):
sta.connect(STA_SSID, STA_PASS)
timeout = 50
while not sta.isconnected():
utime.sleep_ms(100)
timeout -= 1
if timeout <= 0:
break
if sta.isconnected():
print("\n======== STA CONNECTED ========\n")
print(sta.ifconfig())
if not sta.isconnected():
print("\n======== STA NOT CONNECTED ========\n")
sta.active(False)
@13 (,>#<<)&$+
&
& >$+ & a@b
$+ ! !)$P
#F!$(!$
#( )$4
$1 &&' !1$($$
P!&$1
4.1.1.3 - mDNS Service
<<)&($K& -$
&$!&K& #$!$$,
+'&
>4$&- D $I
#$%$<(B<C
<(&$$)G $GV &
()<$!$ $
$)$!$<+$!$
)$4#)$#&4!$
1$)$($$)$4!$+$
< ' D&$ <)&
$a<b )$

https://de.wikipedia.org/wiki/Zeroconf#Multicast_DNS
https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/mdns
: J&!$,$#
G&& G$)$$A
hostname = "RainbowWarrior"
try:
mdns = network.mDNS()
mdns.start(hostname, "MicroPython with mDNS")
mdns.addService('_http', '_tcp', 80, "MicroPython",
{"board":"ESP32", "service": "mPy Web server"})
print("webpage available at {}.local".format(hostname))
except:
print("mDNS not started")
>$#- "$&
#/&&
#$$1$BC $
4.1.2 - Das microWebSrv-Modul
,( :$!,BC)$
(' 4&$( :$$
(&#%$$ '&'
,(-$ "->!& (
: E7E&&&$- +
-$ $ $(/+ )$PA
https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/
microWebSrv
#$+P !,()$+
<&&(+
<-,( ,($-,!&&
4!+$-,()$
'A
from microWebSrv import MicroWebSrv
N)-,()$ $)$&A

srv = MicroWebSrv(webPath = 'www')
srv.Start(threaded = True, stackSize= 8192)
!& 6"->)$P
2')&&!&+ +&
$&$#(,(
(
N+$N>$$)$4!&
$" P&&' !&$
S&& H$$$4!)&$
&& Eab!&
& "/+ $" !D$
B)&#C$&& ? B6&&&C
)$A
@MicroWebSrv.route('/')
def _httpHandler(httpClient, httpResponse) :
httpResponse.WriteResponseFile(filepath =
'www/index.html', contentType= "text/html",
headers = None)
$" (,() &!
& ('
,($$$
# &
&$ (/+$$:
$ &!)&6XE7E&&&X
(A
https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/
bootstrap.min.css
https://github.com/crxcv/Leuchteding/blob/master/pyboard_code/www/
style.css
: & 4 !4 $
+Q+: <G+G$G G
&

8."->
&$"->B? Cnh$A
<head>
<title>RainbowWarriorSettings</title>
<meta name="viewport" content="width=device-width, initial-scale=1,
shrink-to-fit=no"> <link rel="stylesheet" href="bootstrap.min.css" >
<link rel="stylesheet" href="style.css">
</head>
"/)$"->
Kommunikation zwischen HTML-Seite und dem Server:
https://wiki.selfhtml.org/wiki/HTTP/Anfragemethoden
:$ A
https://wiki.selfhtml.org/wiki/HTML/Formulare/form

4.2.1 - Aufbau einer HTML-Seite
HTML ist eine „Strukturierungssprache“, mit der dem Browser „gesagt“ wird, wie
die Inhalte strukturiert sind: welche Bereiche (Buchstaben, Wörter, Sätze) z.B.
Überschriften, was Absätze, was Aufzählungen, was Tabellen usw. sind.
HTML ist keine Programmiersprache – man beschreibt, welche logische
Struktur ein Inhalt hat (nicht mehr, nicht weniger).
Jeder einzelne Bereich wird mit einem Tag definiert. Der Beginn des Bereichs (am
Beispiel Absatz - (engl. paragraph)) wird mit einem öffnenden Tag <p>, das Ende
des Bereichs mit einem schließenden Tag </p> gekennzeichnet.
79
06e
<! DOCTYPE html>
/6e&/& !&/
&$& $
."#
<head>
<title>Titel der Webseite</title>
<link rel="stylesheet"
href="style.css"> </head>
/"#-! + &
!/&+)&&>)$
:
B C#$,(&
/6e
<body>
...
</body>
//6e $"->#%
-)$ $($ P$A
https://www.html-seminar.de/einsteiger.htm
https://www.html-seminar.de/html-grundlagen.htm

https://www.html-seminar.de/html-seitenaufbau.htm
https://www.html-seminar.de/css-lernen.htm
4.2.2 - HTML - Formulare
:$ ($<$):(?B/+
<!<C#$& ()$
https://www.html-seminar.de/formulare.htm
https://wiki.selfhtml.org/wiki/HTML/
Formulare
4.2.3 - HTTP - Kommunikation mit dem Server
/" $#+!,($/&
$)*$
!$G G" !$
<G"+?+ G
(A(-
/#$$/&)$GW$GB#!/+A
4C!((G+GB#&!/+A
)C&&
)$'H%'
W$&$#- -
##$$ "+)P-(A
66<!%!"#!6!N!>!#$6<<,'
$K)$-%$6
#&--)$'"&
W$)$/+ $B$)$$"->C
# #&$W$' B$/&C
"-> +
H%'- >:$ ,(
Werden durch den Request lediglich andere Daten als Antwort empfangen, so ist
die GET-Methode die richtige Wahl.
,$W$$(('!6-
,
,>!&4 !$6
),
https://de.wikipedia.org/wiki/
Hypertext_Transfer_Protocol
https://wiki.selfhtml.org/wiki/HTTP/Einsteiger-Tutorial
https://wiki.selfhtml.org/wiki/HTTP/Anfragemethoden

4.2.4 - Die HTML-Seite
<!DOCTYPE html>
<html>
<head>
<title>RainbowWarriorSettings</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="bootstrap.min.css" > <link rel="stylesheet"
href="style.css">
</head>
<body class="h-100">
<div class="ground"></div>
<div class="sky">
<div class="cloud variant-1"></div>
<div class="cloud variant-2"></div>
<div class="cloud variant-3"></div>
<div class="cloud variant-4"></div>
<div class="cloud variant-5"></div>
</div>
<div class="rainbow-preloader">
<div class="rainbow-stripe"></div>
<div class="rainbow-stripe"></div>
<div class="rainbow-stripe"></div>
<div class="rainbow-stripe"></div>
<div class="rainbow-stripe"></div>
<div class="shadow"></div>
<div class="shadow"></div>
</div>
<div class="container text-white align-items-center d-flex flex-column h-100
justify-content-end pb-md-5">
<h1 id="id1">RainbowWarrior</h1>
<h2 id="id3"></h2>
<div class="mt-3">
<form class="form-group" method="POST" action="/"
role="form"> <h3 class="mb-3" id="id1">LED Pattern
auswählen:</h3> <div class="input-group">
<select class="custom-select" id="inputGroupSelect04" name="light">
<option selected>Animation auswählen ...</option>
</select>
<div class="input-group-append">
<button class="btn btn-dark" type="submit" >auswählen</button>
</div>
</div>
</form>
</div>
</div>
</body>
</html>
)"-> $
6K$#"$)$'

:$ D &!+&)$
#$& # &A
<form class="form-group" method="POST" action="/" role="form">
<h3 class="mb-3" id="id1">LED Pattern auswählen:</h3>
<div class="input-group">
<select class="custom-select" id="inputGroupSelect04" name="light">
<option selected>Animation auswählen ...</option> <option
value="myValue">MyName</option>
</select>
<div class="input-group-append">
<button class="btn btn-dark" type="submit">auswählen</button> </
div>
</div>
</form>
"->: D&!N)$$
()$,($)$)$$GG
&!& -BAC&$GG!&
$" (&& :4"->
<form>A
<form class="form-group" method="POST" action="/">
und endet mit dem schließenden Tag </form>:
</form>
$4P"&
Z + :$(&
<h3 class="mb-3" id="id1">LED Pattern auswählen:</h3>
G"G Z<,<$$
&0 J%4J'
N()$!&/$(&A
<div class="input-group-append">
<button class="btn btn-dark" type="submit">
auswählen </button> </div>

, ,(&!&$6+$
7P& lA( $m(
<select class="custom-select" id="inputGroupSelect04" name="light">
<option selected>Animation auswählen ...</option>
<option value="animationName">MyName</option>
</select>
&+&- 4 &B C
)$,
&+! ,!
+&-$&' &4"&$)$
( $P
<$&$$#
:K$#&$)&<option selected>$
</select>+( $A
<option value="running_dot">Running Dot</option>
72>E>,!#((&
(&&&$)!$#)$
"&!( $ !&
F+I &&
#4
(&( JMG-N
?!+&-)&
G" +GOL&)$ $(N $4!
K/&N $:(X'X!X4X!XX "$)
OLB'C!OLB4C$OLBC
8,(
<$&&! $%-!
#:$ 6-)$)
4.3.1 - Route-Handler des microWebSrv Moduls
$&$)&$" -&(+
$" %$ (P D A

@MicroWebSrv.route('/')
$" 6& D A
@MicroWebSrv.route('/', 'POST')
KW$$&:$!&$
#&!&(( #&
&>4&& :$ &
!
:%W$ $! #&)$A
@MicroWebSrv.route('/')
def _routeHandlerGet(httpClient, httpResponse):
httpResponse.WriteResponseFile(
filepath = 'www/index.html',
contentType= "text/html",
headers = None)
/6W$$()$') $
&
/ -$ $('$!&&:
4A
@MicroWebSrv.route('/', 'POST')
def _routeHandlerGet(httpClient, httpResponse):
formData = httpClient.ReadRequestPostedFormData()
httpResponse.WriteResponseFile(
filepath = 'www/index.html',
contentType= "text/html",
headers = None)
<$&++
,&'! '$,(&$
-#$$# $
,4K)&F$A&
:$F( $&(+!&(+$$$Dies
würde uns allerdings immense Probleme bereiten, wenn main.py auf die Variable
zugreift, während sie zur gleichen Zeit von webSrv.py geändert wird (und dies kommt
häufiger vor als man denkt!)

)(-, $
( !+/$$ A
if "light" in formData:
_thread.sendmsg(_thread.getReplID(), "light:
{}".format(formData["light"]))
>>+!D G G)$P
!$ 1$$)$ J
FBF!C<
D !F&$
E@(-&-)$#$I+
F-$ (I
>PQ>@173(,( $$)
) lm++ +$G G&+'
1$+&I&!&
(++ +$>)PI
4.3.2 - Thread-Messages vom Server in main.py empfangen und
verarbeiten
N-$+-+)$4!&
+)$?+ )E@(--"1'3 $I
2E@13+&(+
<' $+ BF+!F!
C!&E#-@BO<C!0BOC.BOC
EB&$(
C
<!&(($!
G AaG Gb
N,(aG Gb)$!& a.b
GAG+
72B4D@-1>>3 $!( $$BG G!
aG Gb
&(&,aG Gb#
+!&,& #$
1A( )$$%&(!(
++ +$>)
( $a@b+BC>)!)$/
(

1$+ ?!&
$/$&:$',
)$/+ PA
https://docs.python.org/2/library/string.html
#$ &($#+!
# '$#$J)&&!(
$,(DB.@@@C)$!
+ B $+$C)$1$ !
)$: $!)$
$# &
D$$A
_thread.ReplAcceptMsg(True)
wait_before_start_thread = 2000
# ...
while True:
# ...
msg = _thread.getmsg()
if msg[0] == 2: #true if msg is a
String values =
msg[2].split(":")
if values[0].strip() == "light":
if
_thread.status(animation_thread) !=
_thread.TERMINATED:
_thread.notify(animation_thread,
_thread.EXIT)
utime.sleep_ms(wait_before_start_thread)
_thread.start_new_thread("animation",
animations.start,
(values[1].strip(), ))
4.3.3 - Animationen mit einem String starten
<$&&BC&:$
$!(# & &
+$ $:$?BC:$
BFC
:$ #&!
F&$

#$%$&!$$#)$+!
>
<$4& &!+F!
#A
def start(animation_name):
animation_dict[animation_name]()
4.3.4 - Zwei ähnliche Routinen in einer Funktion
zusammenfassen
<$&)&$+!)+' $A
,# '$&++!$)
$&?
&:$ #)$
<F++&$!&)$'+!
:$#&$B #$,
$&' &$CB $$& &$C
#'&$,( +F&' $
#:$+B?C

def handleAnimations(animation_name=None):
_thread.notify(animation_thread, _thread.EXIT)
if animation_name == None:
utime.sleep_ms(50)
animation_thread = _thread.start_new_thread("animation",
animations.next, () )
else:
print("starting animation
{}".format(animation_name))
utime.sleep_ms(wait_before_start_thread)
animation_thread =
_thread.start_new_thread("animation",
animations.start, (animation_name,))
<$4&+D $1$)
$A
handleAnimations()
1$(-$
handleAnimations(values[1])

5 - RainbowWarrior als Wecker nutzen
<$& !&>+$&)+
+ (' $
$ ,)$)
:6 6+$!
$)$6+$* $
)$1$!&$$N) 4
&$-$ $D':$)$1$
20)+
)+$ >$+!)+
$ B:W$)' $$&$4
& C-)$&!&$$
(& &K>$+
https://de.wikipedia.org/wiki/Ferroelektrischer_Lautsprecher
5.1.1 - PWM - Pulsweitenmodulation (Pulse-Width-Modulation)
,-)+ # (! $%
#!&>)
>P,!
#&,-
,)$
!K
($ %P
$,+
Bhttps://de.wikipedia.org
/wiki/Pulsweitenmodulati
onCZ)$(
B
K&$)&
GG$G$G!)&0$@
$C
$& &
$
,1&
& (G, G+!G, G&&
#$/ $& !$
')4 !$& ! GZ)G
?#)&+$)&$&
$') (!& $GG$
5.1.1.1 - Das PWM-Modul
https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/pwm
-2@"1-BFA2DBF#2DBF2D3
erstellt eine Instanz des PWM, wobei
-<$! &
! ,&
AB+ C):W$)")!$)
& B& !))$ !&
$&+ C$ A2")
#B+ C#) $o$ A2@o
B+ C!D(& B$ A@C
-@A1BAD3):W$)")#$&$$ *' !
$),#$&:$
:W$))$!$* + &
-@13 +&!#$$&++
-@1BA2DBF#2DBF2D3 +&

5.1.2 - Piezo-Speaker mit dem ESP verbinden
N)+)$(!$ 1..
(!&%<%<B (%<$
/C
5.1.3 - Das RTTTL-Modul
>?>$$(:
* 4$- "/+ G6-GA
'OneMoreT:d=16,o=5,b=125:4e,4e,4e,4e,4e,4e,8p,4d#.,4e,4e,4e,4e
,4e,4e,8p,4d#.,4e,4e,4e,4e,4e,4e,8p,4d#.,4f#,4f#,4f#,4f#,4f#,4
f#,8f#,4d#.,4e,4e,4e,4e,4e,4e,8p,4d#.,4e,4e,4e,4e,4e,4e,8p,4d#
.,1f#,2f#'
* $ !$(* +B
>-$ C)$&A
0 I0BAX6-XC
. %7 BO0=!O2!O0.2C!&GOG '
G8G$!K<>'1 G5G
&# $$&GOG((
6(>:GOG#+ &
'+-$
' $*($ A
B+ C'

I B!!!!!!+O$C$
4$"
B+ CH7
>-$ -$ &!&&
G +G$&A
https://github.com/dhylands/upy-rtttl
K!&$ \+:
!+&
,&/ !+
&-$ $6G G# &6
G G $ ++
mkdir /flash/lib
cp rtttl.py /flash/lib
,/+ PA
http://www.picaxe.com/RTTTL-Ringtones-for-Tune-Command/
http://mines.lumpylumpy.com/Electronics/Computers/Software/Cpp/MFC/
RingTones.RTTTL
5.1.4 - Real Time Clock - das RTC Modul
--$ 4&) D$&
-4 &-($
N))$B!&$$-
C
#$J4&G+ +G-$()
$!( :$$&$&
($& (' $-4 )$
1$!&$ )$&I
-$ $)$PA
https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/rtc
&:$!$ ,)$$)!A
2@('J13 )
@13 '$) !&$+
&&AB!!a!$a!$a!bbbC
@13$$ D $+ )$AB!!!$!
$!C
ND)$ ($P!
-($
@-E#17BF-E-DBFD3& (G+ +G
$)&
5.1.5 - Zeitabhängige Funktionen - das utime-Modul
$-$ :$)$1$!$
D$#$JD( $ $
https://docs.micropython.org/en/latest/pyboard/library/utime.html
@1BD3(D!$BC
$+ $5 B!!!$!$!!&!
C,#$&!&$ )
$)
o $B)/.@08C
oB00.C
oB00C
o$B@.C
o$B@29C
oB@29C
o&B@=-C
oB0==C
@1E-3% )$
( '$+ $5 B!!!$!$!
!&!C#) $)&
@0@0093@$!$+ &$!)$
@-EB C #D
- $$
@-E13 #D
-$$
@E13D - $)$
)+$ & ):$&)$
/+ )!$ )$
@E1F3#$!&
(E1FEE--$ $)$

PC &$ +((
C
@Eff15F43D))&)&
,)$
< #)&$(, $
&!)$
o@13#) $)$!)&
@0@0093@$ )(
5.1.5 - Songs mit dem PWM abspielen
N)$+$)$+ ! &$
+
,+ -$ !&&
$,-$$)&4&$
* >
#$J&F-$ +!$#+
$&#$J4& +)F+B..C
P$,-$) !$&)$
$%$!$,-)$(:$
$('&4D$4&1 !$$
)&! /$)$#$A
from machine import Pin, PWM
from rtttl import RTTTL
import _thread
piezo_pin = 22
piezo = PWM(piezo_pin)
piezo.deinit()
abort_playback = False
N+&>6<%,
>$*&#$$>'
(&$!( )$ !$$
) )$&!&A

SONGS = [
'OneMoreT:d=16,o=5,b=125:4e,4e,4e,4e,4e,4e,8p,4d#.,4e,4e,
4e,4e,4e,4e,
8p,4d#.,4e,4e,4e,4e,4e,4e,8p,4d#.,4f#,4f#,4f#,4f#,4f#,4f#
,8f#,4d#.,
4e,4e,4e,4e,4e,4e,8p,4d#.,4e,4e,4e,4e,4e,4e,8p,4d#.,1f#,2
f#',
'MarioTitle:d=4,o=5,b=125:8d7,8d7,8d7,8d6,8d7,8d7,8d7,8d6
,2d#7,8d7,p,
32p,d6,8b6,8b6,8b6,8d6,8b6,8b6,8b6,8d6,8b6,8b6,8b6,16b6,1
6c7,b6,8a6,
8d6,8a6,8a6,8a6,8d6,8a6,8a6,8a6,8d6,8a6,8a6,8a6,16a6,16b6
,a6,8g6,8d6,
8b6,8b6,8b6,8d6,8b6,8b6,8b6,8d6,8b6,8b6,8b6,16a6,16b6,c7,
e7,8d7,8d7,
8d7,8d6,8c7,8c7,8c7,8f#6,2g6',
'Tetris:d=4,o=5,b=160:e6,8b,8c6,8d6,16e6,16d6,8c6,8b,a8a,
c6,e6,8d6,
8c6,b,8b,8c6,d6,e6,c6,a,2a,8p,d6,8f6,a6,8g6,8f6,e6,8e6,8c
6,e6,8d6,
8c6,b,8b,8c6,d6,e6,c6,a,a'
]
,&:$4!&($(-
$$$&
(-$)$$:$&$6<%
&' $+1 +# J&
1 #$)(> <$&K<!
(!':$+ F$$!<
+ $+&!
& A

def find_song(name):
""" find_song(name)
searches in SONGS list for song name
and plays its tones with the play_tone
function name: name of the song to
search for
"""
global abort_playback
abort_playback = False
for song in SONGS:
song_name = song.split(":")[0]
if song_name == name:
tune = RTTTL(song)
for freq, msec in tune.notes():
play_tone(freq, msec)
if abort_playback:
return
piezo.deinit()
D&#$!&)$+A
E2@-1>>3B6D + !
++ +$($ !&
++ +$(a@b <!a0b
($a.b
AF@13 $$!( :$
$BC)&6K)$&AW:W$)$
$
)&,+ (
F+ &<!1 ! &!
,& &+ F
+
-#E1AF3$(:$PFBC+ )&"&
K) < ,-)$# ($ +FBC
4& )$+&:?<PBC)!
$ &A

def play_tone(freq, msec):
"""play_tone(freq, msec)
plays a single tone on piezo buzzer
freq: frequency of the tone
msec: duration in millis
"""
global piezo
global abort_playback
print('freq = {:6.1f} msec = {:6.1f}'.format(freq, msec))
if freq > 0:
piezo.freq(int(freq))
piezo.duty(50)
ntf0 =waitForExitNotification(int(msec *0.9))
piezo.duty(0)
ntf1 = waitForExitNotification(int(msec * 0.1))
if (ntf0 or ntf1):
abort_playback = True
piezo.deinit()
"&,(+ A)$&&!9@o,
(!$$$@)$)# J& )0@o
(&N( /$)$!
&)&(1 +
65 6+$$)$!&
6+B@0C$&$
#$$
D$ )4&:$!#$$+A
def waitForExitNotification(timeout):
""" waitForExitNotification(timeout)
uses _thread.wait(timeout) to sleep for amount of
ms saved in timeout,
checks notfication for _thread.EXIT notification.
Returns True if _thread.EXIT notification is recieved,
else returns False
timeout: (ms) time in ms used for _thread.wait()
return: (boolean) True if _thread.EXIT is recieved, else
False.
"""
ntf = _thread.wait(timeout)
if ntf == _thread.EXIT:
return True
return False
$)& / $
/ &!:$D ( &
, /$B22E@$R&'C)$!&$:
$
2.+&-,
N$,$&' )$4(& &
>#
N$#)$+!4&/
+$$ +/&
N&#)&-)$! MG N
&D $+$"
&!&+)+
S &$ (' +A
S%OLH+I
'$+&A
OGG
<$&$+&-
" &&$>#$!$7
<!6<%>+)$P+$
$4#<!$)& !
&'

"$$? A
</br>
</br>
<h3 class="mb-3" id="id1">Song
auswählen:</h3> <div class="input-
group">
<select class="custom-select" id="inputGroupSelect04"
name="sound"> <option selected>Song
auswählen...</option>
<option value="OneMoreT">One More Time</option>
<option value="MarioTitle">Super Mario Titelsong</option>
<option value="Tetris">Tetris Theme</option>
</select>
<div class="input-group-append">
<button class="btn btn-outline-secondary"
type="button">Button</ button>
</div>
</div>
Übrigens: man muss die HTML-Seite nicht zwingend zuerst auf den ESP kopieren
um sie anschauen zu können. Da sie sich gemeinsam mit ihren zugehörigen CSS-
Seiten im Ordner www befindet, kann man diese einfach mit einem Doppelklick im
Browser öffnen.
5.2.1 - Verarbeitung der Daten auf dem Webserver
#$ )$#(A
&(+ $$GG+&!$
GG
6()$$ 'N$
-I
)$D A
if "light" in formData:
)&$A
if formData:
$!-$&!&+
&$
- &$!,
&!I

BC
(& I$B#$$C
( BC&I
if formData:
message = str(formData)
_thread.sendmsg(_thread.getReplID(), message)
($(&(+$
-
+ &$$$!&($A
msg = _thread.getmsg(
if msg[1] == 2:
print(msg[2])
>>> {'light': 'crossing_dots', 'sound': 'Song+auswählen+...'}
6I
$!$$'(!& /$(
&$!,&I
& ! :PI
-$&+:K- &
(/$$( $!&$ /$
,#&!&&
(&
:/$)& 2> >4&+'
,+! G$G
# 7)&GG#$GG
6$+$$A
>{'light': 'crossing_dots', 'sound':
'Song+auswählen+...', 'button': 'light'}

5.2.2 - Verarbeitung der Daten in main
<$&$$$!1 4 +$
$ 1$+
_thread.getmsg()[2] $ !&$&
$& # J&+!
/$( $GG&$4&
andleAnimationThread,!GGA
# read threadMessage from microWebSrv
msg = _thread.getmsg()
#check if message is String
if msg[0] == 2:
#convert String in dictionary
values_dict = eval(msg[2])
#call function according to value of
"button" if values_dict["button"] ==
"light:
handleAnimationThread(values_dict["light"])
# (&G$GA
elif values_dict["button"] == "sound":
handleSoundThread(values_dict["sound"])
6Funktion handleSoundThread(song))$P!4&
A
sound_thread = 100
def handleSoundThread(song):
""" stopps running sound thread and starts a new thread
with value saved in 'song'
song: (String) name of the song to start
"""
global sound_thread
_thread.notify(sound_thread, _thread.EXIT)
sound_thread = _thread.start_new_thread("sound",
songs.find_song, (song, ))
:I

, $$+&$!$
<$(,$+
>4J%)!&(#
) $ ': 4 !$
# + &
2)$,)
N $ D)$)$$-$ <
&(+$&$!$ ) $+
1 +&A
import utime
datetime = utime.localtime()
K#$$,$ )$)&!$
O$ BC $" :$
D$$!$+ $5 AB!!!$!$!
!&!C
, &$$$+ )/#$ !$
N)B$$-$C$++ +$)!
&$)$&:$'A

5.3.1 - String Formatierung
/&+#$$$)!$&1
?$)$
-#$$I"/+
#$?$1 #$D$&&
# <$)+ ! J? $(
# $
>>> age = input("Alter? ")
$ + #$X# [X!# B)/..C
&/'$1
+A
Alter? 22
<$& &# ?$$A
>print("Alter: {}
Jahre".format(age)) Alter ist 22
Jahre
B(C(1 ($
) lm
, &$&!$& +GG !&A
>>> type(age)
<class 'str'>
,$!$
N/$$)$4!'$&
,BC ',
(A
>>>age=int(input("Alter?"))
>Alter? 22
>type(age)
<class 'int'>
5.3.1.1 - Arbeiten mit mehreren Platzhaltern

<&!&%&# (0.!08$05B#
+0!.!C$& ?!&
J(A
>print("Meine Geschwister sind {}, {} und {} Jahre
alt".format(age1, age2, age3)
Meine Geschwister sind 12, 14 und 18 Jahre alt
, ) ,BC&
# 4&$ #$+!
BC)$('A
>print("Meine grosse Schwester ist {2} Jahre alt, mein
kleiner Bruder {0} und meine kleine Schwester
{1}".format(age1, age2, age3))
Meine grosse Schwester ist 18 Jahre alt, mein kleiner Bruder
12 und meine kleine Schwester 14
<&$!&1 !D $+ B!C
+)$)9#$N)
& J$A
>print("Zeit: {}:{} Uhr".format(time[0],
time[1]) Zeit: 9:6 Uhr
> $!&&!N)
$)& $$-$ $
& JA
>print("Uhrzeit: {0:02d}:{1:02d}
Uhr".format(time[0], time[1])) Uhrzeit: 09:06 Uhr
,@.$!#$)& $!
, @( &$!
,$) ) "B@A0AC)&
)$I
-#$ &+A

>>>print("die Hauptstadt von {province}
ist{capital}.".format("province" :
"Hessen", "capital" : "Wiesbaden"))
die Hauptstadt von Hessen ist Wiesbaden.
# $+#$!$$
&A
>month = "April"
>text = "Mein Geburtsmonat ist {}"
>text.format(month)
>print(text)
Mein Geburtsmonat ist April
,#&$+ P:$A
https://www.python-kurs.eu/python3_formatierte_ausgabe.php
5.3.2 - Formatierung der Systemzeit
N )$,))$4!&$
) # J&!$
"-> &(+( !&format()$$
&4
D$ $&++$$" +
D$$, J&A
..@9.@0502A@2N
N$+ $
B@C!B0C!B.C!$BC!$B8C!B2C!
&B=C!B3C
D$Z4&$D$$$&
&(++A
datetime_dict = { "year" : datetime[0], "month" : datetime[1],
"mday" : datetime[2], "hour": datetime[3], "minute" :
datetime[4],
"second" : datetime[5], "weekday" : datetime[6],
"yearday" :
datetime[7]}

<$&? + ) &!
&$GG<p> (text) </p><$?
&$$, I
<(<form>-& )$4<p>!
$ ) $(?! J</p>A
<p>
{mday:02d}.{month:02d}.{year:04d} {hour:02d}:
{minute:02d} Uhr </p>
<form
...
(& $4!&&(
!$? ( A
file = open("www/index.html")
htmlSite = file.read()
file.close()
-file = open(„www/index.html)&!B
C&!1 file+
)$/+ $!&&?4
,?$$file.close()
/$ &.
file.read() )$
<$&!#$$,$ )
+&$ '$
)$&$$" :$1E-CC D
A
datetime = utime.localtime()
datetime_dict = { "year" : datetime[0], "month" : datetime[1],
"mday" :
datetime[2], "hour": datetime[3], "minute" : datetime[4],
"second" :
datetime[5], "weekday" : datetime[6], "yearday" : datetime[7]}
Nun können wir dafür sorgen, dass die Werte in die Platzhalter mit
%@13&4A
htmlSite.format(**datetime_dict)
++ 1??3(F!F
:XXO( $!XXO( $!$& &

<$&+++# !&#$$
BO#C ((()$&
/&$-(-@(-1-2>G@>3
GG@G)$
&$'!&!"->
#&&
"$):$(-H$X+OX^
2%TA
httpResponse.WriteResponseOk(headers = ({'Cache-Control':
'no-cache'}), contentType = 'text/html', contentCharset =
'UTF-8', content =htmlFile)
&(+$ J$A
from microWebSrv import MicroWebSrv
import _thread, utime
srv_run_in_thread = True
#open file "www/index.html" and save content as String in
htmlSite and
#close file
file = open("www/index.html")
htmlSite = file.read()
file.close()
#route handler for index.html with
#method GET
@MicroWebSrv.route('/')
def _httpHandlerPost(httpClient, httpResponse):
# get system time and save it to datetime_dict
datetime = utime.localtime()
datetime_dict = { "year" : datetime[0], "month" :
datetime[1], "mday" : datetime[2],
"hour": datetime[3], "minute" :
datetime[4], "second" : datetime[5],
"weekday" : datetime[6], "yearday" :
datetime[7]}
#insert datetime_dict values in placeholders #
in htmlSite
htmlSite = htmlSite.format(**datetime_dict)
#send htmlSite as response to client
httpResponse.WriteResponseOk(headers =
({'Cache-Control': 'no-cache'}),
contentType = 'text/html',
contentCharset = 'UTF-8',
content = htmlSite)
#route handler for index.html with
#method POST
@MicroWebSrv.route('/', 'POST')
def _httpHandlerPost(httpClient, httpResponse) :
#read posted form data. If data (dictionary) received,
#convert to string
#and send threadMessage to mainThread
formData = httpClient.ReadRequestPostedFormData()
print(formData)
if formData:
message = str(formData)
_thread.sendmsg(_thread.getReplID(), message)
#get system time and save it to
# datetime_dict
datetime = utime.localtime()
datetime_dict = { "year" : datetime[0],
"month" : datetime[1], "mday" : datetime[2],
"hour": datetime[3], "minute" : datetime[4],
"second" : datetime[5], "weekday" : datetime[6],
"yearday" : datetime[7]}
#insert datetime_dict values in placeholders
#in htmlSite
htmlSite = htmlSite.format(**datetime_dict)
# send htmlSite as response to client
httpResponse.WriteResponseOk(headers =
({'Cache-Control': 'no-cache'}),
contentType = 'text/html',
contentCharset = 'UTF-8',
content = htmlSite)
#create instance of MicroWebSrv and start
#server
srv = MicroWebSrv(webPath = 'www')
srv.Start(threaded = srv_run_in_thread,
stackSize= 8192)
Nachdem alle Dateien auf dem ESP aktualisiert und dieser neugestartet wurde,
sollte nun auf der Webseite die Systemzeit angezeigt werden.

28)$$,
N) )$4!$&,!
D$$&!+$!
,$
# &$&"->,+ )&$
#)" )&? B$$
N)C&/$#$+%
' &+&-$)$4/$
+ )& GG)$
<form class="form-inline" method="POST" action="/"
role="form"> </form>
)&? $/$:&<div>
)$
<div class="input-group">
</div>
<div>&$)$$? ?
&$<input> D$K<input> 4
<label>,& D (<input>+ )& &!
/& $,$
$$#& &4GG$
G7G
<input>& 2>G!)&2>>
,7&#:$<$)
)6+ 4&-! ) P
"4& ) $)!&)$#))
$)
<label class="sr-only" for="inlineFormInputDate">Datum</label>
<input type="text" name="date" class="form-control mb-2"
id="inlineFormInputDate" placeholder="{mday:02.02d}
{month:02.02d} {year:02.02d}" name="date">
<label class="sr-only" for="inlineFormInputTime">Uhrzeit</label>
<input type="text" name="time" class="form-control mb-2"
id="inlineFormInputTime" placeholder="{hour:02.02d}:
{minute:02.02d}">
: $/$$)&? $
J<div> + )$<div> #$
&GG$G7H,($&

,$$$#&&)$+!& /$
&&&G G! 7)
&GG
<div class="input-group-append">
<button type="submit" class="btn btn-dark mb-2"
name="button"value="datetime">Zeit einstellen</button>
</div>
D$)$A
<form class="form-inline" method="POST" action="/" role="form">
<div class="input-group">
<label class="sr-only" for="inlineFormInputDate">Datum</label>
<input type="text" name="date" class="form-control mb-2"
id="inlineFormInputDate" placeholder="{mday:02.02d}.
{month:02.02d}.{year:02.02d}" name="date">
<label class="sr-only" for="inlineFormInputTime">Uhrzeit</label>
<input type="text" name="time" class="form-control mb-2"
id="inlineFormInputTime" placeholder="{hour:02.02d}:
{minute:02.02d}"> <div class="input-group-append">
<button type="submit" class="btn btn-dark mb-2" name="button"
value="datetime">Zeit einstellen</button>
</div>
</div>
</form>
+&$)$)( $1
)$&&#: A
rtc = machne.RTC()
# J& !(-+
&$)&/$!+!,
U UGG+,)$ff! &
elif values_dict["button"] == "datetime":
#Systemzeit initialisieren
&)$ $4=,A!!a!$a!$a!
bbb
,( $F)&$BC$N)
BAC
( $+&N
+ )$ ! &:$$A
:$&)$$$N))
,+ &>,!
( (BC(&4!
&(
def setSystemTime(date, time):

"""converts date and time (String) in integer values and
sets system time
date: date as String (dd.mm.yy)
time: time as String (hh:mm)
"""
date_list = list(int(i) for i in date.split("."))
date = tuple(date_list.reverse())
time = tuple(int(i) for i in time.split(":"))
rtc.init(date+time)
E213@-1>@>3A
K !GG($(K
,
%)$!&
1E3>(
2-1E@7133)&A
E@713 >$B(!
!!!C$& >$+ B(
$$+ &C
2-113@-1>>33A
K !GAG($(K
,$+ BC(,$+
@1*3$)&AQ&!
$+ $'&!
:$& J$$A
elif values_dict["button"] == "datetime":
#initialize system time
setSystemTime(values_dict["date"],
values_dict["time"]
5.4.1 - Fehler in der Eingabe au:angen
6 ($$N))$:
$%&.@05$056
(&N)$++ +$
:' & $)
Um herauszufinden, ob wir split() mit einem Doppelpunkt oder einem Punkt
durchführen müssen, können wir einfach den String nach dem gesuchten
Zeichen (oder der gesuchten Zeichenkette durchsuchen.
%@:113BF26F2D3$$
D!BC&$
$+ $)!)&
)$$$&$
Wenn die Suche erfolgreich war und die Zeichenkette gefunden wurde, gibt
sie die Startposition zurück, ansonsten -1.
date.find(":")& $ 5)$!
&)$$)&!-$ $
(&
date.find(".")& $ 4)$!
!$$!<.B(A
@)$)' IC
4&+!Dff )&
' B 05.@05C$: ! )&D
(!.@@@)$
-134&#) D )$
&$&(
4&( $:$! )
$*($($+ $$$
$$A

def convertDateOrTimeToTuple(s):
"splits given String by '.' or ':'. If resulting List
has len = 4 it is interpreted as date and will be
converted in (yyyy, mm, dd). if value for year has two
digits, 2000 is added.
string in format hh:mm or dd.mm.yy(yy) return: Tuple (hh,
mm) or (yyyy, mm, dd)
"""
if s.find(".") >= 0:
s_list = list(int(i) for i in s.split("."))
else:
s_list = list(int(i) for i in
s.split(":")) if len(s_list) == 4:
s_list.reverse()
if len(str(s_list[0]))
== 2: s_list[0] +=
2000
return tuple(s_list)
5.4.2 - Das Timer-Modul
<$&!$$ ) &
N ,$))$4!&)$')
P")$-$ A
https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/timer
-(A
HI$%CH' '$(D$++,
(D $!++$$
:$$!&P
$(&H&J '$& ?+ )++&,D
$!& :$$$!P
JC(HIH&$)!$(Dq)$
!++!+$$&&
$R'9%$A/( '"$@
(&&
2@'1E3 )F<$
(&
"&&@)

B+!! !+C
-A DB$ A0@C
AP-$B$ A6C
A :$!$& !&D
$B$ A<C
-A$,P!&,!
& B&$$$C
5.4.2.1 - Das Timer-Modul als Wecker einsetzen
N-$ ,))$4&
B4 $, &
+C$V ! -
'@13)&D$$ :$ &!
$$&! D $
,$,$ $& D!
)$# # &? $:
)&#:)$# D)$A
<form class="form-inline" method="POST" action="/" role="form">
<div class="input-group">
<label class="sr-only" for="inlineFormInputTime">Weckzeit</label>
<input type="text" name="alarm" class="form-control mb-2"
id="inlineFormInputTime" placeholder="{hour:02d}:{minute:02d}">
<div class="input-group-append">
<button type="submit" class="btn btn-dark mb-2" name="button"
value="alarm">Weckzeit einstellen</button>
</div>
</div>
</form>
+ &)$0A
timer = machine.Timer(1)
$P:$# BC!&)$D
$+ (A
def setAlarmTime(time):
time = convertDateOrTimeToTuple(time)
# J$&))$$+ $- $!
&- $)$D+$# 4A
curr_time_toup = utime.localtime()
curr_time_sec = utime.mktime(curr_time_toup)
alarm_time_sec =

utime.mktime(curr_time_toup[0:3]
+ time + curr_time_toup[5:])
EE-B6SD)&BWD$&
/a@AbBaAb& (@n)$!a2Ab
2BC
N-F)$!&$EE(EE
)
<&!&& K)B09@NC,$3@N
!&( A&$BC
,$$$-$$$)!&'
D+$1$ FF&'
EE$-E(I
,: !&#) $+)$+F
I
period_sec = alarm_time_sec -
curr_time_sec if period_sec < 0:
period_sec += seconds_per_day
<$4& $ :$P#
+,- $&!&
$!&+O+F\0@@@)A
timer.init(period = period_sec*1000,
mode = timer.ONE_SHOT, callback= _timer_callback )

5.4.2.2 - Timer Callback
<$&P!&+ !& $
,4)$ )$$+ $#
,(#)$!
$ + &&&$+
# $ # + $
$
N)$ )&' )$+ !$1
+& ! )
&' &$!+P ! #(+
)$
:$$ #$!
:$
def _timer_callback(timer):
"Timer callback function to start playing
alarm_song and start "blink" animation
timer: according timer
"
global is_alarm_running
handleSoundThread(alarm_song)
handleAnimations("blink")
,$ $!&- &#
G G+
22# ++
<$4&$$!$4 !# &)$
++
D$# 4&$)I
# &&' !$$)$+
#$!&$# '$I
&$1 F F$&)$/
$: )
,# &$!$)$#
#$B$&)$, C,#

&$!$&$: )!$&
)$!)&#)$&
D$/: +)&$ A
is_alarm_running = False
&$$)! $
FF A
is_alarm_running = True
# J&$!$(&
"&)$+!F F$&$++
#: ! '#&A
#if touch is registered check if alarm
#is running
if touch_val < touch_threshold:
if is_alarm_running:
handleSoundThread(" ")
handleAnimations("off")
is_alarm_running = False
else:
# print output and start function handleAnimations()
# without argument to start next animation
print("touched!! value: {}".format(touch_val))
handleAnimations()
- &'&$I
# K)$")$<&I1 )$
: #$# $
%! )$0@@o $&
ND $&$!)$: $
! $$$ D )&
$$& )$
K :' $ $%$)$P
<$&1+$I
macOS: Wichtigste Terminal Befehle
Befehl Bedeutung Funktion
cd change directory Wechselt in das angegebene Verzeichnis
ls list Auflistung von Verzeichnissen und Inhalten
cp copy Kopiert Dateien und Verzeichnisse
mv move Verschiebt Dateien und Verzeichnisse
rm remove Löscht Dateien oder Verzeichnisse
mkdir make directory Verzeichnis/Ordner erstellen
rmdir remove directory Verzeichnis/Ordner löschen
open
substitute user do
Öffnet die angegebene Datei
sudo Führt den Befehl als Superuser (root) aus
pbcopy pasteboard copy Kopiert die Inhalte in die Zwischenablage
pbpaste pasteboard past Fügt die Inhalte aus der Zwischenablage
ein
Beendet den angegebenen Prozesskill
killall Beendet alle Prozesse, die den
angegebenen Befehl ausführen
Zugriffsrechte von Dateien und Ordnerchmod change mode
ändern
Verpackt Dateien und Verzeichnissezip
unzip Entpackt Dateien und Verzeichnisse
clear Leert das aktuelle Terminal-Fenster
screencapture Erstellt ein Screenshot des aktuellen
Bildschirms
Suche nach Dateifind
mdfind Spotlight-Suche
ps Listet alle aktuell aktiven Prozesse auf
top Listet eine detaillierte Prozessliste auf
history Listet die zuletzt benutzten Befehle auf
reboot Das System neustarten
shutdown Das System herunterfahren
Windows: Wichtigste Terminalbefehle:
Befehl Was macht das
dir Listet den Inhalt des aktuell ausgewählten
Verzeichnisses auf
Zeigt den Inhalt seitenweise andir /p
dir /w Lässt die ausführlichen Informationen weg
dir /s Listet zusätzlich die Unterverzeichnisse mit auf
cd Wechselt das Verzeichnis
cd.. Wechselt ins übergeordnete Verzeichnis
cd\ Wechselt ins Root-Verzeichnis
md Verzeichnisname Legt ein neues Verzeichnis an (auch mkdir
Verzeichnis)
Löscht die angegebene Dateidel Datei
del Datei /s Löscht zusätzlich zur angegebenen Datei auch alle
Unterordner
Löscht das angegebene Verzeichnis (muss leerrd Verzeichnis
sein)
Löscht das Verzeichnis (muss nicht leer sein)re Verzeichnis /s
copy Quelle Ziel Kopiert von Quelle nach Ziel und legt eine neue
Datei an
Verschiebt von Quelle nach Zielmove Quelle Ziel
rename NameAlt NmeNeu Benennt eine Datei um
attrib Ändert die Windows-Dateiattribute
attrib +R Schaltet Schreibschutz an
attrib -R Schaltet Schreibschutz aus
attrib s Datei ist eine Systemdatei
attrib +H Datei ist versteckt
attrib -H Datei ist sichtbar
attrib A Datei ist geändert/ archiviert
type Zeigt den Inhalt einer Textdatei an
Wichtigste Linux Befehle
VERZEICHNISSE, DATEIN:
cd Wechselt in ein beliebiges Verzeichnis cd /media/disk
cd .. Wechselt ein Verzeichnis zurück (/media/disk -> /
media)
Wechselt in das tiefste Verzeichnis cd /cd /
cd – Wechselt in das zuletzt besuchte Verzeichnis cd –
cp /tmp/test.txt /cp Kopiert eine Datei in angegebenes Verzeichnis
media/disk
Verschiebt eine Datei und löscht die Quelldatei mv /tmp/bla.txt /mv
media/disk
Benennt auch Dateien um mv /tmp/x1.txt /tmp/x3.txtmv
rm Löscht eine Datei rm /tmp/bla.txt
rm -rf Löscht alles in dem Verzeichnis rm -rf /tmp/
mkdir Erstellt ein Verzeichnis mkdir /media/disk/bla
rmdir Löscht ein Verzeichnis rmdir /media/disk/bla
ls Zeigt alle Dateien in einem Ordner an ls /home/ubuntu
ls -l Zeigt eine ausführliche Liste, mit ausführlichen Rechten an ls -l /
home/ubuntu
ls -la /home/ubuntuls -la Zeigt auch versteckte Dateien an
pwd Zeigt den Pfad zum aktuellen Verzeichnis pwd
cat Zeigt Inhalt einer Textdatei an cat /home/test.txt
more Zeigt Inhalt einer Datei seitenweise an more test.txt
touch /ubuntu/touch Erstellt eine leere Datei in einem beliebigen Ordner
123.txt
SYSTEM:
top Gibt eine Übersicht über alle laufenden Prozesse und
Systemauslastung
free Zeigt an wie stark der RAM ausgenutzt wird
uptime Dieser Befehl zeigt an wie lange das System schon online ist
uname Zeigt mit der Option -a einige Systeminformationen an z.B. die
Kernelversion uname -a
shutdown -h now Fährt den Computer runter
whoamiwhoami Zeigt den eingeloggten Benutzer ein
