As a group, we were designing a product to ease a pain point in the daily life of an assigned employee on CMU campus. Our client was Crystal, one of the archivists in the CMU Library system. After interviewing and shadowing her in her work environment, we identified a few key pain points:
She has many files to organize and keep track of, and no immediate way to record which of the files have been scanned into the online system (or "digitized").
Due to the way the files are stored, she spends most of her time moving up and down a ladder, which makes keeping track of supplies difficult and tedious.
Another tedious activity is cleaning the numerous film negatives, which require intense but gentle brushing to remove debris before getting digitized.
"I wish there was a magic button next to the file to show it had been logged."
Crystal mentioned this complaint in a very emphatic manner throughout our conversations, so it became our main inspiration for the solution we developed for her.
The Portable Digitizer is a device that can move with Crystal as she is logging different files. Due to it's purse-like shape, it can standalone on a surface or attach to her ladder. When she has digitized a file, she enters that filepath on the device's screen through the silver keypad. When the joystick is clicked, it acts as an "enter" button and logs that filepath number in the internal SD card. When she wants to check an updated list of all digitized files and their corresponding dates, she can plug the SD card into her computer and compile the updated dates to their Master Inventory file. Moving the joystick up and down allows the user to move through previous entries, providing quick number access for when two files share a similar filepath number (e.g. two files in the same box, two boxes in the same collection, ect.) Additionally, there are spots for her to store a Post-It pad and pencil, items she always needs but is frequently dropping from the ladder. The casing is hot pink as a personal ode to her mission of bringing whimsy to her workplace.
The final product: a Portable Digitizer
Crystal the CMU Archivist is fetching some files and documents for a client. She takes the Portable Digitizer with her as she climbs up her ladder. She straps the Digitizer to the bar on the top of the ladder. Then, she looks for the right box to fetch her files from. When she finds it, she wants to digitize the file to send to the client.
With the Portable Digitizer, she types in the Collection Year through the num-pad, which shows up on the LCD screen. She shifts the joystick to the right to move to the next space to fill out. Once she fills out all the units, she clicks down on the joystick, where the message “Successfully Digitized” is displayed.
As she goes through the many different artifacts she wants to digitize, she loses track of what she just digitized. She moves the joystick upwards to check the recent history of the files she digitized, and realized she already digitized the file she was working on! Thus, she moves on to the next file to digitize.
All the while, she takes some sticky notes and uses her pencil, attached to the Portable Digitizer, to jot notes down about her documentation process.
Seeing Crystal's workplace: the Archives
Our initial with Crystal was a freindly, revelaing conversation about some issues she has in her workspace. She came prepared with some ideas, which was helpful, but overestimated the scope of what our team could accomplish for her in this tight time period (with our limited knowledge). Taking away the integration of WIFI nullified many of her ideas, so we started looking for other ways we could assist her with simple physical computing technology. It would have been helpful if she was aware of the scope before creating a list. We also could have done a better job at steering quesitons, as the group got derailed often in conversation. Something that was very helpful was seeing her actual workplace, noticing how she interacted with the files, and how she used the ladder in practice.
We made three prototypes to answer questions for a secondary client use interview:
Form prototype: Do you prefer the look of one of these shapes over others? Do you have a specific vision for how the caisng will look?
Interaction prototype: Do you prefer navigating the menu screen with a joystick, rotational dial, or a set of buttons?
Attachment prototype: What's the most optimal method of attachment for this device to the ladder you use?
A series of drawings representing the form prototype.
Our interaction prototype.
A prototype for deciding attachment method.
Her answers to these three quesitons guided the rest of our design process:
Form protoype: She prefers the triangluar shape that looks like a purse. She wants a flat bottom with all interactions on the front panel, not the top. She'd like to be surprised by a bright, fun color in the outside casing so the device is whimsical in her space.
Interaction prototype: A joystick would be the her preferred method of navigation. She said the filepath name needed to have some formatted adjusted to match their existing system.
Attachment prototype: She liked the magnets and the straps, and wanted them together on the device. After inspecting her ladder, it's aluminum material is not magnetic, so we opted for just the straps on the final.
Our GANTT chart for keeping our project on schedule.
Building the Final Product
Our group split up the work and together finalized the coding, physical computing, CAD modeling, laser printing, and final assembly. From the coding and physical computing side, we had trouble mapping the keypad, initializing the SD card, stabilizing the LCD, and fitting the program within the Arduino Uno’s limited memory. Testing each component separately and simplifying the code helped us create a more reliable device. After mapping out the final measurements of the design according to the existing physical computing components, CADding appeared to be an easy part of the process. We printed out test pieces, which was a smart move because everything cut at half scale. We made adjustments and printed at the right size, so it was time to start adding the finger joints. After spending hours creating the finalized files for laser cutting, there were issues with the file translating to the cutter. After completely starting over in a different software, the file was able to print successfully. Some dimensions were a bit off, but we were able to adjust them during final assembly. During assembly, we noticed that some parts didn't fit the final laser-cut product, as a last minute fix we decided to manually file down every dimension to allow the LCD screen and the battery pack to fit. Another huge issue when assembling the final product was the conflict of fitting every component into the box in a well ordered manner. At first we believed we could just stuff every part into the box and call it a day, but it turned out that parts may become loose and dangerous if we did so. To circumvent this problem, we decided to secure the main big components with hot glue, such as the protoboard, LCD, and keypad, while the smaller components could be left in the open to allow for more flexability. A couple things we realized at the end of the process that we should have considered at the beginning of fabrication was easy access to the SD card and an on/off button. In its final form, the user has to fold down the front panel to take out the SD or plug the board to power. Other than these small oversights, we were proud with our device's outcome.
While presenting our product during the final critique, we felt that the process went well. We received mostly positive feedback, and many critics appreciated both the appearance and functionality of our design. Most importantly, our client, Crystal, thoroughly enjoyed the product and felt that it responded to the problems she described during our interviews. Although most of the responses were positive, the constructive criticism gave us valuable insight into several ways we could improve the device.
The final critique showed that the project’s main strengths were its portability, simple interaction, and close connection to Crystal’s workflow. We were happy to see that one response said the device was “Simple interface, effectively solves the problem, very cute!” Reviewers also liked the history feature, formatted SD-card data, bright color, pencil holder, and Post-it storage. Another person specifically praised how we listened to our client, writing, “Making the SD format work for Crystal’s workflow on the backend is amazing!! Also the fact that you listened to her needs and made a simple yet functional design for her.” This feedback confirmed that our most successful decisions came from observing Crystal’s routine and responding to her specific needs.
The most common criticism concerned access to the SD card and absence of a power switch. One person wrote, “It would be nice to have quick access to power and the SD card.” While assembling, we hadn't thought of a place to have the SD card accessible and the pink casing we made hadn't had a place laser cut to be able to fit the SD card module. So, the decision was ultimately made to keep the SD card module inside the case hidden away instead of making last minute cuts that may ruin the structure of the outer shell. Because these components were located inside the enclosure, the user had to partially open the device whenever they wanted to remove the card or turn it off. Something that we definitely could have done better if we had created another version, it would be to add an external SD-card slot to be able to access without opening the casing, as well as creating a power switch that is both easily accessible and exists. These changes would drastically improve our device by not needing to open the casing, making it way more reliable.
We also received useful feedback about the software. One response suggested “Being able to delete individual entries.” Currently, the user can only add entries or view previous entries but cannot remove an entry at all. By adding editing and deletion functions, it would make the device more forgiving and practical to be an all-in-one digitizer for an archivist. Another person suggested, “Allow entry of partial information (such as if the year of an item isn’t known). Could use a less bulky case.” This made us realize that our input system assumes every archival identifier will be complete, which may not always be true. This also got us thinking about different features we could add if we had more time. For example, something that we could add to decrease the actions needed to digitize something, thus cutting down accumulative work time with our device, is to automatically go to the next entry box after filling it out, or remembering the first 4 entries such as the year, collection, isle, box, and only needing to edit the number in the box each time.
Working with a client was different from designing something for ourselves because we could not rely on assumptions about how the device would be used. Researching our client was important, if not the most important part of our project. We needed to understand how Crystal moves through the archives, how her files are identified, what supplies she carries, and how the data would eventually enter her existing system. While learning more about how Crystal works, it was difficult for us to pinpoint one problem that we could reliably solve with a designed product. We thought about creating some film negative cleaner, or an environmental alarm to alert when humidity and temperature are too high for the archives. In the end, we landed on this digitizer as we believed that it would be the most help for Crystal after learning all about her workflow. As we developed this idea, we also added some small features such as the pencil holder or post-its. Surprisingly, smaller physical details were just as important to the client as some of the electronic features.
Overall, we are proud that the Portable Digitizer addresses a real problem with a focused and understandable interaction. If we developed it further, we would improve the enclosure, make the SD card and power switch easier to access, strengthen the ladder attachment, and add more flexible entry-editing features. Most importantly, we learned that continued communication and careful observation are essential when creating something genuinely useful for a client.
The device runs on an Arduino UNO, it takes a 6xAA battery pack through the barrel jack for 7.2V input, the rest of the technical components are explained below:
Functional Block Diagram:
Electrical Schematic:
Main Code:
/*
60-223 Intro to Physical Computing, fall 2026
Campus Client Project: Portable Digitizer
OVERVIEW:
For this project, our group designed a product to address a pain point in the
daily work of an assigned CMU employee. Our client was Crystal, an archivist
in the CMU Libraries system.
After interviewing Crystal and observing her work environment, we identified
several challenges. She manages many physical files and does not have an
immediate way to record which files have already been scanned into the online
system, or "digitized." Because the files are stored on shelving that requires
a ladder, she also spends much of her time moving up and down while carrying
supplies and trying to keep track of her progress.
Crystal repeatedly expressed that she wished there were a "magic button" beside
each file that could show that it had been digitized. This became the primary
inspiration for the Portable Digitizer.
WHAT WE BUILT:
The Portable Digitizer is a device that moves with Crystal while she works.
Its purse-like enclosure can stand on a surface or attach to her ladder. It
also includes places to store a Post-it pad and pencil, which are supplies she
regularly uses but can easily drop while working on the ladder. The enclosure
is hot pink as a personal reference to Crystal's goal of bringing more whimsy
into her workplace.
After digitizing a file, the user enters its ArchivesSpace identifier using a
3x4 numeric keypad. The identifier follows this format:
1988-0001_01_32_01
Collection year - Collection number - Box - Folder - Item
The joystick moves left and right between identifier sections. Clicking the
joystick acts as the Enter button. If the identifier is complete, the device
records the identifier and the current date and time on an internal microSD
card.
Moving the joystick up and down browses the three most recent entries stored
in the Arduino's memory. Clicking while viewing a history entry selects it,
allowing the user to quickly modify identifiers that share a collection, box,
or folder number.
Keypad controls:
0-9 Enter digits into the selected section
* Delete the most recent digit in the selected section
# Clear the entire identifier
Joystick controls:
Left/right Move between identifier sections
Up/down Browse recent digitized identifiers
Click Digitize the current identifier or select a history entry
The 20x4 LCD displays the current identifier, selected section, history, and
success or error messages. A DS3231 real-time clock supplies the digitization
date and time. The microSD card stores the persistent CSV log.
The SD card CSV uses the following columns:
archivesspace_id,digitized_datetime
Example row:
1988-0001_01_32_01,2026-11-15 14:30
This sketch is organized into libraries, hardware definitions, variables,
setup, LCD functions, identifier functions, history functions, keypad input,
joystick input, and the main loop.
IMPORTANT:
- The SD card must be formatted as FAT16 or FAT32, not exFAT.
- The SD card file must use an 8.3-compatible filename. This project uses:
ASDIGIT.CSV
- The installed SD library supports short DOS-style filenames and may not open
a filename such as ArchivesSpace_digitized_IDs_Arduino.csv directly.
- The SD adapter used in this project accepts 5V because it includes an onboard
regulator. A bare microSD adapter may require 3.3V instead. Check the specific
adapter before connecting power.
- Do not remove the SD card while the Arduino is writing. Wait for the success
message, turn off the device, and then remove the card.
- The RTC and LCD share the Arduino's I2C bus. SDA connects to A4 and SCL
connects to A5.
- The RTC's 32K and SQW pins are not used.
- The keypad's seven connections are all row and column signals. The keypad
does not connect directly to 5V or ground.
- The RTC time can be set once with rtc.adjust(). Comment out that line and
upload the program again afterward, or the RTC will reset to the specified
time every time the Arduino restarts.
- The Arduino Uno barrel jack should normally receive 7-12V DC through a
center-positive plug. A six-cell NiMH pack supplies only 7.2V nominal and may
become unstable as it discharges. A regulated supply or eight-cell NiMH pack
is more reliable.
PIN MAPPING:
Arduino pin | Role | Details
------------------------------------------------
2 | Joystick | SW pushbutton
3 | Keypad | R4
4 | Keypad | R1
5 | Keypad | C2
6 | Keypad | R3
7 | Keypad | C3
8 | Keypad | R2
9 | Keypad | C1
10 | SD card | CS
11 | SD card | MOSI
12 | SD card | MISO
13 | SD card | SCK
A0 | Joystick | VRX
A1 | Joystick | VRY
A4/SDA | RTC + LCD | Shared I2C data
A5/SCL | RTC + LCD | Shared I2C clock
5V | Joystick | Power
5V | LCD | Power
5V | RTC | Power
5V | SD adapter | Power for the regulated adapter used in this project
GND | All modules| Common ground
LIBRARIES AND SUPPORTING FILES:
Keypad:
Reads the 3x4 matrix keypad.
Wire:
Provides I2C communication with the LCD and RTC.
LiquidCrystal_I2C:
Controls the 20x4 LCD at I2C address 0x27.
RTClib:
Controls the DS3231 real-time clock.
SDLogFile.h:
Initializes the microSD card and appends identifiers and timestamps to
ASDIGIT.CSV.
Disclosure:
This code was partially written and edited with the assistance of generative AI.
_____
Prompt 1
how would i wire this keypad to be able to type the numbers
Prompt 2
pressing 1: results nothing
2: #
3: *
4: nothing
5: 6
6: 4
7: nothing
8: 3
9: 1
*: 8
0: nothing
#: nothing
each button currently corresponds to these keys, how would I edit the row and column pin assignments of the keypad to fix this issue?
Prompt 3
so i want to do this format
1988-0001_01_32_01
(Collection#,box 1,folder 32,item 01)
along with the keypad and the joystick
the keypad to type the numbers
the joystick to move between sections (1988, or 0001, or 01, or 32, or 01)
Prompt 4
how can I make it so that pressing # after each section goes to the next. and then clicking the joystick would say "successfully digitized"
Prompt 5
i would also want to implement a new features that allows you to go to previous history using the updown on the joystick
Prompt 6
here’s the csv file formats that I would like to write onto, let’s say that I want to append to the last one using the same file format as the specified format as above. what would be the best way to keeping track of entered files?
Prompt 7
Ok. How about for now lets just add to our original code to make a full prototype that just edits this CSV to
ignoring their csv inventory.
im using a micro sd card adapter
with CS, SCK, MOSI, MISO, VCC, GND
can you tell me how to wire it and if the code i uploaded could work with the module i have?
Prompt 8
Sketch uses 23338 bytes (72%) of program storage space. Maximum is 32256 bytes.
Global variables use 1916 bytes (93%) of dynamic memory, leaving 132 bytes for local variables. Maximum is 2048 bytes.
Low memory available, stability problems may occur.
so it says completed uploading but the lcd screen is stuck and doesnt go dark then flash back on to show its reset the code. how would I reduce the memory to allow the code to run efficiently?
_____
Released to the public domain by the authors, November 2026.
Eddy, AC, Grace
emiao@andrew.cmu.edu, amunger@andrew.cmu.edu, gracehua@andrew.cmu.edu
*/
#include <Keypad.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <RTClib.h>
#include "SDLogFile.h"
// ==================================================
// Hardware
// ==================================================
const byte SD_CS_PIN = 10;
const byte JOYSTICK_X = A0;
const byte JOYSTICK_Y = A1;
const byte JOYSTICK_SW = 2;
RTC_DS3231 rtc;
LiquidCrystal_I2C lcd(0x27, 20, 4);
bool sdReady = false;
bool rtcReady = false;
bool joystickReady = true;
byte lastJoystickSwitchState = HIGH;
// ==================================================
// Keypad
// ==================================================
const byte ROWS = 4;
const byte COLS = 3;
char keys[ROWS][COLS] = {
{ '1', '2', '3' },
{ '4', '5', '6' },
{ '7', '8', '9' },
{ '*', '0', '#' }
};
byte rowPins[ROWS] = { 4, 8, 6, 3 };
byte colPins[COLS] = { 9, 5, 7 };
Keypad keypad = Keypad(
makeKeymap(keys),
rowPins,
colPins,
ROWS,
COLS);
// ==================================================
// Identifier
// ==================================================
// Identifier format: 1988-0001_01_32_01
const byte SECTION_COUNT = 5;
const byte ID_LENGTH = 18;
const byte ID_BUFFER_SIZE = ID_LENGTH + 1;
const byte sectionLengths[SECTION_COUNT] = {
4, // Collection year
4, // Collection number
2, // Box
2, // Folder
2 // Item
};
const byte sectionPositions[SECTION_COUNT] = {
0, 5, 10, 13, 16
};
// Each section has room for the longest section (4 digits) plus '\0'.
char sections[SECTION_COUNT][5] = {
"", "", "", "", ""
};
byte selectedSection = 0;
// ==================================================
// History
// ==================================================
// Fixed-size storage avoids String heap fragmentation.
const byte MAX_HISTORY = 3;
char digitizedHistory[MAX_HISTORY][ID_BUFFER_SIZE] = {
"", "", ""
};
byte historyCount = 0;
int8_t historyIndex = -1;
// ==================================================
// Setup
// ==================================================
void setup() {
Serial.begin(9600);
pinMode(JOYSTICK_SW, INPUT_PULLUP);
// Initialize the display first so startup progress is visible.
lcd.init();
lcd.backlight();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(F("Starting..."));
sdReady = slBegin(SD_CS_PIN);
if (sdReady) {
Serial.println(F("SD card ready"));
} else {
Serial.println(F("SD card failed"));
}
rtcReady = rtc.begin();
if (rtcReady) {
Serial.println(F("RTC ready"));
if (rtc.lostPower()) {
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
} else {
Serial.println(F("RTC failed"));
}
updateDisplay();
Serial.println(F("Archive digitization logger ready"));
//rtc.adjust(DateTime(2026, 11, 8, 0, 45, 0));
}
// ==================================================
// LCD Functions
// ==================================================
void clearLCDRow(byte row) {
lcd.setCursor(0, row);
lcd.print(F(" "));
}
void printSectionName(byte section) {
switch (section) {
case 0:
lcd.print(F("Collection year"));
break;
case 1:
lcd.print(F("Collection number"));
break;
case 2:
lcd.print(F("Box"));
break;
case 3:
lcd.print(F("Folder"));
break;
case 4:
lcd.print(F("Item"));
break;
}
}
void printPaddedSection(byte section) {
lcd.print(sections[section]);
byte used = strlen(sections[section]);
while (used < sectionLengths[section]) {
lcd.print('_');
used++;
}
}
void printDisplayID() {
printPaddedSection(0);
lcd.print('-');
printPaddedSection(1);
lcd.print('|');
printPaddedSection(2);
lcd.print('-');
printPaddedSection(3);
lcd.print('-');
printPaddedSection(4);
}
void buildFinalID(char *output, byte outputSize) {
snprintf_P(
output,
outputSize,
PSTR("%s-%s_%s_%s_%s"),
sections[0],
sections[1],
sections[2],
sections[3],
sections[4]);
}
void updateDisplay() {
clearLCDRow(0);
lcd.setCursor(0, 0);
printSectionName(selectedSection);
clearLCDRow(1);
lcd.setCursor(0, 1);
printDisplayID();
clearLCDRow(2);
lcd.setCursor(sectionPositions[selectedSection], 2);
for (byte i = 0; i < sectionLengths[selectedSection]; i++) {
lcd.print('^');
}
clearLCDRow(3);
lcd.setCursor(0, 3);
lcd.print(F("Move=select Click=OK"));
}
void displayHistory() {
clearLCDRow(0);
clearLCDRow(1);
clearLCDRow(2);
clearLCDRow(3);
lcd.setCursor(0, 0);
lcd.print(F("Digitized history"));
lcd.setCursor(0, 1);
lcd.print(digitizedHistory[historyIndex]);
lcd.setCursor(0, 2);
lcd.print(F("Record "));
lcd.print(historyIndex + 1);
lcd.print(F(" of "));
lcd.print(historyCount);
lcd.setCursor(0, 3);
lcd.print(F("Browse then click"));
}
// ==================================================
// Identifier Functions
// ==================================================
bool identifierComplete() {
for (byte i = 0; i < SECTION_COUNT; i++) {
if (strlen(sections[i]) != sectionLengths[i]) {
return false;
}
}
return true;
}
void clearIdentifier() {
for (byte i = 0; i < SECTION_COUNT; i++) {
sections[i][0] = '\0';
}
selectedSection = 0;
historyIndex = -1;
Serial.println(F("Entire identifier cleared"));
updateDisplay();
}
// ==================================================
// History Functions
// ==================================================
void copyID(char *destination, const char *source) {
strncpy(destination, source, ID_BUFFER_SIZE - 1);
destination[ID_BUFFER_SIZE - 1] = '\0';
}
void addToHistory(const char *identifier) {
if (
historyCount > 0 && strcmp(digitizedHistory[historyCount - 1], identifier) == 0) {
return;
}
if (historyCount < MAX_HISTORY) {
copyID(digitizedHistory[historyCount], identifier);
historyCount++;
} else {
for (byte i = 0; i < MAX_HISTORY - 1; i++) {
copyID(digitizedHistory[i], digitizedHistory[i + 1]);
}
copyID(digitizedHistory[MAX_HISTORY - 1], identifier);
}
historyIndex = -1;
}
void showDigitizeError(
const __FlashStringHelper *lineOne,
const __FlashStringHelper *lineTwo) {
clearLCDRow(0);
clearLCDRow(1);
clearLCDRow(2);
clearLCDRow(3);
lcd.setCursor(0, 0);
lcd.print(lineOne);
lcd.setCursor(0, 1);
lcd.print(lineTwo);
delay(1500);
updateDisplay();
}
void digitizeIdentifier() {
if (!identifierComplete()) {
Serial.println(F("Cannot digitize: incomplete identifier"));
showDigitizeError(
F("Cannot digitize"),
F("Complete all fields"));
return;
}
if (!sdReady) {
Serial.println(F("SD card unavailable"));
showDigitizeError(
F("SD unavailable"),
F("Check SD wiring"));
return;
}
if (!rtcReady) {
Serial.println(F("RTC unavailable"));
showDigitizeError(
F("RTC unavailable"),
F("Check RTC wiring"));
return;
}
char finalID[ID_BUFFER_SIZE];
buildFinalID(finalID, sizeof(finalID));
// The first CSV date uses the collection year and January 1.
char logDate[11];
logDate[0] = sections[0][0];
logDate[1] = sections[0][1];
logDate[2] = sections[0][2];
logDate[3] = sections[0][3];
logDate[4] = '-';
logDate[5] = '0';
logDate[6] = '1';
logDate[7] = '-';
logDate[8] = '0';
logDate[9] = '1';
logDate[10] = '\0';
DateTime now = rtc.now();
char loggedAt[17];
snprintf_P(
loggedAt,
sizeof(loggedAt),
PSTR("%04d-%02d-%02d %d:%02d"),
now.year(),
now.month(),
now.day(),
now.hour(),
now.minute());
if (!slAppendRow(finalID, loggedAt)) {
Serial.println(F("SD logging failed"));
showDigitizeError(
F("SD logging failed"),
F("Check card/file"));
return;
}
addToHistory(finalID);
Serial.print(F("Successfully digitized: "));
Serial.println(finalID);
clearLCDRow(0);
clearLCDRow(1);
clearLCDRow(2);
clearLCDRow(3);
lcd.setCursor(0, 0);
lcd.print(F("Successfully"));
lcd.setCursor(0, 1);
lcd.print(F("digitized!"));
lcd.setCursor(0, 2);
lcd.print(finalID);
delay(1500);
updateDisplay();
}
void copyIdentifierSection(
byte section,
const char *identifier,
byte startPosition) {
byte length = sectionLengths[section];
memcpy(sections[section], identifier + startPosition, length);
sections[section][length] = '\0';
}
void selectHistoryEntry() {
if (historyIndex < 0 || historyIndex >= historyCount) {
return;
}
const char *selectedID = digitizedHistory[historyIndex];
copyIdentifierSection(0, selectedID, 0);
copyIdentifierSection(1, selectedID, 5);
copyIdentifierSection(2, selectedID, 10);
copyIdentifierSection(3, selectedID, 13);
copyIdentifierSection(4, selectedID, 16);
historyIndex = -1;
selectedSection = 0;
Serial.print(F("Selected history entry: "));
Serial.println(selectedID);
clearLCDRow(0);
clearLCDRow(1);
clearLCDRow(2);
clearLCDRow(3);
lcd.setCursor(0, 0);
lcd.print(F("History selected"));
lcd.setCursor(0, 1);
lcd.print(selectedID);
delay(1000);
updateDisplay();
}
void browseOlderHistory() {
if (historyCount == 0) {
return;
}
if (historyIndex < 0) {
historyIndex = historyCount - 1;
} else if (historyIndex > 0) {
historyIndex--;
}
displayHistory();
}
void browseNewerHistory() {
if (historyIndex < 0) {
return;
}
if (historyIndex < historyCount - 1) {
historyIndex++;
displayHistory();
} else {
historyIndex = -1;
updateDisplay();
}
}
// ==================================================
// Keypad
// ==================================================
void readKeypad() {
char key = keypad.getKey();
if (!key) {
return;
}
if (historyIndex >= 0) {
historyIndex = -1;
updateDisplay();
}
byte used = strlen(sections[selectedSection]);
if (key >= '0' && key <= '9') {
if (used < sectionLengths[selectedSection]) {
sections[selectedSection][used] = key;
sections[selectedSection][used + 1] = '\0';
updateDisplay();
}
} else if (key == '*') {
if (used > 0) {
sections[selectedSection][used - 1] = '\0';
updateDisplay();
}
} else if (key == '#') {
clearIdentifier();
}
}
// ==================================================
// Joystick
// ==================================================
void readJoystick() {
byte currentSwitchState = digitalRead(JOYSTICK_SW);
if (
currentSwitchState == LOW && lastJoystickSwitchState == HIGH) {
if (historyIndex >= 0) {
selectHistoryEntry();
} else {
digitizeIdentifier();
}
}
lastJoystickSwitchState = currentSwitchState;
int joystickX = analogRead(JOYSTICK_X);
int joystickY = analogRead(JOYSTICK_Y);
if (
joystickX > 400 && joystickX < 600 && joystickY > 400 && joystickY < 600) {
joystickReady = true;
}
if (!joystickReady) {
return;
}
if (joystickY < 300) {
browseOlderHistory();
joystickReady = false;
return;
}
if (joystickY > 700) {
browseNewerHistory();
joystickReady = false;
return;
}
if (joystickX < 300) {
historyIndex = -1;
if (selectedSection > 0) {
selectedSection--;
}
joystickReady = false;
updateDisplay();
return;
}
if (joystickX > 700) {
historyIndex = -1;
if (selectedSection < SECTION_COUNT - 1) {
selectedSection++;
}
joystickReady = false;
updateDisplay();
}
}
// ==================================================
// Main Loop
// ==================================================
void loop() {
readKeypad();
readJoystick();
}
SDLogFile.h:
#ifndef SD_LOG_FILE_H
#define SD_LOG_FILE_H
#include <Arduino.h>
#include <SPI.h>
#include <SD.h>
#define SL_FILE_NAME "ASDIGIT.CSV"
#define SL_HEADER "archivesspace_id,digitized_datetime"
inline bool slBegin(uint8_t csPin = 10) {
return SD.begin(csPin);
}
inline void slWriteField(File &file, const char *text) {
if (!text) {
return;
}
bool needsQuotes = false;
for (const char *character = text; *character; character++) {
if (
*character == ',' ||
*character == '"' ||
*character == '\r' ||
*character == '\n'
) {
needsQuotes = true;
break;
}
}
if (needsQuotes) {
file.write('"');
}
for (const char *character = text; *character; character++) {
char c = *character;
if (c == '\r' || c == '\n') {
c = ' ';
}
if (c == '"') {
file.write('"');
}
file.write(c);
}
if (needsQuotes) {
file.write('"');
}
}
inline bool slAppendRow(
const char *archivesSpaceID,
const char *digitizedDatetime
) {
if (
archivesSpaceID == NULL ||
archivesSpaceID[0] == '\0' ||
digitizedDatetime == NULL ||
digitizedDatetime[0] == '\0'
) {
return false;
}
File file = SD.open(SL_FILE_NAME, FILE_WRITE);
if (!file) {
return false;
}
uint32_t fileSize = file.size();
if (fileSize == 0) {
file.println(F(SL_HEADER));
}
else {
file.seek(fileSize - 1);
if (file.read() != '\n') {
file.println();
}
}
slWriteField(file, archivesSpaceID);
file.write(',');
slWriteField(file, digitizedDatetime);
file.println();
file.flush();
file.close();
return true;
}
#endif