Instructions

User Manual:

Open the PDF directly: View PDF PDF.
Page Count: 124 [warning: Documents this large are best viewed by clicking the View PDF Link!]



 !"##
"$ % $&'%% $()
*+"$ $,# 
RainbowWarrior
$
- +$-
$.( +/
0


 !"##
"$ % $&'%% $()
*+"$ $,# 
Inhaltsverzeichnis
0 1$
00- 
0..( +/2
0$)$ 3
00 43
0.#$ #()5
06 $75
081)& 5
02+9
08/$:& 00
080#'00
08.600
08;<) ,0=
088;.+$$>+(09
. ;>#-+.0
.0-$ .0
.00-$ ..
.0.+? -$ ..
..> $ .8
..0:.2
.1 $+.3
.01 .3
..+.3
.8;#@
.80/ @
.2 @
.20: 0
.2.,  
.=6+$#$8
.=0#6+8
.=.1 +2
.=>6+2
.3:$=
.30:$+ 5
.5 +8@
.508@
.5.+$$88
.5#$A  88
.9$82
.0@# .A$83
.


 !"##
"$ % $&'%% $()
*+"$ $,# 
.00*B-C2@
.000D 2@
.00./ E20
.0.# A& ( 2.
$$#$28
0$28
00#$2=
./#&$E1)&$23
=0
8> $  1 =.
2-$ =8
20 + $(F==
=" >$=5
=0&=9
8;$$#,(38
80,>#<$38
800&-$ 38
80.,(-$ 35
8."->5@
8,(5=
80$" ,(-$ 5=
8.-((++$(55
8#9@
88D&' $:$)$9@
2&, ,$)9.
20)+9.
200,-$ &$ B$ ,-$ C9.
20.)+(98
20>-$ 98
208  -$ 92
202D':$$-$ 9=
202,-+ 93
2.+&-,0@.
2.01$$,(0@
2..1$0@2
2)$,)0@=
20:$0@3
2.:$)0@9
28)$$, 00
28.-$ 003
22# ++0.@


 !"##
"$ % $&'%% $()
*+"$ $,# 
8


 !"##
"$ % $&'%% $()
*+"$ $,# 
1. - Vorbereitungen
00- 

.( +/
>+*=50.%/,!03@ B/ C
/
$+&

<)1( (-4 !>$
 ? ))$)!*+ G ? H"$
(I &1  
&!&J6K!& ? + $& +
 -)$*+ G+$G
 ? + 03@?03@?0@B/ C
" ) !+)$ "2@?3@?09@
- + $B$)4+("!
4<' 'C
)+B+(C

,!0LB$;&);; C
>):B&)!! C
 !
>4 !>4)!>4$ )
" )'!*'-4 !" ))$(
/ /2!$2
 ++B4$C
"J + 
M !>$!>$" ))$( 
+$ $(N/* 
2


 !"##
"$ % $&'%% $()
*+"$ $,# 
# $)$ >$?-&
4 !&($!$4,&$
-6)$ :1 ' %!
K $))$:  $
=


 !"##
"$ % $&'%% $()
*+"$ $,# 
0..( +/
/.( +/ $- !$
 +$-+$
<.8@-")$ ).2.@*/#-
$B#-O#- #+!
,$)&+ (&&
+$*B*!0*/O0@.8/C$8-/7+BO
76-!+!( ! 
C
D$1 A"$B &$( +C
$ ).2%")!&' 
0@@-   .
#$J()&!(
%/#+!+( ( 
  !.8@-")$ 
.8@!@@@!@@@++$$&N
 - $$- !
  G G#$1 )$ 4
< $$(+8
%6B% $++$E6$+$C! 8
B - C! 
$+&B* +# $C)$/+ ,
:$+$$ !, 
-&$: >+
#$JA$+ &!
$/$!" !&$
 #$J+$
D$') /$:$($+,>#< 
+,>#<B"C<)&(!
 1$+/ $ 
#$. '$-/6B 
6+C"$$)$/+ -4 
)$#$)$ 
)4 ( ' .
3


 !"##
"$ % $&'%% $()
*+"$ $,# 
)$/+ ,"$)$>$$!
>$$$+$$+ 
 -$+,>#</ $
-$/$! 
&$$)!$&$)$ 
6&>+$$
#+,( !,)$
$$# D$') $
(&!$#)$-)+
$)!$4! )- )$+ $&!
$" >N$)$+
.$(#!)&
(:&+A
A#$+
 +$&& $ '$P+)&
 '$P:&#$$QQE-!
 $& $$$#$(
 +$ $$BO
( +(C!#$$)!$
.+
"#A-+1(C)
$$!(#'   $&
# $!1 ($!&
+ ?
$%&A( +:&$QQ$
P) :&!(" & &$
& $ $N+ $#$$
%$
5
0$)$
- -4 !/ :
+ $" !$$+&
!<)&"&/ $/$)(& 
)&+ $!$'1 )$
6+!$P67')$1$4
#$ $$ &-#&$ 
$+*) +)$1$!& 
:$!P<$)7')$

1.3.1 - Terminal önen
N>$?A$+&$G'G# (
%'()*+'*'+$ 4&
,&A,&!GG!'
-6A->$+ )$4!G'G
( / )$+' $>$?1 
/ $$-6)$P$$,&(
 & 
$)#$7$&/ +/P
$I
#$/ 
 $+
+$ '$
D 
<$)! (
+$B$
RC# J&
6)!
$ P"
$$STH!& 
$!
"1)P
# &D 
S,H!)$
 ! NB& #$+$C
  !)$$)!$<$)
