A Fun IOT Arduino Crane
This is my Arduino Crain using a stepper motor with joystick control. In this tutorial all we will need to use is an Arduino. The ESP32 is optimal for whatever you want extra. So, lets jump right into it!
Supplies
Arduino uno
ESP32 (optional)
Stepper Moter + driver board
Joystick
String
Frame for crane
Wheel
Wiring
This is a fairly simple diagram of the wiring by: RAYANKIWAN63. Remember that the joysticks pins are not all used. If the GND on the joystick is loose, it will go haywire. If the VRY is loose then that does not provide a common ground between the Arduino and Crane, thus making it slowly but surely go haywire.
Shaft
Here is how the Moter and string are connected.
Code!
#include stepper.h
const int stepsPerRevolution = 2048; // change this to fit the number of steps per revolution
const int rolePerMinute = 15;
const int X_pin = 1; // analog pin connected to X output
Stepper myStepper(stepsPerRevolution, 2, 4, 3, 5);
void setup() { myStepper.setSpeed(rolePerMinute); //Serial.begin(9600);
}
void loop() {
// Serial.print("X-axis: ");
// Serial.println(analogRead(X_pin));
int a = analogRead(X_pin);
if (a > 400 && a < 520) {
for (int i = 2; i < 6; i++) { digitalWrite(i, LOW); } }
else if (a < 400)
{ myStepper.setSpeed(rolePerMinute);
myStepper.step(-30); }
else if (a > 530) { myStepper.setSpeed(rolePerMinute);
myStepper.step(30); }
}
ESP32
I added a tazer because you never know when some bad guys are going to try and steal something LOL.
Test
make sure that the Crain has a weel to prevent the string form going overboard. My frame was made out of metal, but a 3D printer should do the job. If the crane does not work, try adding some pulleys or reducing friction in some congested areas. Have fun and bye!