Hello, and welcome to this project, it’s a self-propelled LASER turret, RC LASER Tank… I don’t know its name yet :D. So this project is very simple, it’s a remote controlled tank chassis with a remote controlled LASER turret and you can activate the LASER remotely too.
So this project combines different things I did before, make sure to check on them if you’re having a problem:
- Interfacing Wireless PS2 Controller with Arduino
- Step by step on how to use the L298n dual H-bridge driver with Arduino
- Control dual axis FPV camera cradle with Joystick module
- Arduino KY-008 LASER module
For this project we gonna need a motorized chassis, the usual 2 WD / 4 WD robot chassis, or anything you have in hand… This one is a tank chassis with 2 tracks driven by 2 DC motors.
To control the Motors we have a dual H-bridge DC motor driver, I’m using the L298n, it’s powered by a 7.4V Lithium battery through it’s +12v pin, and also this module provides power to the Arduino board and the servos thanks to its 5v output.
Then we have the FPV camera cradle, it’s just that acrylic frame with two servo motors that we control.
On that I placed a LASER module
PS2X wireless remote controller with its receiver
All these controlled with Arduino board I’m using UNO as usual
And an Arc Reactor for power
That’s pretty much my wiring, Don’t forget the L298n has a 7.4V Li battery on it’s +12V/GND pins, which powers all the things, you can use 9v battery if you want.
For the LASER so you won’t be confused, actually the LASER needs two pins, GND and a pin that can provide 5V voltage, so here in the wiring schematic I could have wired the (-) pin with GND but I prefered to do as written in the Code, I wired the (-) pin with an Analog pin and put it to LOW level, instead of using a breadboard or some other dodgy thing (And you know I’m not very handy)… You can use what you want just it should be grounded, and the other Analog pin is now acting like a Digital Output and it sets High or LOW to activate the LASER
For the PS2 Receiver, it has 9 pins and we used (1,2,6,7) for data and (4,5) for power, the gray square are not connected.
The only libraries we’re using are:
- Servo library which is already installed
- PS2X Library: Download here
You can download the code here in .ino format.
For some part of the code I’m gonna explain them bellow:
Those lines are for the LASER, (-) pin on A0 and (S) on (A1), so we declare them as outputs and put the A0 to low constantly to act as our GND.
a and b, constantly reading the servos current positions and we increment or decrement (other part of code). Stop() is always active as long as no stick are moved.
Then if « X » is press, the vibrate variable takes a value, wich makes the controller vibrate, and the same value is on the A1 pin, normaly the vibrate value is analog but you know there’s a threshold for analog signals to be considered as LOW or HIGH digital Level, and so the Laser turn on everytime we press the « X » button.
In an other part of the code the Arduino is constantly listening for new signals, and we did some math to make the value of the left analog stick to go from 130 to 255 for up (forward).
and 120 to 0 for down (backward).
So here we adapted this signal received from 130 – 255 to 0 – 255 which is proportionnal on how you push the stick and we adapted the signal so it can be written as PWM signal on the speed pin as we know the speed is controlled by a value from 0-255.
Same thing I did for Backward, and for Left and Right I just turn off one motor to make it turn in a certain direction, for the HIGH/LOW values it depends on your system you may swap them or swap your wiring…
Electronics, Automation engineering student... I try to share my little experience with other electronics amateur.