&&$&/ $&
1.3.2 - Aktuelles Arbeitsverzeichnis
pwd BO+&C
: K !6P!
pwd!&&$ S$ 
#()$H
1.3.3 - Ordnerinhalt au$isten
ls BO C
-/ ls 6$<$ls!6+!
 $ #()!&'
$ ls /home/$USER/Bilder
$'()#())$/+  6
G/ G1)$ /$)BOUNC$
1.3.4 - Verzeichnis wechseln
cd BOC
NN())$& !$/ ! 
$<N()>))&
(I
$ cd Bilder
&  NG/ G!$ 
#()P$
++$ A-$/$
1)-* $#/ 
#$(( '$;
1)D #!P
 
-4)1)& !!
 (+ 1)+- $ /(
!$)$ !$N() 
$ cd /tmp
& $+'1)G+G!
1)BN?VW$( )$,&XGAYG>$&
N&Z1))$& !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 /+ AG GC
+ )$D BEEUNE : 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
 41( $>$
6$!&&$
./I
& &/ !&  
)$P,/ &  $ 
 '
08/$:& 
1.4.1 - Abhängigkeiten
/( /$-+:&
 ( B&C&!
$B-C)$4$>!
1$)$$)$$$)/)$
#$J&:&$ 
N>$?&)$ 4$ / 
<KD $'&#$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 / 4B%&'I: &  
% CA
$ sudo easy_install pip rsync
$ sudo pip install pyserial
1.4.2 - freeRTOS
:6B 6+C& 
)!)$- $
- $$&$$(- +
<$&* [
* !$/&<!*!
")K/"&)$
 !$JD$$"&
$!* $!&& )) !
& +$)!&"&)
$)$&
: )$') >!)$') A
https://de.wikipedia.org/wiki/FreeRTOS
https://www.searchdatacenter.de/denition/Kern
el
1.4.2.1 - USB Port ermitteln
/($:&&!&)$
&!$& N/+&N/%'&
(+) +!(+
&
N>$?!& $$-6!.
GN/@GGN/0G
  !$$+A
$ ls /dev/ttyUSB*
$!+ $  %'B+
6E(C!GN/G\ !
D D 4
: /  #$  !$
0"$) &$$>$?$
-6/
dmesg 12-#3
N#
* )$
!
/  
$(
"&
&$!
$ ! 
&$
/) - $) 
)$ )N/%'
D$/+ 1BO" C
$$!(&B$A.0@.N/N#/
 C
:$   )D "G-4567
#8%96G!&$!$%'!' 
+.0@? '$!#8%96 &$
:,&  VW$( )$
"&B$$'C
$GN/ GG# B6-]>CG%'
!$& %')$N,&N/
%'G6-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 AZ
 & )$($ 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&-$ !$&$ JC
(
Hier navigiert man ausschließlich mit den Cursor-Tasten.
6EN$(-+$$)$&' !
Rechts/Links um in der Menüleiste unten zwischen "select" (=Menüpunkt auswählen
/ ändert),
GGBO)$)$-+$  
C!
G-GB)$1&$)$,1  C!G7G
B$ *P$B$<C+CGGBO
+*P$ C$)$&' 
&$)$!  (( 
/ )$(& !$&V$& 
&
, SH$-+$G-G$$
&! N(-
,$&)$ "4& 4!(
  !GG&$'

,V$$PA
USB Port prüfen:
%;:-
" +&!)$( N/BN/@C $ 
 +)
Webserver-Funktion aktivieren:
"-#%#%$  7
-$$-+$(!$S#HSH!$
,()$((-$ &G\G)SH
SH(-$ !( (&$
$&
Telnet- und FTP-Server-Funktion mit "n" deaktivieren, falls diese aktiviert sind:
"-#%#%$ '7
"-#%#%$ -7
#$J&!&( +$)
4A
"#%#"#-1093
" * (G-"+)G,9=: 
: !'&$,)$+
,(-$ 4-$ < =!
(& A
"-#" 
# A-$ !S?H&!
'! $$$-$ )$ $
'" S H#$&' ! 
(&
D$ )$-  )$>7G& $
'#!$& 
P+& !$$'
# J?&' $$P)$
: &#$$ N
!SPH$ +B&
& 1)C)$K$%$ &>
)$+ *+ G+$G: P
(+$)&!$$P)$GG
 &!($P&+$&
)^I
$ .BUILD.sh clean
$ ./BUILD.sh
_&_ I
<$!&+[
/: $/'!/$ ) 
&/$ )1&& $!
#&$!$/'BC$`$ )$&
)$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)$
/+ 6X-F.F+#-F>/<$E
-F/N>E+E+E+.X$
?@?@-$ !+$
)$4": 
$-J )!
 $$!G(G
' $-!$: (/!
& /  $+'
-$ !&# +
)$/+ B+!-+<'C
/ $(' #)$!-!
 
+  &'*+ ($)
$-+$
 '(+$$
<  /+ !&)$!&
1 GG,)$&&)&,!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)
382:02 (,6a+8b!. O.c )1 !
$
/
&!
$,.
5/82:5 (?!,6 OQc )
a+5b #d$,
5/22: (?!,6
(1 
)
a+8b d$,
@0@ ?!?
(1 
#,
(d)$
5982:8 (,6a+
,(#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!$)$+$
)$ JI
# $$1+$!N/* $+$I
,&'&KN/%'(+) +!
(+&
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
# !21BC!B
 C$%$!%<B&)
&JC
 J$&)B&JC
* ?W$ B $&
>!$$21#$$%<(
$)# Z+$
N/)$(
$J%)C,A$)$
 J$%<?W$ 
