Skip to the content.

Automated Smart Bridge

The Automated Smart Bridge isn’t any normal bridge; it raises and lowers itself based off environmental conditions. When its sensors detects moisture, it displays a flood alert while simultaneously raising the bridge. The purpose of this bridge is to ensure that people can cross it safely during floody conditions.

Engineer School Area of Interest Grade
Logan W Irvine HS Structural Engineering Incoming Junior

IMG_9308 (1)

Final Milestone

Modifications

Challenges I Overcame

Future Iterations

First Milestone

Different Components

Challenges I Overcame

Future Iterations

Schematics

Grand Elzing-Maimu (1) IMG_6293 (1)

Code

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Servo.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET    -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

// Define Pins
const int ESTOP_PIN = 2;     
const int SERVO1_PIN = 4;    
const int SENSOR1_PIN = 5;   
const int LED_PIN = 6;       
const int SERVO2_PIN = 7;    // Servo 2
const int SENSOR2_PIN = 8;   

Servo servo1;
Servo servo2;

bool estopTriggered = false; 
unsigned long lastFlashTime = 0;
bool ledState = LOW;

void setup() {
  Serial.begin(9600);
  
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  
  display.clearDisplay();
  display.setTextColor(SSD1306_WHITE);
  display.setTextSize(2);
  
  pinMode(SENSOR1_PIN, INPUT);
  pinMode(SENSOR2_PIN, INPUT);
  pinMode(LED_PIN, OUTPUT);     
  pinMode(ESTOP_PIN, INPUT_PULLUP); 
  
  servo1.attach(SERVO1_PIN);
  servo2.attach(SERVO2_PIN);
  
  // STARTING POSITIONS
  servo1.write(0);    // Servo 1 starts at 0
  servo2.write(90);   // Servo 2 starts at 90 (its "closed" position)
  digitalWrite(LED_PIN, LOW);   
}

void loop() {
  if (digitalRead(ESTOP_PIN) == LOW) {
    estopTriggered = true;
  }

  display.clearDisplay();
  display.setCursor(0, 0);
  
  if (estopTriggered) {
    display.println("EMERGENCY\nSTOP!!!");
    display.display();
    
    // Snap back to safe/closed positions
    servo1.write(0);
    servo2.write(90); 
    digitalWrite(LED_PIN, HIGH); 
    
    while(true) {}
  }

  int s1 = digitalRead(SENSOR1_PIN);
  int s2 = digitalRead(SENSOR2_PIN);
  
  if (s1 == LOW || s2 == LOW) {
    display.println("FLOOD\nALERT!");
    display.display();
    
    // OPEN THE GATES
    servo1.write(90);  // Servo 1 rotates up to 90
    servo2.write(0);   // Servo 2 rotates down to 0 (which mirrors it!)
    
    if (millis() - lastFlashTime >= 200) {
      lastFlashTime = millis();
      ledState = !ledState;
      digitalWrite(LED_PIN, ledState);
    }
  } 
  else {
    display.println("Safe\nLevel");
    display.display();
    
    // KEEP GATES CLOSED
    servo1.write(0);
    servo2.write(90);
    digitalWrite(LED_PIN, LOW);
  }
  
  delay(50); 
}

Bill of Materials

Part Note Price Link
Arduino Uno Recieves inputs from Moisture Sensor and sends signals to the outputs $14.99 Link
OLED Module Displays Text $9.99 Link
Breadboard Allows for multiple wires to share a GND and 5V connection $7.89 Link
Micro Servo Raises and lowers the bridge $9.88 Link
Female Jumper Wires Connects Moisture Sensor, OLED, and LED to the Arduino $3.99 Link
Male Jumper Wires Connects the Servo and Red Button to the Arduino $3.99 Link
Soil Moisture Sensor Detects Water $12.99 Link
Red Button E-Stops the Bridge $8.99 Link
Red LED Alarm $5.99 Link
Cardboard Structure of the Bridge $24.99 Link
Construction Paper Road $5.38 Link
Battery Pack Supplys Extra Power $8.39 Link

Resources

Schematic Maker

Example Project

Code Maker

Arduino Programmer