Introduction: A 3d Printed Bridge With Arduino

This is a bridge that me and my friend made with the help of 3d printing and Arduino.

Supplies

For supplies we used a 3d printer with alot of printing plastic, Autodesk inventor professional 2023.

9v battery, 6v battery, arduino, step motor 28BYJ-48 and the basic arduino stuff.

Step 1: The Files

copy these files into your 3d printer. You will need to have six copies of "cirkel för tråd.stl" to properly have everything

Step 2: The Code

. print this piece of code into arduino.

//Include the Arduino stepper library
#include <Stepper.h>

//Define an input pin
int buttonPressPin = 7;

// Define a boolean indicating direction of the bridge.
bool raising;

//Define a Boolean to track a button press
bool buttonPressed;

//Set how many steps it takes to make a full revolution. Divide the degrees per step by 360 to get the steps
const int stepsPerRevolution = 2048;

//Use pin 8-11 on the arduino to IN1-IN4 on the stepper board
//Setting up the stepper
Stepper stepperName = Stepper(stepsPerRevolution, 8, 10, 9, 11);

void setup() {

//Set the RPM of the stepper motor
stepperName.setSpeed(10);

//Set the pinMode of our button pin
pinMode(buttonPressPin, INPUT_PULLUP);

// Set default direction to not raising
raising = false;
//Set our button press Boolean to a known value
buttonPressed = false;

}
void loop() {
// Keep previous button state.
bool wasPressed = buttonPressed;

//Checking the state of the button pin and saving it in our Boolean
buttonPressed = digitalRead(buttonPressPin);

//Checking the previous
if (buttonPressed && !wasPressed) {
raising = !raising;
}
//If the button is pressed then depending on the last buttonpress the bridge will either rise or fall
if (buttonPressed == true) {
if (raising == false) {
stepperName.step(-stepsPerRevolution / 180);
}
else{
stepperName.step(stepsPerRevolution / 180);
}

}
}

Step 3: Assemble

assemble the 3d printed pieces and screw down the pieces that need to be screwed down

Step 4: Arduino

make circuits for the arduino

Step 5: Turn It On

(you can make your own changes if felt necesery)