ATM Automation Sketches
The rfid_scanner/rfid_scanner.ino sketch will be installed onto each Arduino R4 UNO WiFi.
The general behavior is:
- Setup: connect to wifi, initialized RFID scanner
- Loop:
- Watch for scan
- Turn on LEDs
- Submit tag information to software via HTTP
- Enable automation
- Wait for automation to complete, or until we hit a configurable timeout
All customization options can be found in config.h, along with comments.
The code has a couple different automations that can be enabled, which implement a pretty basic interface
setup()run(callback)cancel()
The setup() will be called from the main setup() routine.
The run(callback) will be called to start the automation. A void (*) function can be passed as a "done callback", which should be called when the automation completes.
The cancel() function can be called at any time to cancel an automation. The cancel() implementation should reset the state so that the automation is ready to be triggered again.
Enable by uncommenting the following lines in config.h:
#include "NoAutomation.h"
NoAutomation automation;This should be used when no automation is needed.
Enable by uncommenting the following lines in config.h:
#include "DigitalSignalAutomation.h"
DigitalSignalAutomation automation;Pinout:
- Arduino pin 5 - TX, defaults to
LOW - Arduino pin 4 - RX, defaults to
INPUT_PULLDOWN
You can override the RX pin default by passing in a different pin mode, e.g.
#include "DigitalSignalAutomation.h"
DigitalSignalAutomation automation(INPUT_PULLUP);The DigitalSignalAutomation has the following functionality:
- When automation is triggered, writes
HIGHto TX pin - Then waits to detect a rising edge
LOW->HIGHon RX pin- When detected, executes callback passed to
run()
- When detected, executes callback passed to
- Can be cancelled by calling
cancel()
Enable by uncommenting the following lines in config.h:
#include "DigitalSignalLowAutomation.h"
DigitalSignalLowAutomation automation;Pinout:
- Arduino pin 5 - TX, defaults to
LOW - Arduino pin 4 - RX, defaults to
INPUT_PULLUP
The DigitalSignalLowAutomation has the following functionality:
- When automation is triggered, writes
HIGHto TX pin - Then waits to detect a falling edge
HIGH->LOWon RX pin- When detected, executes callback passed to
run()
- When detected, executes callback passed to
- Can be cancelled by calling
cancel()
Enable by uncommenting the following lines in config.h:
#include "SoundAutomation.h"
SoundAutomation automation;Pinout:
- Arduino pin 5 - Serial TX
- Arduino pin 4 - Serial RX
- Arduino pin 3 - BUSY pin, defaults to
INPUT_PULLUP
The SoundAutomation has the following functionality:
- Sets
trackto 1 - When automation is triggered, writes serials commands to trigger track
track- Increments
track
- Increments
- Then waits to detect a rising edge
LOW->HIGHon BUSY pin- When detected, executes callback passed to
run()
- When detected, executes callback passed to
- Can be cancelled by calling
cancel()
The DY-* modules are very particular about the names of files, and the existence of additional files on the memory card.
If using MacOS, it will add a bunch of Spotlight-related files that will mess stuff up.
How to get mp3 files on the memory card:
- Download your mp3 files and place them in
Documents/mp3s, using the naming convention00001.mp3,00002.mp3, etc. - Insert your memory card
- Remove extra files (note that it's okay to have a
.fseventsdpresent)
sudo mdutil -d /Volumes/NO\ NAME
sudo mdutil -X /Volumes/NO\ NAME
find /Volumes/NO\ NAME -type f -name '.*' -delete
ls -al /Volumes/NO\ NAME- Copy over mp3s using terminal:
cd ~/Documents/mp3s
cp -v `ls -1 mp3s/*.mp3|sort` /Volumes/NO\ NAME- Unmount the memory card using terminal:
diskutil umount /Volumes/NO\ NAME
Enable by uncommenting the following lines in config.h:
#include "WledAutomation.h"
WledAutomation automation;Pinout:
- Arduino pin 5 - Serial TX
- Arduino pin 4 - Serial RX
The WledAutomation has the following functionality:
- Sets
preset=1 - When automation is triggered, turns on LEDs to preset
preset- Increments
preset
- Increments
- Waits a configurable amount of time
- Turns off LEDs
- Can be cancelled by calling
cancel()