%<($# J
($>+B<C08
 & +N/* +$
($
1.4.4.3 - Eine Verbindung zum ESP herstellen - rshell und REPL
"(&& GGBO C!$4 !
1$)$ )$ $$6)$ !
$)$ !)$()$ 4!>)$
 4#!&)$/+ $4JB$)O@C
$B+E(EN/@C!&( BE(EN/@C
)$
/& %Q
-BO;( ;+ +C&$)$!$+*) / 
$/$)$! :$)$ $!
(+$)$
$ rshell --buffer-size=30 -p /dev/ttyUSB0 -a -e nano
$ repl
#('
 $D I
>&
D '
DG>>>G 
&J!

 ! P!  / 
&/&>%Qd
2. – LED Animationen mit Micropython
-&&'&G+G1(
B1C$/$!$
)!$ &( $/$
#$$!1&$) -$ $:$&'
$!& 4$(&&! 
$ E# $ A
8*!&NG&G
+) K%A
http://python4kids.net
http://python4kids.net/how2think/index.htm
#$$$+$$P4
$$+ %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-+$)$$)$44
-$ GG  GG$-$ !
&-$ !)$&G* G 
https://www.python-kurs.eu/klassen.php
https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/machin
e
-$ )$/+ )&
-")$  1@A1B-"CD33 
$B@13C
#$J $&-$ !)&* G<+? G!
&+P$$$! )$>$4
2.1.2 - Das neopixel-Modul
/(&+ $ 4!& )$-$ 
$P!&>+
 # J$6K(G<+? G)$&
:KG)* 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 DFB-G-D3P!&
a+F$b!& +B+$C
B$+$C&
@@H8')$/+ ! ( $
B>+C&
%$ / >$'K& 
A
>>> import machine
>>> led_pin = machine.Pin(14, machine.Pin.OUT)
N6KG<+? G)$ !#
&$&!+ !
&#) ? $+B: 08? C#$
(&>+ &!$$+(+
G*=50.G,$ ' +eF%/! 
>K& :A! $*=50.
G%/,G>!+? $(:<%/$&J!
>$) )$)$A
machine.Neopixel(pin, num_pixels[, type])
&K )1 
GE-G+
!$BA08C1 
BE-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-FBFFF-D3)$'!? 
$)$ #$)&#)& ! 
B* C+ 
-)?? !:&)& 
&<!& :?  $
 "&(P:(&B&
 /+ C!:& "?) &B&+'
 'C
B+ C%/,+!& :,J
?  $ ,!& &@
)",(@.224 4!&J&
:
fB+ CP!&( ? )&
 !$(? !+&$&
0! &'J$? $!$
&$
f-B+ C!? K& 
:)& !)& B&$&C!
#)&& : && !
$+O: )$
N ? (): $)$ !
)$') / +&BC4
>>> 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$) :&PA
9+J0FC&'$F($F+&"$F9+8$FK$++HFJKIF")$I'F%&+/$(F)(KF
"(HHIFH+&/$F)($$IF8(+$F'$+FI/K@
# (-4 !:"?) &
)$
%/:&P$,BOC!BOC$
 $BOC,)&@$.22 ::
$ O.22!+4,!O@!$O@)&#
AB.22!@!@C%/, $+  
"?) &&'Gg::@@@@G!)&@?::@@@@!&DGgG
G@?G$( &!$)$)!$
"?) & Gg::@@@@GXgX  D!
D !@?@@@@B?) CD &$
D  '!(&& $@?@@@@
, &) ) G.22G"?) )  &G::G
"?) &:& &! K& :&
!$!) ("?) ) $ J

:GW$G)$/+ %/,B0.3!.22!.0.C*(
&) ,"?) & &@?3:::8B 0.3O
@?3:!.22O@?::!.0.O@?8*(&&$+ 
"?) &) & &5552=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 &
$)!$('6K)$+6K4)$/+ )
D &&DBC6$,
X$XX: X
2.3.1 - Variablen in Python
,'++1 ?+ )P&$
$$&'>$)('&!
D$&$D$/+ 1 O0@$
D ! )D ,+'O.!
(+7! % ) 
-$) D &DBC1 
+
--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.989=3.92!
& +( $(,BC(i.08385=85
.08385=83
 )% &%4J1 B.
=8/C,/0!2j0@ki82!8j0@k5B7!./C
/2!@j0@ki.80!3j0@k@5B$ !=8/C
J!BODC)) D!& 
/$ $D !&) &
  %)) -  !
 $!$!&$$&
$#  !)$/+ ,+A
https://upload.wikimedia.org/wikipedia/commons/2/26/Ascii-
codes-table.png
,K/$! J!KD $
K)$$)$4$,#
>!?(  $)$$
& 1  $ I
2.3.2.2 - Sequentielle Datentypen in Python
W$ +)+!: 
 (  
%)D! #$(D
W$)() D-?) 
D?+&$4 !
),1(/$
/$W$))$$!)$ 
) /$BW$)C$)$-
& : +(+( 
+ #+ +)!$& 
 &$&)$
* ab- ?$)  >
)$$$('
'-!$$+ >' - 
?$)  )$&$+ $* 
BC+$%))$>('
 )$') )$,$/)!
6K$$A+ FOlG/
,$GAG$G!G/GAG-$G!m
  W$ +)$"
  $6KG G!4$
*G-++G!& & $&
-)$)+$ 
>$A
https://www.python-kurs.eu/python3_variablen.php
https://www.python-kurs.eu/python3_sequentielle_datentypen.ph
p
https://www.python-kurs.eu/python3_listen.php
https://www.python-kurs.eu/python3_dictionaries.php
.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
$%$  AB@!2C,$8$2[
2>D  !&#) D # 
$B2CB)&B@!2CC!D !$2%)
D !@!n2 8!)$&
/$&$A &2?$:K(@n2
#&P &$J [
&$$P
+ !&2?$& !$$1 D 
  #/&
> $! D GB2CAG
++ +$$ $$!
)$&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))$( !& $
 -$ GG!)&:$
-E13
@-E14663!') 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& Bn2CX!  ,(  2!& 
$)$$$1   
 $04&!$
  I
>>> while (i < 5):
... i += 1
...
 $!+!/$!$
#$$&G& G&,! 
$!)&&!&#$$
 )
.=6+$#$
N#$$($*$
1 !*!6+$&(:$
#$&$#$$,!1 
)$&&&#$$1&$'$ 
<$ 6+
"&$$&6+
6+#$7$)6+!BC
$,B7C)$!&'>
1 +, +$  $: 
)$
2.6.1 - Arithmetische Operationen
Operator Aktion Beispiel
Q # 00OQ
$ 0O
\ -$ +  0.O\
E ( 2OE
EE $(E
%)) (
(
)) # 
(: K

6+: ,
!&)) 
# ( : 
$
hhh0@EE
hhh0@@EE
@
o -$ (
B$%)) C
0Oo
B2\0O2!=2O0C
O D$&$(,
2.6.2 - Vergleichsoperatoren
h %4J 
n *  
hO %4J  
nO *   
OO % 
IO < !$ 
  ( 0a0!.!b
2.6.3 - Logische Operatoren
# >N BC
6 >6
< ><
#$7$( ',6+$$ '$
P$ A
https://www.python-kurs.eu/operatoren.php
http://python4kids.net/how2think/kap02.htm
, &$!>)$(DE
(#$$&!
$: D$$
.3:$
$B#C!& !)$(D
(#$& !
:$)$
:$&  &GGBOPC #$$
 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)
EA,$0 :$
4 !&:$)&&
 !)&&#$&$ Seite 35
$ ( !4
&!$:$#&$$)$
/ ? $GG
&$)!$:$$-$ )$-)$
*+ 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)! /+ !:$!)&
,BC& !&&& 
(A
1. ,& :$!)&D &
<& GG.
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:$DBQ$C(')$4
& 
 &  #$!$&
&
/ :$&$,:$D
(&$$1 )!,#$$
:$!)&&
#$1  $)$!<)$&' !$
>)$&' $)&$,
-( ))$4!&$
::!1 G G)$:D!
> $ !GFG$:D!> $
 !GFG
>>> 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? +GBO
?) :&' C-4 !&: 
"?) &)$ 
*! 1$:$4: +
+&$'$>+)I
2.7.1 - Funktionen mit optionalen Parametern
 $ !:$+BC!: ! 
> ) & !#) )$ > 
G$OG&
" $+ !$$ 

+!&&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
 /!GKG!/K
  ) !&$
+  4& $
 $!:!)$
NK)$ !)&$)$&' ! 
-$GKG: $&' +&-$G#K
: G
: +6+)K(
 !+P ! 6)$ 
)$/+ "1)6GG
+B ) : C$KB6C
+ 
<&' ! K
K
-4 $ K$ !
!-$*?
K4$G&: G&' # (
K
:' 4!< $(
$B+C&$
/P ?"& 
4BKCB '+C)
#$J&$!$!+! !
&&> !
 1 A
$"($&?$#( $$
&)$/+    &4B+!!C  )# 
:$!*$!&,)
#$D )  &(1 !&)$
? B ++ C
<$ $+&$!&
& $)
#  !
+&K
 #()4
 XQXD $
1$4&( 1$)$ A
$ rshell --buffer-size=30 -p /dev/ttyUSB0 -a -e nano
(&>!+& +$A
$ cp animations.py /flash
# J&$")$/$BC
$ $
<$4&>-# &G+ G 
$'
N$:$ )$!$+)$+
>>> import animations
,$&)$!$$ ,&$
(-$ &$!&
) --$  &$I
)&$$:$!& 
  I
6+I X: $ X ,P
: [
#&  !&)$D )$I
/:  $$)$  )D 
 (
 )#: !$&$AS( ?H 
?: D !& $& 
D )$:  D 00
# &&/  +
@-E1E3D 00 $*?: 
)$PI:  $ D $

-@16FF2E-D 0@P(&I
* &$4!& I
+(!$ D D 00 
/ !&*  !
?: ND 00 : &$!
&$$D 00I
6(!  !$: ( ))$
4 / $D  $!
 )P"&/$ 
&1 $B($ C 
#)$:$E-$ !D$: 
$$&$
+K:$K-$ !D$) 
!&$ ( !&
+$   !&)$: 
$)!$)- (
+  $$!$ !$)$
$
 )A$ ((
&$ $
)($!$KBC&
$!E*4D&  
 ( INA(I&P( 
)$ : $++&I
# * ++ %Qd>
+$+$>&$
++G$ GA-/ $$D +I>$?
++>$?&$+  
+B$JC&D GLG
(!$+ +)$ !/ 
$)$ $ )$$)!
/ )$*+$$>)$$D $
XLX&A
$ cp animations.py; repl
#$& 4$D B/ C)$
!$ -$>-I
&& $!4&/$)$
A
>>> import machine; machine.reset()
<$ ++  $
ZA,$J/BOC&!$
($ -$ $
 '!GG>$ J#/
 -$ (!&#$(( '$
,GG
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&( $ JG;
 7+$.$)$ A
>>> ls /flash
$$$  : +$$
<$G+GP$$ A
G+G
!/1BC
$&"   !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#GB#)$C$!$>
+B1 -$ C)$6X X$
: + ?)$&
N$)$P!&$! !/ 
$-++ $)$&A
https://docs.micropython.org/en/latest/pyboard/library/sys.html
#@-A#$  +$ 
/$!('>61 +
&!-$ $&+ &K&
B?C-$ 4!-++ $
(!6S7E H+&!
&& $
<> @-#G$&$!&'J: 
G@-#G$: (!&$
<$!&@-#[
$!&)& I4
&-$ $$$&!&$/ :$
4&$ +!&& )<$
>!:$G G$/
)
 & $G+G!K
+&$)$ )>$D 
#4$ )4BD$
C!$+ -!&)&
)4)$ &$G+G! 
$)/:
!&(
:$$$+
D&)&$ #$  [:
&1 $K$!&&/ :$ 
4!& )$&+ 
&
1<$I"&GG 
<)$*7
  &4 1 )&
1  G$G
.0@# .A$
-4 !/&$#)$!!&)$
/+ $>)$ DK$$
( $<$&&[
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@?@@:::::!FO2@
'$# ()$" $) 
(0&!)$ D$&$$+
,& $ !&> 4 
:$)$W$ $I
"$$ G/G-+ $
&! '(+I
< &'@)$)' 1@9$
0@DN)&$0@D!&!$ D 0@
D )$ 
$! & ! P!
?@+&& ! 
P!?0+
#$+&$!>0 &+O@
+&!> ) +OB$F+? 0C
: I>& +O@ 
$+O0+&+O$F+? 0( )
> $!& ) )>&$F+? 
+
&+BC ?$') Q0I
%&#&G+G + !
$$:$$$)&I
animations.running_dots()
#$ ,$
.00*B-C
<$&$!&!&
)&G$ G& -4 &'!)$
 $ $D ! '$%!
 D& G(G$  4
&-4 *
Z &&*)$)$!&
  #&'& $
)!$) ((+X X)$

#$ #*  4&!
 $&+'&
XX
-$)&)&(#(*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 # !&gP!& (+
+$$$
# 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
/ 4D )$)$/$
/ #$): 
""" 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$FFFF+BF$FFFFC/$)

$$ &!
&: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&)
 +O0+
strip.set(i-1, color, white=100)
& >+!$  $
P
strip.set(i-2, color, white = 150)
&>+!)&PI
#A: O0&'.O0(?)$:  $
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.
NG: G-+ $&$)$!$
++&Q0B!+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)!& + !
)$/+ #<0D '$! J#<
.!$&
/&'!&& 4!&'
# 
0$
N.+&/!&)$/+ 
$B/$C
%$&0@$P
@!.!8!0!0.!08!02!.3!$.
/$ $*+)(
:$$$V$ : 
N$( B(DC(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!&* 
$B6.3C<)$$+,B  C!
 ! +$
$+)$
-++!$+!+ $ 
$& !& ,6
/$&,)&8@@$2@@!/$
)&@$02@,4 K
N$(' (
)& & &! GG  !$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.
./#&$E1)&$
$($#&$B
1)&$C !$$/$$&
>/$(!&$# (B
$C $&
#$A1)&$ !& ()&B$C
 B# (C#'(BC
/$$&
4)A
Wenn dies: mache das.
)$4PA
Wenn dies nicht: mache was anderes.
6&/$:4A
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&$% % ++# 
/$")$$)GIOGBO$ 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&$$!&/$BC
)$
$&$$!&&  $ )$
- ()&
$$$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 BCGG G!&)$#$$
:$!&&& 
# J &$!&$:$?BC 
 :$4&!!&:$$$
&$!>&: 1 
&$! K& '&
!+ )>4$&'!&)$/+ !
 BC#<@!$FBC#<0BC!&'D' 
$)' 


D!$ >B' C
)!$' & 
for i in range(3):
print(i)
4$ JA
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
,&/+ $:$)$PA
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()
E2E@EEEE13&!'
:$1 $F$+&
-E13&$
$?+/ $<$)
XX+!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&
ND)$+&+D!NB 
)C+$,  $) 
 D!N&
-$ (' ' !$)&
!+   $!(! 
(#$ &!+  )$
/ '$$!,
4&$)$
"$)-+-$ F
:$& 1 ( 'A
https://www.python-kurs.eu/threads.php
# 4&/+ &!-+  
#+1(
-$ /$)$F $(/+ PA
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$/+ B0!C
+ "&+ 
  & &
/+AlG0GA( $0!G.GA( $.m
:$#$$)$!1 
BAC+& 
&4!$#$$$)$)&
)$++
E@-1E3$E@1E3&#$$
$$ J&)
$ $!&$)$:$
N$E@-1'3 $&$
-4++!E@-1E3$)
$& $/$I
$(&!$!&
 !:$:2E@:13$& 
P ,!$FdBd 
1 *,<,
$)')$>C# ($
E@13$)+!:$ 
($ +FB$C)&!&'
$)/$ &4$$
&'#$4 
$  &$&) $ B  
 C&( &
3.5.1- Implementierung von _thread
,$#/(&$K
) +!/$ &$!+&)
:$
4)$$ !   
(:$& &$ $ B
$ +F) C# $:$ &!& 
$ 
& &+!/$( ,
/$Fd!& &)$!
#$$# $&$
4&A
def waitForExitNotification(timeout):
notification = _thread.wait(timeout)
if notification == _thread.EXIT:
return True
else:
return False
N:$#$)$$$$,)$
(4&$F +FB$C$ )A
exit = waitForExitNotification(timeout)
if exit:
return
&K) ($ +FK#!
   '$<(A,($I
)&$:$+!
/$$4<$&!
$++&
NK) #F )$!4&
!?BC& #$$
# (?BC
# )&+?BC$
animation_thread = _thread.start_new_thread("animation",
animations.next, () )
)&# !#$I
,&#>$$&)$
!&1 F
+( &$I
1   !&4 !)$/:$
-$ !&)$#4!
+'(B&: FC
# &&+$)$/
1 $)$,0@@)$&
F+BFC&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-BFD3!&$
'J0B#0C$&
E72@13 +$B1C! $
+ F( 
#$-$ $B#(C(!+$
,)&@$00@@1!&@ $ $
00@@  )$+
,4& 0A0$)!$" >)$
)!$,)&@$.22)+:#
!,$" &)$G++G
)-A
F( O F( E00@@\.22
,>$,(3@@!& 0=.!.3.3.3.3
$ A<+? $)
D !$I
 1 E73!$
% ) 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$+,B0pC
>(& 1#$!&
,($&$(&%<$
)$ JN,$)$ !&$
#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! <)&BCP
,& ,($)!$,$#
$)$&' 
N)$4 !$)$!
+("&
-$ )$'
80,>#<$
4.1.1 - Das network-Modul
&-$ -4 !,>#<1$
)$ $-4 !:(B)$/ $(
BCC! (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(PO<,>#<
<)&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 $GV &
 ()<$!$ $
$)$!$<+$!$
)$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$BC $
4.1.2 - Das microWebSrv-Modul
,( :$!,BC)$ 
 (' 4&$( :$$
(&#%$$ '&' 
,(-$  "->!& ( 
  : E7E&&&$- +
-$ $ $(/+ )$PA
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!)&$
&&  Eab!& 
& "/+ $" !D$
B)&#C$&&  ? B6&&&C
)$A
@MicroWebSrv.route('/')
def _httpHandler(httpClient, httpResponse) :
httpResponse.WriteResponseFile(filepath =
'www/index.html', contentType= "text/html",
headers = None)
$"  (,() &!
&  ('
,($$$
 # &
&$ (/+$$: 
 $ &!)&6XE7E&&&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? Cnh$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.
79
06e
<! DOCTYPE html>
/6e&/& !&/ 
&$&  $
 
."#
<head>
<title>Titel der Webseite</title>
<link rel="stylesheet"
href="style.css"> </head>
/"#-! + &
 !/&+)&&>)$
: 
B C#$,(& 
/6e
<body>
...
</body>
//6e  $"->#%
-)$ $($ 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(-
/#$$/&)$GW$GB#!/+A
4C!((G+GB#&!/+A
)C&&
)$'H%'
W$&$#- -
##$$ "+)P-(A
66<!%!"#!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&auml;hlen:</h3> <div class="input-group">
<select class="custom-select" id="inputGroupSelect04" name="light">
<option selected>Animation ausw&auml;hlen ...</option>
</select>
<div class="input-group-append">
<button class="btn btn-dark" type="submit" >ausw&auml;hlen</button>
</div>
</div>
</form>
</div>
</div>
</body>
</html>
)"->   $
6K$#"$)$'
:$   D &!+&)$
#$& # &A
<form class="form-group" method="POST" action="/" role="form">
<h3 class="mb-3" id="id1">LED Pattern ausw&auml;hlen:</h3>
<div class="input-group">
<select class="custom-select" id="inputGroupSelect04" name="light">
<option selected>Animation ausw&auml;hlen ...</option> <option
value="myValue">MyName</option>
</select>
<div class="input-group-append">
<button class="btn btn-dark" type="submit">ausw&auml;hlen</button> </
div>
</div>
</form>
"->: D&!N)$$
()$,($)$)$$GG
&!& -BAC&$GG!& 
$" (&& :4"->
<form>A
<form class="form-group" method="POST" action="/">
und endet mit dem schließenden Tag </form>:
</form>
$4P"&
Z + :$(&
  
<h3 class="mb-3" id="id1">LED Pattern ausw&auml;hlen:</h3>
G"G Z<,<$$
 &0 J%4J'
 
N()$!&/$(&A
<div class="input-group-append">
<button class="btn btn-dark" type="submit">
ausw&auml;hlen </button> </div>
, ,(&!&$6+$
7P& lA( $m(

<select class="custom-select" id="inputGroupSelect04" name="light">
<option selected>Animation ausw&auml;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>
72>E>,!#((&
(&&&$)!$#)$
"&!( $ !&
F+I &&
#4
(&( JMG-N  
?!+&-)&
G" +GOL&)$ $(N $4!
K/&N $:(X'X!X4X!XX "$)
OLB'C!OLB4C$OLBC
8,(
<$&&! $%-!
#:$ 6-)$)
4.3.1 - Route-Handler des microWebSrv Moduls
$&$)&$" -&(+
$" %$ (P D  A
@MicroWebSrv.route('/')
$" 6& D  A
@MicroWebSrv.route('/', 'POST')
KW$$&:$!&$ 
#&!&(( #&
&>4&& :$ &  
!
:%W$ $! #&)$A
@MicroWebSrv.route('/')
def _routeHandlerGet(httpClient, httpResponse):
httpResponse.WriteResponseFile(
filepath = 'www/index.html',
contentType= "text/html",
headers = None)
/6W$$()$') $
&
/ -$ $('$!&&:
4A
@MicroWebSrv.route('/', 'POST')
def _routeHandlerGet(httpClient, httpResponse):
formData = httpClient.ReadRequestPostedFormData()
httpResponse.WriteResponseFile(
filepath = 'www/index.html',
contentType= "text/html",
headers = None)
<$&++
,&'! '$,(&$
-#$$# $

,4K)&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
FBF!C< 
D !F&$
E@(-&-)$#$I+
F-$ (I
>PQ>@173(,( $$)
 ) lm++ +$G G&+'
1$+&I&!&
(++ +$>)PI
4.3.2 - Thread-Messages vom Server in main.py empfangen und
verarbeiten
N-$+-+)$4!&
+)$?+ )E@(--"1'3 $I
2E@13+&(+
<' $+ BF+!F!
C!&E#-@BO<C!0BOC.BOC
EB&$(
C
<!&(($! 
G AaG Gb
N,(aG Gb)$!& a.b
 GAG+ 
72B4D@-1>>3 $!( $$BG G!
aG Gb
 &(&,aG Gb#
+!&,& #$
1A( )$$%&(!(
++ +$>) 
( $a@b+BC>)!)$/
(
1$+ ?!& 
$/$&:$',
)$/+ PA
https://docs.python.org/2/library/string.html
#$ &($#+!
# '$#$J)&&!(
$,(DB.@@@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
<$&&BC&:$
$!(# & &
+$ $:$?BC:$
BFC
:$ #&! 
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 #$,
$&' &$CB $$& &$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$ 
20)+
)+$ >$+!)+
$  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
onCZ)$(
  B
K&$)&
GG$G$G!)&0$@
$C
 $& &
$
,1&    
& (G, G+!G, G&&
#$/ $& !$  
')4 !$&  ! GZ)G
?#)&+$)&$& 
$') (!&   $GG$
5.1.1.1 - Das PWM-Modul
https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/pwm
-2@"1-BFA2DBF#2DBF2D3
erstellt eine Instanz des PWM, wobei
-<$! & 
! ,&
AB+ C):W$)")!$)
& B& !))$ !&
$&+  C$ A2")
#B+ C#) $o$ A2@o
B+ C!D(& B$ A@C
-@A1BAD3):W$)")#$&$$ *' !
 $),#$&:$
:W$))$!$* + &
-@13 +&!#$$&++
-@1BA2DBF#2DBF2D3 +&
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 I0BAX6-XC
. %7 BO0=!O2!O0.2C!&GOG '
G8G$!K<>'1 G5G
&# $$&GOG((
6(>:GOG#+ &
 '+-$
 ' $*($ A
B+ C'
I B!!!!!!+O$C$
4$" 
B+ CH7
>-$ -$ &!&&
 G +G$&A
https://github.com/dhylands/upy-rtttl
 K!&$  \+: 
!+&
,&/ !+
&-$ $6G G# &6
G G $ ++
mkdir /flash/lib
cp rtttl.py /flash/lib
,/+ PA
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
#$J4&G+ +G-$()
$!( :$$&$&
($& ('  $-4 )$
1$!&$ )$&I
-$ $)$PA
https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/rtc
&:$!$ ,)$$)!A
2@('J13 )
@13 '$) !&$+
&&AB!!a!$a!$a!bbbC
@13$$ D $+ )$AB!!!$!
$!C
ND)$ ($P!
-($
@-E#17BF-E-DBFD3& (G+ +G
$)&
5.1.5 - Zeitabhängige Funktionen - das utime-Modul
$-$  :$)$1$!$ 
D$#$JD( $ $
https://docs.micropython.org/en/latest/pyboard/library/utime.html
@1BD3(D!$BC
$+ $5 B!!!$!$!!&!
C,#$&!&$ )
$)
o $B)/.@08C
oB00.C
oB00C
o$B@.C
o$B@29C
oB@29C
o&B@=-C
oB0==C
@1E-3% )$  
( '$+ $5 B!!!$!$!
!&!C#) $)&
@0@0093@$!$+ &$!)$
@-EB C #D
- $$
@-E13 #D
-$$
@E13D - $)$
)+$ &  ):$&)$
/+ )!$ )$ 
@E1F3#$!&
(E1FEE--$ $)$
PC &$ +((
C
@E15F43D))&)&
,)$
< #)&$(, $
&!)$
o@13#) $)$!)&
@0@0093@$ )(

5.1.5 - Songs mit dem PWM abspielen
N)$+$)$+ ! &$
+
,+ -$ !&&  
$,-$$)&4&$   
* >
#$J&F-$ +!$#+ 
 $&#$J4& +)F+B..C
P$,-$) !$&)$ 
$%$!$,-)$(:$
$('&4D$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
E2@-1>>3B6D +  ! 
++ +$($ !& 
++ +$(a@b <!a0b
($a.b
AF@13 $$!( :$
$BC)&6K)$&AW:W$)$
$
 )&,+  (
F+ &<!1 ! &!
,& &+ F
+
-#E1AF3$(:$PFBC+ )&"&
K) < ,-)$# ($ +FBC
4& )$+&:?<PBC)!
$  &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 +
65 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 ( &
, /$B22E@$R&'C)$!&$: 
$
2.+&-,
N$,$&' )$4(& &
>#
N$#)$+!4&/ 
+$$ +/&
N&#)&-)$! MG N
&D $+$"
&!&+)+ 
S &$ (' +A
S%OLH+I
 '$+&A
OGG
<$&$+&-
" &&$>#$!$7
<!6<%>+)$P+$
$4#<!$)& !
&' 
"$$? A
</br>
</br>
<h3 class="mb-3" id="id1">Song
ausw&auml;hlen:</h3> <div class="input-
group">
<select class="custom-select" id="inputGroupSelect04"
name="sound"> <option selected>Song
ausw&auml;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
&(+ $$GG+&!$
GG
6()$$ 'N$
-I
)$D A
if "light" in formData:
)&$A
if formData:
$!-$&!&+
&$
- &$!,
 &!I
BC
(& I$B#$$C
( BC&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+...'}
6I
$!$$'(!& /$(
&$!,&I
 & ! :PI
-$&+:K- &
(/$$( $!&$ /$
,#&!&&
(&
:/$)& 2> >4&+'
,+! G$G
# 7)&GG#$GG
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&+!
/$( $GG&$4&
andleAnimationThread,!GGA
# 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"])
6Funktion 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 AB!!!$!$!
!&!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
, &$&!$& +GG !&A
>>> type(age)
<class 'str'>
,$!$ 
N/$$)$4!'$& 
,BC ',
(A
>>>age=int(input("Alter?"))
>Alter? 22
>type(age)
<class 'int'>
5.3.1.1 - Arbeiten mit mehreren Platzhaltern
<&!&%&# (0.!08$05B# 
+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)
 $)& $$-$ $
& JA
>print("Uhrzeit: {0:02d}:{1:02d}
Uhr".format(time[0], time[1])) Uhrzeit: 09:06 Uhr
,@.$!#$)& $!
 , @( &$!
,$) )  "B@A0AC)&
)$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.@0502A@2N
N$+ $
B@C!B0C!B.C!$BC!$B8C!B2C!
&B=C!B3C
D$Z4&$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]}
<$&? + ) &!
&$GG<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-CC 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&4A
htmlSite.format(**datetime_dict)
++ 1??3(F!F
:XXO( $!XXO( $!$& &
<$&+++# !&#$$
BO#C ((()$&
/&$-(-@(-1-2>G@>3
GG@G)$
&$'!&!"->
 #&& 
"$):$(-H$X+OX^
2%TA
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.
28)$$, 
N) )$4!$&,!
D$$&!+$!
,$ 
# &$&"->,+ )&$
#)" )&? B$$
N)C&/$#$+% 
' &+&-$)$4/$
+ )& GG)$
<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>+ )& &!
/&  $,$
$$#&  &4GG$
G7G
<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> #$
  &GG$G7H,($&
,$$$#&&)$+!& /$
&&&G G! 7)
&GG
<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 UGG+,)$!  &
elif values_dict["button"] == "datetime":
#Systemzeit initialisieren
&)$ $4=,A!!a!$a!$a!
bbb
,( $F)&$BC$N)
BAC
( $+&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)
E213@-1>@>3A 
K !GG($(K 
,
%)$!&
1E3>(
2-1E@7133)&A
E@713  >$B(!
!!!C$& >$+ B(
 $$+ &C
2-113@-1>>33A 
K !GAG($(K
 ,$+ BC(,$+ 
@1*3$)&AQ&!
$+ $'&!
 
:$&   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$056
(&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.
%@:113BF26F2D3$$
D!BC&$
$+ $)!)&
)$$$&$
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&+!D  )&
 ' B 05.@05C$: !  )&D
(!.@@@)$
-134&#) 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&$)!$(Dq)$
!++!+$$&&
$R'9%$A/( '"$@
(&&
2@'1E3 )F<$
(&
"&&@)
B+!! !+C 
-A DB$ A0@C
AP-$B$ A6C
 A :$!$& !&D
 $B$ A<C
 -A$,P!&,!
 & B&$$$C
5.4.2.1 - Das Timer-Modul als Wecker einsetzen
N-$  ,))$4&
B4 $, &
+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:$# BC!&)$D
$+ (A
def setAlarmTime(time):
time = convertDateOrTimeToTuple(time)
# J$&))$$+ $- $!
&- $)$D+$# 4A
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:])
EE-B6SD)&BWD$&
/a@AbBaAb&  (@n)$!a2Ab
  2BC
N-F)$!&$EE(EE
)
<&!&& K)B09@NC,$3@N
 !&(  A&$BC 
,$$$-$$$)!&'
D+$1$ FF&'  
EE$-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+ 
22# ++
<$4&$$!$4 !# &)$
++
D$# 4&$)I
# &&' !$$)$+
#$!&$#  '$I
&$1 F F$&)$/
$: )
,#  &$!$)$# 
#$B$&)$, C,#
 &$!$&$: )!$&
)$!)&#)$& 
D$/: +)&$ A
is_alarm_running = False
&$$)!  $
 FF 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)$")$<&I1 )$
  : #$# $
%! )$0@@o $&
ND $&$!)$:  $
! $$$ 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

Navigation menu