wirecraft

Adventure · Arduino Uno

Secret Badge Chest

A Arduino Uno build with 4 components. Reads: RFID. Drives: Servo, LED, Buzzer. When a card is presented, chirp and swing the latch open.

4 parts · 11 connections · 9 steps

Wiring

Mini Map
power
ground
data
signal
analog

Parts

PartRefsQtyEst.
RC522 RFID reader (SPI)RFID1$2.90
SG90 micro servoServo1$2.40
LED (5 mm) + 220 Ω resistorLED1$0.15
Passive piezo buzzerBuzzer1$0.60
Plus: breadboard, jumper wires, USB cable≈ $6.05

Prices are rough hobby-market estimates. Click a part for wiring notes and specs.

Firmware

src/main.cpp
1// RFID Lock
2// Generated by Wirecraft for the Arduino Uno (ATmega328P)
3// Prompt: An RFID treasure chest that unlocks a servo latch and chirps when the right card is presented
4//
5// Wiring, parts and step-by-step assembly live alongside this file.
6
7#include <Arduino.h>
8#include <SPI.h>
9#include <MFRC522.h>
10#include <Servo.h>
11
12#define RFID_SS 2
13#define RFID_RST 3
14#define SERVO_PIN 5
15#define LED_PIN 4
16#define BUZZER_PIN 6
17
18MFRC522 rFID(RFID_SS, RFID_RST);
19bool rFIDCardPresent = false;
20Servo servo;
21
22void setup() {
23 Serial.begin(115200);
24 SPI.begin();
25 rFID.PCD_Init();
26 servo.attach(SERVO_PIN);
27 servo.write(0);
28 pinMode(LED_PIN, OUTPUT);
29 pinMode(BUZZER_PIN, OUTPUT);
30 Serial.println(F("RFID Lock ready."));
31}
32
33void loop() {
34 // --- Read sensors ---
35 rFIDCardPresent = rFID.PICC_IsNewCardPresent() && rFID.PICC_ReadCardSerial();
36
37 // --- React ---
38 // When a card is presented, chirp and swing the latch open.
39 if (rFIDCardPresent) {
40 servo.write(90);
41 } else {
42 servo.write(0);
43 }
44
45 delay(50);
46}
47
platformio.ini
1; PlatformIO project for RFID Lock
2[env:uno]
3platform = atmelavr
4board = uno
5framework = arduino
6monitor_speed = 115200
7lib_deps =
8 miguelbalboa/MFRC522@^1.4.11
9 arduino-libraries/Servo@^1.2.1
10

Assembly

  1. 1

    Lay out your workbench

    Gather the Arduino Uno, a half-size breadboard, and a bundle of male-to-male jumper wires. Keep the parts list open — every component below gets its own spot on the breadboard. Don't plug in USB power until the last wire is placed.

  2. 2

    Seat the board and power rails

    Run a red jumper from the Arduino Uno's 3V3 (or 5V for 5 V parts) pin to the breadboard's + rail, and a black jumper from GND to the − rail. Every component's power and ground will tap these rails.

  3. 3

    Wire the RFID

    Place the RC522 RFID reader (SPI) on the breadboard. Power first: VCC → + rail, GND → − rail. Then signals: SDA → D2, RST → D3. Tip: SPI pins (SCK/MOSI/MISO) go to the board's hardware SPI header — the diagram labels the two that vary.

  4. 4

    Wire the Servo

    Place the SG90 micro servo on the breadboard. Power first: VCC → + rail, GND → − rail. Then signals: SIG → D5. Tip: Servos are power-hungry. For more than one, feed them from a separate 5 V supply and share GND.

  5. 5

    Wire the LED

    Place the LED (5 mm) + 220 Ω resistor on the breadboard. Power first: CATHODE → − rail. Then signals: ANODE → D4. Tip: The longer leg is the anode (+). The resistor can go on either leg.

  6. 6

    Wire the Buzzer

    Place the Passive piezo buzzer on the breadboard. Power first: GND → − rail. Then signals: SIG → D6. Tip: Passive buzzers need tone(); active ones just want HIGH. This design assumes passive.

  7. 7

    Double-check before power

    Trace every wire against the diagram once more — 11 connections in total. The classic mistakes: swapped power and ground, and off-by-one rows on the breadboard. Thirty seconds of checking saves a component.

  8. 8

    Flash the firmware

    Open the exported folder in VS Code with the PlatformIO extension (free), plug in the Arduino Uno over USB, and hit Upload. PlatformIO fetches the libraries listed in platformio.ini automatically. Prefer the Arduino IDE? Copy src/main.cpp into a new sketch and install the same libraries from the Library Manager.

  9. 9

    Bring it to life

    Open the Serial Monitor at 115200 baud to watch live readings. When a card is presented, chirp and swing the latch open. Adjust the thresholds at the top of the sketch to match your environment.