-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e78c043
commit bf2c54e
Showing
18 changed files
with
721 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# PCB Canta Storie con Arduino Nano e RC522 | ||
|
||
Il PCB del progetto è disponibile su EasyEDA [Canta Storie Arduino Nano PCB](https://oshwlab.com/giorgio.boiero/tonuino-extended_copy) | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Canta Storie realizzato con Arduino Nano e RC522 | ||
La cartella contiene i file del Canta Storie realizzato con Arduino Nano e il sensore RFID RC522 che è meno costoso del PN532 | ||
Il funzionamento del Canta Storie è identico | ||
|
||
|
||
**Materiale necessario** | ||
- Arduino Nano a 5V | ||
- MP3 DFPlayer | ||
- SD Card con file MP3 | ||
- Lettore RFID RC522 | ||
- TXS0108E Level Shifter Breakout Board | ||
- Tessere/Tag RFID | ||
|
||
E' possibile usare il [Kit Tonuino di Az Delivery](https://www.az-delivery.de/it/products/tonuino-set) e acquistare a parte il TXS0108E | ||
|
||
Lo Schema e il PCB del progetto è disponibile su EasyEDA [Canta Storie Arduino Nano - Schema e PCB](https://oshwlab.com/giorgio.boiero/tonuino-extended_copy) | ||
|
||
Per precauzione è stato usato il TXS0108E Level Shifter perchè il lettore RFID RC522 non è garantito per funzionare con i 5V da NXP | ||
|
||
|
||
|
||
|
||
|
||
|
75 changes: 75 additions & 0 deletions
75
10_Other_Versions/Arduino_Nano_RC522/Sketches/CS_Nano_R00/CS_Nano_R00.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* ---------------------------------------------------- | ||
* CantaStorie con RC522 e Arduino Nano => Tonuino | ||
* Rev 00 | ||
* | ||
-------------------------------------------------------*/ | ||
#include <SPI.h> | ||
#include <MFRC522.h> | ||
#include <EZPROM.h> | ||
|
||
|
||
#define SS_PIN 10 | ||
#define RST_PIN 9 | ||
|
||
|
||
String programma="CS_Random_Giorgio_18-08-2020"; | ||
MFRC522 rfid(SS_PIN, RST_PIN); // Instance of the class | ||
#define MP3_files 14 // Numero massimo di MP3 riproducibili + 4 (Card di servizio( | ||
|
||
int MP3_file_registrati=4; //MP3 registrati | ||
|
||
//Per Scheda Carlo | ||
//byte MP3_busy=2; | ||
|
||
//Per Arduino Nano | ||
byte MP3_busy=4; | ||
|
||
|
||
byte LED1=A4; | ||
byte LED2=A5; | ||
//byte led1=0; | ||
//byte led2=0; | ||
|
||
|
||
const uint8_t uid_cards_id=0; | ||
const uint8_t uide_id=0; | ||
const uint8_t volume_id=1; | ||
const uint8_t MP3_file_registrati_id=2; | ||
|
||
uint8_t uid_ok[MP3_files][7]; | ||
//uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID | ||
const int mstatus[] = { //Status associated to the RFID Cards | ||
903, //RFID 1: Load Card RFID | ||
900, //RFID 2: stop | ||
901, //RFID 3: vol+ | ||
902, //RFID 4: vol- | ||
1, //RFID 5: track 1 | ||
2, //RFID 6: track 2 | ||
3, //RFID 7: track 3 | ||
4, //RFID 8: track 4 | ||
5, //RFID 9: track 5 | ||
6, //RFID 10: track 6 | ||
7, //RFID 11: track 7 | ||
8, //RFID 12: track 8 | ||
9, //RFID 13: track 9 | ||
10, //RFID 14: track 10 | ||
}; | ||
const uint8_t uid_cards[][7] = { | ||
//{ 0x4, 0x82, 0x87, 0xDA, 0x64, 0x5D, 0x81 }, //RFID 1 => Master | ||
{0x4, 0x8, 0xBA, 0xFA, 0xAD, 0x56, 0x80,}, | ||
{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, //RFID 2 | ||
{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, //RFID 3 | ||
{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, //RFID 4 | ||
{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, //RFID 5 | ||
{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, //RFID 6 | ||
{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, //RFID 7 | ||
{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, //RFID 8 | ||
{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, //RFID 9 | ||
{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, //RFID 10 | ||
{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, //RFID 11 | ||
{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, //RFID 12 | ||
{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, //RFID 13 | ||
{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, //RFID 14 | ||
}; | ||
int volume=12; | ||
//const int secondi=60; |
78 changes: 78 additions & 0 deletions
78
10_Other_Versions/Arduino_Nano_RC522/Sketches/CS_Nano_R00/Mp3Notify.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#ifndef MP3NOTIFY_H | ||
#define MP3NOTIFY_H | ||
// implement a notification class, | ||
// its member methods will get called | ||
//---------------------------------------------- | ||
class Mp3Notify{ | ||
public: | ||
static void OnError(uint16_t errorCode){ | ||
// see DfMp3_Error for code meaning | ||
Serial.println(); | ||
Serial.print("Com Error "); | ||
Serial.println(errorCode); | ||
|
||
/* NOTE | ||
https://github.com/Makuna/DFMiniMp3/blob/master/src/DFMiniMp3.h | ||
DfMp3_Error | ||
// from device | ||
DfMp3_Error_Busy = 1, | ||
DfMp3_Error_Sleeping, | ||
DfMp3_Error_SerialWrongStack, | ||
DfMp3_Error_CheckSumNotMatch, | ||
DfMp3_Error_FileIndexOut, | ||
DfMp3_Error_FileMismatch, | ||
DfMp3_Error_Advertise, | ||
// from library | ||
DfMp3_Error_PacketSize = 0x81, | ||
DfMp3_Error_PacketHeader, | ||
DfMp3_Error_PacketChecksum, | ||
DfMp3_Error_General = 0xff | ||
*/ | ||
} | ||
//------------------------------------------------- | ||
static void OnPlayFinished(uint16_t globalTrack){ | ||
Serial.println(); | ||
//Serial.print("Play finished for #"); | ||
|
||
Serial.println("Fine lettura brano"); | ||
Serial.println(globalTrack); | ||
//digitalWrite(LED1,LOW); | ||
} | ||
//----------------------------------------------- | ||
static void OnCardOnline(uint16_t code){ | ||
Serial.println(); | ||
Serial.print("Card online "); | ||
Serial.println(code); | ||
} | ||
//---------------------------------------------- | ||
static void OnUsbOnline(uint16_t code){ | ||
Serial.println(); | ||
Serial.print("USB Disk online "); | ||
Serial.println(code); | ||
} | ||
//--------------------------------------------- | ||
static void OnCardInserted(uint16_t code){ | ||
Serial.println(); | ||
Serial.print("Card inserted "); | ||
Serial.println(code); | ||
} | ||
//-------------------------------------------- | ||
static void OnUsbInserted(uint16_t code){ | ||
Serial.println(); | ||
Serial.print("USB Disk inserted "); | ||
Serial.println(code); | ||
} | ||
//------------------------------------------- | ||
static void OnCardRemoved(uint16_t code){ | ||
Serial.println(); | ||
Serial.print("Card removed "); | ||
Serial.println(code); | ||
} | ||
//------------------------------------------ | ||
static void OnUsbRemoved(uint16_t code){ | ||
Serial.println(); | ||
Serial.print("USB Disk removed "); | ||
Serial.println(code); | ||
} | ||
}; | ||
#endif |
49 changes: 49 additions & 0 deletions
49
10_Other_Versions/Arduino_Nano_RC522/Sketches/CS_Nano_R00/_100_mp3_ok.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* Inizialize MP3 player | ||
* | ||
*/ | ||
#include <SoftwareSerial.h> | ||
#include "Mp3Notify.h" | ||
#include <DFMiniMp3.h> | ||
|
||
// instance a DFMiniMp3 object, | ||
// defined with the above notification class and the hardware serial class | ||
//DFMiniMp3<HardwareSerial, Mp3Notify> mp3(Serial1); | ||
|
||
|
||
//Prototipo Carlo | ||
//SoftwareSerial secondarySerial(4, 3); //rxPin, txPin | ||
|
||
//Prototipo Nano | ||
SoftwareSerial secondarySerial(2, 3); //rxPin, txPin | ||
|
||
//Prototipo BEA | ||
//SoftwareSerial secondarySerial(3, 4); | ||
|
||
|
||
DFMiniMp3 <SoftwareSerial, Mp3Notify> mp3(secondarySerial); | ||
|
||
|
||
/* NOTES Library MP3 | ||
DF Player Library | ||
https://github.com/Makuna/DFMiniMp3/blob/master/src/DFMiniMp3.h | ||
it expects the sd card to contain these three mp3 files but | ||
doesn't care whats in them | ||
sd:/mp3/0001.mp3 | ||
sd:/mp3/0002.mp3 | ||
sd:/mp3/0003.mp3 | ||
DfMp3_Error | ||
// from device | ||
DfMp3_Error_Busy = 1, | ||
DfMp3_Error_Sleeping, | ||
DfMp3_Error_SerialWrongStack, | ||
DfMp3_Error_CheckSumNotMatch, | ||
DfMp3_Error_FileIndexOut, | ||
DfMp3_Error_FileMismatch, | ||
DfMp3_Error_Advertise, | ||
// from library | ||
DfMp3_Error_PacketSize = 0x81, | ||
DfMp3_Error_PacketHeader, | ||
DfMp3_Error_PacketChecksum, | ||
DfMp3_Error_General = 0xff | ||
*/ |
79 changes: 79 additions & 0 deletions
79
10_Other_Versions/Arduino_Nano_RC522/Sketches/CS_Nano_R00/_200_eeprom_ok.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
//--------------------------------------------- | ||
void read_eeprom(){ | ||
//Read the RFID Cards UIDs codes from the Arduino Eeprom | ||
// ezprom.setOverwriteIfSizeDifferent(true); | ||
//delay(500); | ||
Serial.println(F("Carica le Carte dalla Eeprom")); | ||
//..................... | ||
ezprom.load(uide_id, **uid_ok); //uide=costante impostata a 0, locazione iniziale. | ||
delay(1000); //uid_ok, array bidimesionale con posizione e valore. | ||
//..................... | ||
Serial.println(F("")); | ||
Serial.println(F("Registrate le seguenti Carte:")); | ||
for (int n=0; n<MP3_files; n++) { //uid_ok[MP3_files][7] | ||
Serial.print(F("New UID Card ")); //MP3_files=14; | ||
Serial.print(n+1); | ||
Serial.print(F(" Value: ")); | ||
for (uint8_t i=0; i < 7; i++){ | ||
Serial.print(F(" 0x")); | ||
Serial.print(uid_ok[n][i], HEX); | ||
} //n=numero carta, i=valore. Es 04:82:87:DA | ||
Serial.println(F("")); //altro tipo carta 04:82:87:DA:64:5D:81 | ||
} | ||
|
||
// Carica il volume dalla eeprom | ||
Serial.print(F("Carica il volume dalla Eeprom: ")); | ||
ezprom.load(volume_id, volume); //Commentare al primo avvio perchè dato non registrato | ||
delay(1000); | ||
Serial.println(volume); | ||
|
||
// Carica max file per Random | ||
Serial.print(F("Carica max file per Random: ")); | ||
ezprom.load(MP3_file_registrati_id, MP3_file_registrati); //Commentare al primo avvio perchè dato non registrato | ||
delay(1000); | ||
Serial.println(MP3_file_registrati); | ||
|
||
|
||
} //end | ||
|
||
|
||
|
||
//---Inizializzazione EEPROM-------------------- | ||
void initEEPROM(void){ | ||
Serial.println(F("Formattazione Eeprom...")); | ||
ezprom.reset(); | ||
delay(100); | ||
Serial.println(F("Eeprom formattata...")); | ||
//ezprom.setOverwriteIfSizeDifferent(true); | ||
//const uint8_t uid_cards_id=0,uide_id=1; | ||
Serial.println(F("Registra le Carte nella Eeprom")); | ||
//Carica sulla Eeprom solo il codice della card Master, | ||
//tutti gli altri campi vouti. | ||
ezprom.save(uid_cards_id, **uid_cards, MP3_files * 7); | ||
delay(1000); | ||
Serial.println(F("Registra il volume nella Eeprom")); | ||
ezprom.save(volume_id, volume, sizeof(volume)); | ||
delay(1000); | ||
Serial.println(F("Registra massimo numero di brani random")); | ||
ezprom.save(MP3_file_registrati_id, MP3_file_registrati, sizeof(MP3_file_registrati)); | ||
|
||
Serial.println(F("Verifica che le Carte siano state salvate nella Eeprom")); | ||
//uint8_t uid_e[MP3_files][7]; | ||
//ezprom.load(uid_cards_id, **uid_e); //Carica i dati da Eeprom per verifica. | ||
//delay(1000); | ||
//Serial.println(F("")); | ||
read_eeprom(); | ||
/* | ||
Serial.println(F("Registrate le seguenti Carte:")); | ||
for (int n=0; n<MP3_files; n++) { //Verifica contenuto Eeprom. | ||
Serial.print(F("New UID Card ")); | ||
Serial.print(n+1); | ||
Serial.print(F(" Value: ")); | ||
for (uint8_t i=0; i < 7; i++){ | ||
Serial.print(F(" 0x")); | ||
Serial.print(uid_e[n][i], HEX); //Dati in Eeprom. | ||
} | ||
Serial.println(F("")); | ||
} | ||
*/ | ||
} |
Oops, something went wrong.