I have tried to find and or modify a sketch for my turnouts that uses 6 push buttons to operate 6 servos.
I would also like to connect my Arduino Mega through an interface module to the DIgitrax Loconet . Because of my limited knowledge of Arduino coding and unable to learn coding, I would be most grateful if someone could help me to develop this turnout control system. Regards, Wally
Hi Wally,
Please show your attempts so far.
have you looked at LocoNet - Arduino Reference
You cannot expect forum members to write code for you for free. They will give you unlimited free help if you are prepared to learn to code.
If you want, I can move your topic to a forum section where you can offer payment for others to write code for you. If you do that, take great care with your money, there may be those on the forum who will take your money with no intention of writing any code for you, and others who should not be taking your money because they don't have the necessary skills and experience, they only think they do.
I don't believe that you are
it might be that you don't like learning coding.
But that you are unable ??? no way!
Well you have to make a fundamental decision:
deciding for A:
investing enough money to buy whatever pre-programmed original loconet-products that fullfil your not yet mentioned requirements
deciding for B:
taking the effort of finding a person that
- you can trust to be able to be fair in calculating programming hours realistic, -
- has enough knowledge to really can do the job
deciding for C:
posting your not yet working code combined with a specific question about a certain detail.
You can repeat this method of:
- posting your not yet working code combined with a specific question
hundreds of times.
- as long as it is recognisable that you put some own effort into it, you will get answer after answer
even hundreds of times.
In this way you will get a to your needs taylored special how to write code for loconet tutorial that is developing over time.
This is the programming questions subforum sorted by number of replies
As you can see there are threads with more than 100, 200, 300 replies
That is the way how this forum works.
So just start asking questions.
best regards Stefan
Hello Greatnorthern
Do you have an interface requirement specification of am interface available.
As a start the arduino documentation
links to this webiste
https://mrrwa.org/loconet-interface/
that shows a professional and a prototype interface
and this website links to a loconet-code
http://www.spcoast.com/pages/LoconetLayoutControlPanel.html
@Greatnorthern :
if you look into this code and you know yet almost nothing about programming I can understand very good that this seems to be very complicated.
No it isn't complicated ! It is 20 to 50 hours of learning basic things about programming. Starting with much easier to understand code-examples.
So as I already said:
make a fundamental decision between
A: waiting 2 to 12 weeks spending as less money as possible for daily life to have the money to buy professional loconet-products.
B: taking 20 to 50 hours to learn the basics of programming and then be able to ask specific questions about how to adapt the above linked code.
best regards Stefan
Thanks for your comment. I am a pensioner, 80 years old and have difficulty trying to learn how to write code. Thanks for your help and understanding, Regards, Wally.
Loconet Interface.pdf (236.6 KB)
Thank you for your reply. I have attached loconet interface that I am using. I have some sketches but don't know how to include the loconet/interface into the sketch. I have attached a copy of the sketch. Regards.
# include <Servo.h>
Servo pointServo[6];
byte servoPin[] = { 2, 3, 4, 5, 6, 7, }; // pin numbers for servo signals
byte switchPin[] = { 8, 9, 10, 11, 12, 13 }; // pin numbers for switch connections
// Uno analog pins A5 A4 A3 A2 A1 A0
byte servoLowPos[] = { 50, 60, 60, 60, 60, 50, }; // degrees for low servo position
byte servoHighPos[] = {160, 140, 160, 170, 150, 160,}; // degrees for high servo position
byte servoPos[6];
void setup() {
Serial.begin (9600);
setupSwitches();
setupServos();
}
void loop() {
for (byte n = 0; n < 6; n++) {
boolean servoMove = false;
byte sw = digitalRead(switchPin[n]);
if (sw == HIGH) {
while (servoPos[n] != servoLowPos[n]) {
servoPos[n] -= 1;
pointServo[n].write(servoPos[n]);
delay(10);
}
}
if (sw == LOW) {
while (servoPos[n] != servoHighPos[n]) {
servoPos[n] += 1;
pointServo[n].write(servoPos[n]);
delay(10);
}
}
if (servoMove) { // only move the servo if the switch has changed
pointServo[n].write(servoPos[n]);
}
}
}
void setupServos() {
// set servos to correct position PRIOR to servo.attach()
for (byte n = 0; n < 6; n++) {
if (HIGH == digitalRead(switchPin[n]))
servoPos[n] = servoLowPos[n];
else
servoPos[n] = servoHighPos[n];
pointServo[n].write(servoPos[n]);
}
// start creating the servo-signals (right from the START with the correct position)
for (byte n = 0; n < 6; n++) {
pointServo[n].attach(servoPin[n]);
}
}
void setupSwitches() {
for (byte n = 0; n < 6; n++) {
pinMode(switchPin[n], INPUT_PULLUP);
}
}
The most important thing is that you make an
OWN ATTEMPT with at least TRYING it.
regardless if the attempt does compile or not.
If you don't want to do that.
Have you done a internet-resarch about loconet-users?
Especially me I want to see some own effort from you .
And this effort shall go beyond writing
If you have taken some randomly chosen video-tutorial there is a 95% chance that this tutorial was bad and difficult to understand.
If you have taken some randomly chosen website that claims to explain coding there is a 95% chance that this tutorial was bad and difficult to understand.
I claim if you test multiple tutorials that you will find one that is understandable.
If you don't want to do that. How about asking in your area where you were living in if there is a so called fab-lab to find a person that is living near to you so you can meet personally with this person to learn coding?
best regards Stefan
Hello Greatnorthern
Thank you very much for your answer.
The supplied code controls the turnouts via servos.
In order to be able to carry out remote-controlled turnout operation, the message interpreter for the "DIgitrax Loconet" messages is missing.
For this, a serial interface must be set up on the Arduino and the above-mentioned interpreter must be running.
There are two possibilities:
- search the internet for an interpreter and integrate it into the programme.
or - write it yourself and learn a little.
I think both ways are interesting and will be a lot of fun.
Up to you.
Have a nice day and enjoy coding in C++.
Here is an example-code for this
http://www.spcoast.com/pages/LoconetLayoutControlPanel.html
why the shouting ?...
What do you want Loconet to do with your Mega?
What's the very simplest thing you can do to get started (and test your connection circuitry)?
It is about the 5th or 6th time that I emphasized "show more own effort"
at your 3rd post in this thread ? ![]()
My view : say it once (or twice max)... if OP answers and tells you he can't because of his age or some personal challenges he does not want to get into, then "shouting" will not get your point across any better...
We had some PMs and there is another thread with the same problem of not showing enough effort.
My way of reacting is writing big bolded letters. If this does not help either I agree. Move on to a different thread where the TO shows some own effort.
it's not just a one on one conversation - we basically all see you "shouting" and it's not cool to be in a discussion like that.
OK what do you suggest as a better way to emphasize on a certain aspect?
Congratulations!
The TO has left the building.
Once again a member has been driven out of the forum.
