-
-
Save JosephGregg/a3c05dd6f6f883de456fbdd358486c40 to your computer and use it in GitHub Desktop.
const byte numChars = 32; | |
char receivedChars[numChars]; // an array to store the received data | |
boolean newData = false; | |
int dataNumber = 0; // new for this version | |
void setup() { | |
pinMode(5, OUTPUT); | |
pinMode(4, OUTPUT); | |
pinMode(0, OUTPUT); | |
pinMode(2, OUTPUT); | |
Serial.begin(115200); | |
Serial.println("<Pan/Tilt Controller>"); | |
Serial.println("Ready!"); | |
} | |
void loop() { | |
recvWithEndMarker(); | |
showNewNumber(); | |
} | |
void recvWithEndMarker() { | |
static byte ndx = 0; | |
char endMarker = '\n'; | |
char rc; | |
if (Serial.available() > 0) { | |
rc = Serial.read(); | |
if (rc != endMarker) { | |
receivedChars[ndx] = rc; | |
ndx++; | |
if (ndx >= numChars) { | |
ndx = numChars - 1; | |
} | |
} | |
else { | |
receivedChars[ndx] = '\0'; // terminate the string | |
ndx = 0; | |
newData = true; | |
} | |
} | |
} | |
void showNewNumber() { | |
if (newData == true) { | |
dataNumber = 0; | |
dataNumber = atoi(receivedChars); | |
if (dataNumber == 1) { | |
Serial.println("Received stop command"); | |
analogWrite(5, 0); | |
analogWrite(4, 0); | |
exit; | |
} | |
else if (dataNumber == 2) { | |
Serial.println("Received rotate left command"); | |
analogWrite(4, 1023); | |
digitalWrite(2, LOW); | |
delay(300); | |
analogWrite(4, 0); | |
} | |
else if (dataNumber == 3) { | |
Serial.println("Received rotate right command"); | |
analogWrite(4, 1023); | |
digitalWrite(2, HIGH); | |
delay(300); | |
analogWrite(4,0); | |
} | |
else if (dataNumber == 4) { | |
Serial.println("Received tilt back command"); | |
analogWrite(5, 1023); | |
digitalWrite(0, HIGH); | |
delay(300); | |
analogWrite(5,0); | |
} | |
else if (dataNumber == 5) { | |
Serial.println("Received tilt forward command"); | |
analogWrite(5, 1023); | |
digitalWrite(0, LOW); | |
delay(300); | |
analogWrite(5,0); | |
} | |
newData = false; | |
} | |
} |
I'm trying to figure out between this and https://hackaday.io/project/175096-hacking-yt-500-pan-tilt-head-radio-remote/details if this is possible to control using Pi or Arduino. Would you be able to provide more info?
Thanks in advance.
I've used a Raspberry Pi to control a YT-260. If you are comfortable using a soldering iron, it is quite easy to remove the brown RF PCB and attach some wires from the green main PCB to the Pi's GPIO.
The L911 motor driver used by the YT-260 can then be controlled directly from the Raspberry PI's 3.3V GPIO.
Before
After
@davidfurey This is amazing! I was starting to think I will need to use an Arduino together with an RPi.
Would you mind giving some more exact details on setting this up?
In the photograph you can see 5 orange wires that I've added to the PCB where the RF board was. The one at the very left (marked on the PCB with a box around it) is ground. The other 4 are up, down, left and right. I can't remember the order, but you'll find out quickly once you try them.
You just need to connect the ground wire to the Raspberry PI's ground, and the other 4 wires to any 4 GPIO on the Raspberry PI. Then program the Raspberry PI to set those GPIO as outputs, and set the appropriate pin HIGH when you want the YT-260 to move.
I had some success with using PWM to control the speed, setting the GPIO high for 50ms every 0.5s to move slowly, 100ms every 0.5s for medium and 200ms every 0.5s for fast.
Sometimes the YT-260 sticks slightly though, and the 50ms pulse isn't enough to make it move at all.
Thanks for the inspiration! I bought a YT-1000 from AliExpress for $70 because I needed the 1kg capacity for my project. It uses a completely different logic board than the one in the YT-260, but it also uses DC motors and separate H bridge controllers for each motor. The controllers are surface-mount CMOS chips (TC118SS), so that makes modifications a delicate operation! I chose to desolder the input pins and then bend them up so that I could wire them (and the pads) to a small board containing a quad CMOS OR gate (CD4071B). The OR gates allows me to control the base with an external controller (I'm using a Raspberry Pi 4) as well as the RF remote. There's a convenient empty spot in the bottom of the case for the board.
It's probably worth cross-referencing https://hackaday.io/project/175096-hacking-yt-500-pan-tilt-head-radio-remote
I'm planning to grab one of these to sit under the 5MPx camera that monitors my 3D printer, and now that this gist has illustrated how easy it is to break into the motor control I might investigate putting something like a Teensy inside so that pan/tilt could look like an HID device.
Thanks for the inspiration! I bought a YT-1000 from AliExpress for $70 because I needed the 1kg capacity for my project. It uses a completely different logic board than the one in the YT-260, but it also uses DC motors and separate H bridge controllers for each motor. The controllers are surface-mount CMOS chips (TC118SS), so that makes modifications a delicate operation! I chose to desolder the input pins and then bend them up so that I could wire them (and the pads) to a small board containing a quad CMOS OR gate (CD4071B). The OR gates allows me to control the base with an external controller (I'm using a Raspberry Pi 4) as well as the RF remote. There's a convenient empty spot in the bottom of the case for the board.
Can you share a bit more details here? I got one of those as well and want to control via esphome. Thanks!
Here's the schematic of the whole project. The wiring for the base is in the lower right. I desoldered two pins on each of the motor controller chips so that I could insert the OR gates. They aren't really necessary, I included them so that the buttons on the base and the remote would still work. If you don't care about that functionality, just connect your external controller directly to the motor controller pins after desoldering them and bending them up. Alternatively, you could find a place to cut the traces from the onboard controller to the motor controller chips then wire directly to the motor controller pins without desoldering. Sorry, I don't have any photos.
Thanks. This will do it. Excellent.
I forgot to mention the power switch. I used a germanium diode so that there would be no chance for the power switch on the base to damage the PIO driver on the Pi. Also, the 10k resistors are to prevent unintended activation and/or ESD damage.
Yep, that's the way I would do it now. I found this one not long after fully committing to the hardware-hacking approach: https://hackaday.io/project/175096-hacking-yt-500-pan-tilt-head-radio-remote/details
This looks really interesting. I'm considering getting a YT-260 to control using an Arduino or Pi. Have you written up anywhere how you got on with this? I can't tell from your code whether you modified the YT-260, took apart the remote control or something else. Any further info would be really helpful!