Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
robogroup
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
matteo perini
robogroup
Commits
8198f4ad
Commit
8198f4ad
authored
Jan 03, 2025
by
“matteo.perini@trentinosviluppo.it”
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Creato lo scheletro dell'app e documentazione
parent
ccaf8a0e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
87 additions
and
3 deletions
+87
-3
README.md
README.md
+32
-0
applicazione.py
applicazione.py
+39
-0
image.png
image.png
+0
-0
my_lib.py
my_lib.py
+16
-3
No files found.
README.md
View file @
8198f4ad
# robogroup
SDA connects to Pin 24.
SCK connects to Pin 23.
MOSI connects to Pin 19.
MISO connects to Pin 21.
GND connects to Pin 6.
RST connects to Pin 22.
3.3v connects to Pin 1.
Tutorial from here:
https://pimylifeup.com/raspberry-pi-rfid-rc522/

```
sudo apt install python3-dev python3-pip python3-venv
```
Poi nell'ambiente virtuale del progetto:
```
python3 -m pip install spidev
python3 -m pip install mfrc522
```
Il db è già compreso in python come anche la libreria os e time
Per colorare le scritte servirà installare termcolor
```
python3 -m pip install termcolor
```
applicazione.py
0 → 100644
View file @
8198f4ad
import
time
import
os
from
termcolor
import
colored
os
.
system
(
'cls'
if
os
.
name
==
'nt'
else
'clear'
)
def
mostra_menu
():
os
.
system
(
'cls'
if
os
.
name
==
'nt'
else
'clear'
)
#print(chr(27) + "[2J") # questa riga serve per cancellare il terminale
#Qui sotto creiamo il menù
print
(
colored
(
"
\n
Seleziona l'operazione da effettuare selezionando il numero del menù:
\n
"
,
"green"
,
attrs
=
[
"bold"
]))
print
(
colored
(
" [1] Registrazione nuovo cliente"
,
"cyan"
,
attrs
=
[
"bold"
]))
print
(
colored
(
" [2] Acquisto prodotto"
,
"cyan"
,
attrs
=
[
"bold"
]))
print
(
colored
(
" [3] Restituzione prodotto"
,
"cyan"
,
attrs
=
[
"bold"
]))
print
(
colored
(
" [4] Ricerca numero cliente per nome"
,
"cyan"
,
attrs
=
[
"bold"
]))
print
(
colored
(
" [5] Ricerca proprietario di un prodotto"
,
"cyan"
,
attrs
=
[
"bold"
]))
print
(
colored
(
"
\n
[0] Esci"
,
"magenta"
,
attrs
=
[
"bold"
]))
n
=
input
(
""
)
#leggiamo il tasto inserito dall'utente
if
n
.
isnumeric
()
:
#se è stato inserito un numero entriamo nella funzione che lo controlla
if
int
(
n
)
in
[
1
,
2
,
3
,
4
,
5
,
0
]:
#il numero è tra le possibilità ipotizzate?
if
int
(
n
)
==
0
:
#se è stato schiacciato lo 0 scrivo arrivederci e esco
print
(
"Arrivederci!"
)
return
0
#serve per uscire dalla funzione
else
:
print
(
"ok"
)
time
.
sleep
(
2
)
mostra_menu
()
else
:
print
(
"Numero selezionato non valido. Riprova!"
)
#se il numero non è tra quelli previsti
time
.
sleep
(
3
)
#aspetto tre secondi
mostra_menu
()
#faccio ripartire la funzione del menù
else
:
print
(
"Scelta non corretta. Deve essere un numero. Riprova!"
)
#se l'immissione non è un numero
time
.
sleep
(
3
)
#aspetto tre secondi
mostra_menu
()
#faccio ripartire la funzione del menù
if
__name__
==
"__main__"
:
#se sto chiamando il programma principale
mostra_menu
()
# avvia la funzione per mostrare il menù
\ No newline at end of file
image.png
0 → 100644
View file @
8198f4ad
249 KB
my_lib.py
View file @
8198f4ad
...
...
@@ -2,17 +2,30 @@ import RPi.GPIO as GPIO
from
mfrc522
import
SimpleMFRC522
import
sqlite3
def
leggi_c
odice_rfid
():
def
leggi_c
liente
():
reader
=
SimpleMFRC522
()
try
:
print
(
"Ciao, avvicina il tag
RFID
al ricevitore!"
)
print
(
"Ciao, avvicina il tag
del cliente
al ricevitore!"
)
id
,
text
=
reader
.
read
()
#print(id)
#print(text)
return
int
(
id
)
except
:
print
(
"C'è stato un errore di lettura. Ripetere l'operazione!"
)
pass
finally
:
GPIO
.
cleanup
()
return
int
(
id
)
def
leggi_prodotto
():
reader
=
SimpleMFRC522
()
try
:
print
(
"Ciao, avvicina il tag del prodotto al ricevitore!"
)
id
,
text
=
reader
.
read
()
#print(id)
#print(text)
except
:
print
(
"C'è stato un errore di lettura. Ripetere l'operazione!"
)
pass
finally
:
GPIO
.
cleanup
()
return
int
(
id
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment