File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change
1
+ import time
2
+ import digitalio
3
+ import storage
4
+ import board
5
+
6
+ # Either of these should work for the PyPortal
7
+ switch = digitalio .DigitalInOut (board .D4 ) # upper port
8
+ #switch = digitalio.DigitalInOut(board.D3) # lower port
9
+
10
+ switch .direction = digitalio .Direction .INPUT
11
+ switch .pull = digitalio .Pull .UP
12
+
13
+ # If the switch pin is connected to ground CircuitPython can write to the drive
14
+ # Use a female/female jumper wire to connect the outer pins in the D4 connecter
15
+
16
+ storage .remount ("/" , disable_concurrent_write_protection = not switch .value )
17
+ if switch .value :
18
+ print ("File system is read-only, insert jumper in data port between" )
19
+ print ("pins 1 and 3 to make it writeable." )
20
+ else :
21
+ print ("File system is writable, remove jumper in data port to make" )
22
+ print ("it read-only and available to CircuitPython." )
23
+
24
+ time .sleep (5 )
You can’t perform that action at this time.
0 commit comments