-
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
kaizoku-oh
committed
Aug 20, 2023
1 parent
243ec1d
commit 1fd19bf
Showing
4 changed files
with
117 additions
and
63 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 |
---|---|---|
@@ -1,2 +1,45 @@ | ||
# resto-device | ||
Embedded project for resto card reader | ||
|
||
### Final application vision | ||
``` C | ||
// Clean code | ||
|
||
#include <Arduino.h> | ||
|
||
#include "Log.h" | ||
#include "Led.h" | ||
#include "Buzzer.h" | ||
#include "CardReader.h" | ||
|
||
#define MFRC522_RST_PIN (5) | ||
#define MFRC522_SPI_SS_PIN (10) | ||
#define MFRC522_IRQ_PIN (1) | ||
#define BUZZER_PIN (0) | ||
#define BUZZER_BEEP_DURATION_MS (1000) | ||
#define GREEN_LED_ON_DURATION_MS (1000) | ||
|
||
static void onCardDetected(Card card); | ||
|
||
static const char *TAG = "MAIN"; | ||
|
||
static CardReader cardReader(MFRC522_SPI_SS_PIN, MFRC522_RST_PIN, MFRC522_IRQ_PIN); | ||
static Buzzer buzzer(BUZZER_PIN); | ||
static Led greenLED(LED_GREEN); | ||
static Log logger(&Serial); | ||
|
||
void setup() { | ||
logger.i(TAG, "App started..."); | ||
|
||
cardReader.registerCallback(onCardDetected); | ||
cardReader.run(); | ||
} | ||
|
||
void loop() {} | ||
|
||
static void onCardDetected(Card card) { | ||
logger.i(TAG, "UID: " + card.getUID()); | ||
greenLED.asyncOn(GREEN_LED_ON_DURATION_MS); | ||
buzzer.asyncOn(BUZZER_BEEP_DURATION_MS); | ||
} | ||
``` |
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
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
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