Loading...
Loading...
// Grade Crossing System
#include <Servo.h>
#include <DFRobotDFPlayerMini.h>
#include <SoftwareSerial.h>
SoftwareSerial mp3Serial(10, 11);
DFRobotDFPlayerMini mp3;
Servo gate;
const int SENSOR_APPROACH = 2;
const int SENSOR_EXIT = 3;
const int LED1 = 4, LED2 = 5;
void setup() {
mp3Serial.begin(9600);
mp3.begin(mp3Serial);
gate.attach(9);
gate.write(90); // Gate up
}
void activateCrossing() {
mp3.play(1); // Bell sound
gate.write(0); // Lower gate
// Flash LEDs...
}This is starter code - modify and expand for your specific needs.
Before building this project, make sure you have the Arduino IDE installed and are comfortable uploading basic sketches to your board.
Most projects use standard Arduino libraries. Some may require additional libraries like AccelStepper, Servo, or NmraDcc - install these through the Arduino Library Manager.