After some investigation, I've decided to use servos to change the alignment of some of the turnouts on my model railroad. I've also decided to use an Arduino to drive the servos. And I know that the Uno is capable of controlling 14 servos but if I want LED indication of the track set at the turnout, it requires at least 3 pins for each servo. That limits things greatly.
Then I discovered the PCA9685 which can drive 16 servos via SDA and SCL. Tom's Train and Things has a sketch showing this. In his sketch, he uses a button and a 3-way LED, which he connects to the Uno. I've modified his sketch to use a toggle switch and I've come up with a circuit in which only 1 pin of the Uno is required for each servo. Which means I can drive 16 servos with just 1 Arduino Uno. This is great. But now comes my challenge.
In Tom's sketch, he uses the pulse to limit the throw of the servo. This means that the servo goes from one side to the other almost instantaneously. That's not very prototypical. I'd like to slow the movement of the servo so that it sweeps from one side to the other, thereby opening or closing the turnout in a more realistic manner.
My programming days are long gone and it was in Basic and Cobol, casually! So the syntax of C++ leaves me confused at times.
Can some here look at my sketch and enlighten me? I'd copy my sketch here but I'm not sure the best way of copying and not loosing the formatting.
Thanks
David
Can some here look at my sketch and enlighten me? I'd copy my sketch here but I'm not sure the best way of copying and not loosing the formatting.
1. Select the code to be posted in the Arduino IDE.
2. Right-click on the selected code and choose "Copy as HTML" from the pop-up menu.
3. Then in the forum editor window choose the source code icon {:} at the top of the editor.
4. Paste the HTML code into the pop-up window and select ok.
5. You can then select "Preview" at the bottom of the post editor to see exactly how the code will appear when posted.
This method preserves both the alignment and the color formatting of the Arduino code.
DroneBot Workshop Robotics Engineer
James
After some investigation, I've decided to use servos to change the alignment of some of the turnouts on my model railroad. I've also decided to use an Arduino to drive the servos. And I know that the Uno is capable of controlling 14 servos but if I want LED indication of the track set at the turnout, it requires at least 3 pins for each servo. That limits things greatly.
Then I discovered the PCA9685 which can drive 16 servos via SDA and SCL. Tom's Train and Things has a sketch showing this. In his sketch, he uses a button and a 3-way LED, which he connects to the Uno. I've modified his sketch to use a toggle switch and I've come up with a circuit in which only 1 pin of the Uno is required for each servo. Which means I can drive 16 servos with just 1 Arduino Uno. This is great. But now comes my challenge.
In Tom's sketch, he uses the pulse to limit the throw of the servo. This means that the servo goes from one side to the other almost instantaneously. That's not very prototypical. I'd like to slow the movement of the servo so that it sweeps from one side to the other, thereby opening or closing the turnout in a more realistic manner.
My programming days are long gone and it was in Basic and Cobol, casually! So the syntax of C++ leaves me confused at times.
Can some here look at my sketch and enlighten me? I'd copy my sketch here but I'm not sure the best way of copying and not loosing the formatting.
Thanks
Hi, I also went with Toms Trains sketch and modified to operate 16 sets of points on my Model Railway build..
John
David