Hello, Im designing and creating a Sam turret out of the game call of duty modern warfare 3. I’m doing this because I find a good challenge for myself to design and make the electronic components work.
so far I have designed everything from a few pictures I took in game. Its now fully 3D printed and im working on the electronics, my plan is to use and PS4 controller and an ESP32 to control the stepper motors and other electronics. I know my way around soldering and wiring but im still learning about a lot of things like coding, resistors, capacitors all the smaller things...
Im happy to share my project and if there are tips on how I can make it better there welcome.
Cool project!
First thing I would say is don't use L293 for stepper motors, but something A4988 or TMC2209. I assume your stepper motors are NEMA 17 size or smaller.
I would start off by wiring up one stepper motor, then using the AccelStepper library to move it.
Im using 2 motors to turn on Y axis because the payload is heavy and I think 1 won't cut it. also got 1 in de bottom to turn on Z axis using a planetary gear system.
For the sound Ill probably add sounds if I have everything working.
Thanks,
Alright I'll look into the motor drives. Im not sure if these are NEMA 17, I am using them from my old 3D printer (Ender 3).
thanks for the tip.
Any idea how I would Implement this?
This will not get you HiFi-stereo-surround-sound, but with the talent you show, you will find improvements...
This guy on YouTube is worth watching all five years of five minute Arduino videos...
This video starts the three-part series on DFplayerMini... (click "more" to find "link to code")
If you have an ESP32, DroneBotWorkshop has a more ear-pleasing solution... then pipes it into an audio amp..
So I upgraded to TMC2208 instead of the L298N motor drives. I think I have wired everything correct.
The problem that I have now I can see in the serial plotter the joystick move left and right but the servo isn't turning when I do this.
Maybe I need new stepper motors, or recheck my wiring, or it is something else any help is welcome.
Here is the code:
#include <PS4Controller.h>
#include <Stepper.h>
// Define stepper motor control pins
#define DIR_PIN 25
#define STEP_PIN 32
#define ENABLE_PIN 33
// Define stepper motor parameters
const int stepsPerRevolution = 200; // Adjust as per your stepper motor's specification
Stepper myStepper(stepsPerRevolution, DIR_PIN, STEP_PIN);
// PS4 Controller MAC Address
const char* ps4_mac = "00:1A:2B:3C:4D:5E";
void setup() {
Serial.begin(115200);
// Initialize PS4 controller
PS4.begin(ps4_mac);
if(!PS4.isConnected()){
Serial.println("PS4 controller not connected!");
}
// Initialize stepper motor
pinMode(ENABLE_PIN, OUTPUT);
digitalWrite(ENABLE_PIN, LOW); // Enable the motor
myStepper.setSpeed(100); // Set initial speed in RPM
}
void loop() {
if(PS4.isConnected()){
int joystickValue = PS4.data.analog.stick.lx;
Serial.print("Joystick Value: ");
Serial.println(joystickValue);
if(joystickValue > 10) { // Joystick moved right
Serial.println("Turning Right");
digitalWrite(DIR_PIN, HIGH);
myStepper.step(stepsPerRevolution / 200);
} else if(joystickValue < -10) { // Joystick moved left
Serial.println("Turning Left");
digitalWrite(DIR_PIN, LOW);
myStepper.step(stepsPerRevolution / 200);
}
}
delay(0); // Reduced delay for better responsiveness
}
What do you see for "Joystick Value"? That is to say, are you printing X or Y or SEL?
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.