Hey everyone! If you are having trouble with an error not being declared. Try pasting the sketch into a basic text editor that every computer comes with then copy it from there. Sometimes phantom characters can be brought in from a simple copy paste.
@wayneburling3157
3 жыл бұрын
Tried this and it still will not verify error is "redefinition of 'int sensePin1' "
@tomg3855
Жыл бұрын
Thank you thank you thank you! Not only am I learning how to code, but I have a better understanding of how I can control my trains. I am really thrilled with the signal block layout. Fantastic. I only have two small suggestions, one is move your microphone away from your keyboard. Your microphone has great bass and so do the speakers in my office. Your typing really bumps the bass even when I turn my sub off. My other suggestion would be to kill off the "music". I was a musician so I am really into music. After I am done watching one of your tutorials, that "music" makes me feel like I'm going insane. I can't learn without listening to you but I can't listen to you without the "music". It just keeps repeating as you know, and repeats and repeats and repeats.... you get my point. You should do a survey to see how people feel about the "music". Opening and closing music would be okay, really.
@JoeG-firehousewhiskey
6 жыл бұрын
This is an awesome video, thank you for publishing it for all of the community.
@DIYDigitalRailroad
6 жыл бұрын
Thank you! I really enjoy making these videos!
@tomcarr1050
6 жыл бұрын
ty Jimmy for another great arduino lesson...keep em coming Tom
@DIYDigitalRailroad
6 жыл бұрын
Thank you!
@banglacaterer8219
5 жыл бұрын
brother...very nicely described took pain to type all sketch and uploaded for us to make it use thak you so so much and god bless you ...
@randybryson5519
6 жыл бұрын
Thank you for the video. I'm just getting into the Arduino and look forward to using with my N Scale layout.
@DIYDigitalRailroad
6 жыл бұрын
Thanks for watching! Make sure that you check out part 2 where I take some viewer suggestions and use them to improve the code.
@dukesnyder3607
5 жыл бұрын
Very good, THANK YOU!!!
@KevinSmith-dx6xq
5 жыл бұрын
I suggest that you use #define for your pin names. #define RED1 6 #define RED2 5 You could also #define an led on/off #define ledON LOW #define ledOFF HIGH Then turning leds on becomes digitalWrite(RED1,ledON); I would also rename the state names in a way that reminds you of the logic of each state. enum CrossingSTATE { ST_OFF, ST_WESTBOUND, ST_EASTBOUND, ST_CLEARING_GATE }; I hope this helps. I'm enjoying the series.
@RocktCityTim
6 жыл бұрын
Love these. I would ask one thing - please use red and black (or white) jumpers consistently for your power connections. A bit OCD, but this can further assist new makers to understand the devices and the signals as they are configured on the breadboard.
@DIYDigitalRailroad
6 жыл бұрын
That's a great suggestion! I am trying to figure out the easiest way to make a diagram of the circuit too.
@cadillacescalade5428
2 жыл бұрын
Coding is great, I built one with crossing bells that trigger on sencer 1 an end on sencer 2 an clears when gates raise an led still flashing till gate is fully up. And also sencers are active either direction is like the real thing. Really kool.
@LawrenceEggering
5 жыл бұрын
This is very well done. I have an Arduino sensor sketch I may try to combine with this. '
@apocalypserailroad9047
4 жыл бұрын
What would be awesome, is an actual scale operating crossing signal system!! I have yet to find anything that can do it, either DIY or commercially!!! It appears to me that the logic of the actual railroad system takes into account how fast a train is moving as to when the signals will activate. Also, as the train approaches, the signals continue to flash, but if the train stops anywhere before the actual crossing and sits for a few seconds or starts backing away, the signals will stop flashing until movement is again detected as an "approach". If the train backs away, the signals will not start flashing again. One last thing, if the train is detected anywhere over the crossing area, the signals will continue to flash, even if the train stops, until it is no longer over the crossing area. Hopefully all that made sense. :) This system would have to use a resistance based system as apposed to infrared. Would you be interested in attempting to figure this out? I'd be willing to donate to the cause!
@cadillacescalade5428
2 жыл бұрын
I have built one that's just like like...you can check out my newest video on my page For Jakks Pacific Power Trains
@rhtservicesllc
2 жыл бұрын
I have reviewed the code that you posted on Github for this. I saw there are some ways that it can be improved so that the separate flasher device does not have to be used. Also can simplify by writing the light flasher code only once in the sketch instead of multiple times in the sketch.
@sparkslightingable
6 жыл бұрын
In the future could you change the resolution on your monitor while writing the sketch so it's easier to follow. Thanks
@chriswisselo4329
5 жыл бұрын
Instead of using the sensor to turn on/ off, I would just use them to keep the signals going as long as they are 'tripped'. Turn them off automatically after a few seconds automatically. This way you avoid having to adjust the position of your sensor to the (max) length of your trains. You'd still need two sensors, one for each direction. You could possibly add a 3rd IR sensor in the track right at the crossing. As long as that one is active, the counter of the two 'entering' would not start. In case your train has to stop for a red signal and the tail is still on the grade crossing. Would it be possible to do this with reed switches though? They are a lot easier to hide under the track. Just glue a small magnet under the rolling stock? Love your videos, well explained. A great source of inspiration.
@ChristopherMardell
5 жыл бұрын
Great video! I'm a little new to this, but wondering if you can just run two outputs to the LEDs, connect the diodes in parallel and flip the polarity of the outputs to change which one is lit? I.e. If both are LOW it's off, LOW/HIGH lights one and HIGH/LOW lights the other?
@justrandomcarsurbex3057
5 жыл бұрын
Cool, i built a H0 crossing my self with arduino, you can see it on my channel. Im not really into train modelling as mutch anymore but still love to make this small projects and a small diorama to fit it on to👍
@seanpepple6110
5 жыл бұрын
love your videos do you know if its possible to hook up a crossing bell sound module to this setup by chance thanks
@jackhattingh8814
4 жыл бұрын
Hi Jimmy how difficult will it be to add 2 servos for gates, please?
@larrydayhoff999
4 жыл бұрын
I would sure like to see this for a double track main.
@cadillacescalade5428
2 жыл бұрын
I have a set up code for double track set up and for either direction. 4 ir sensors also bells clear after the train clears then gates raise lights clear along with gate lights and sound
@w.rustylane5650
4 жыл бұрын
I've been looking for this for some time. I want my Arduino board to control my crossbucks. However, I already have a flasher unit, I just want the Arduino board to sense the train and turn on the flasher. After the train passes I want the Arduino board to turn off the flasher to the crossbucks. And for it to do the same thing in the opposite direction. I've already built a flasher circuit powered by a bread board power supply but it takes a press of the switch to activate.
@uniteddrones7626
4 жыл бұрын
So if I have the sensors 6inches away from the grade crossing either side. What if my train is long and the engine hits the next sensor while the grade is still being crossed. Does the first sensor cancel out the second one if a train is still crossing over or would you need to move these sensors further apart
@JohnCrellin
4 жыл бұрын
do you have a video showing installing the sensors under the track??
@frankneher9192
5 жыл бұрын
you could add a potentiometer To change the value for the light.
@jackhattingh8814
4 жыл бұрын
Hi Jimmy , I have a stupid question! Where is the link to the description to get a copy of the sketch? I cannot wait to try this program on my train set.Please keep up the good work! Thanks
@microplumb
2 жыл бұрын
HI , it's very interesting. THanks Do you have same with gate control by servo or other motor... thanks again
@cmotdibbler4454
5 жыл бұрын
Hi, Love the tutorial, I am just looking to get into model railways so this is awesome inspiration. Just a thought, could you not use a Arduino Pro Micro as the controller to make it even more streamlined/low profile and cheaper?
@paulvincent9744
5 жыл бұрын
Will work well with Arduino Pro Micro
@cdevidal
5 жыл бұрын
I tried to build exactly this when I was a twelve year old kid. Did not succeed. So it’s cool to see this project.
@DIYDigitalRailroad
5 жыл бұрын
Cool!
@eugentakacs6766
4 жыл бұрын
Hi Jimy, I am new to Arduino, but experienced in Assembler. I am learning on your excellent tutorials. Until this one (4th in row) everything was working but this code cannot be compiled: Iam getting always the same errors does not matter if this is my typed code upon your video or copy your code. Crossingor:40:35: error: 'crossingflashing1' was not declared in this scope The same error is on all these crossing.... things. Any idea what to change? Thank you! crossingflashing1(valA1, valA2);
@normpetherbridge3039
4 ай бұрын
Really have enjoyed your content. Started using Arduinos for Model Railroad panel projects about 3 years ago. My question, especially with respect to the crossing signal sketch, is your use, for the Leds, of the positive lead as the common rather than the negative lead as I have seen in most sketches. In the Crossing sketch, you have Pin 8 as the "Power" and set it HIGH. And throughout the sketch it stays HIGH (never set LOW). Could the positive leads just be connected to the 5V from the Arduino rather than use a Digital Pin? And secondly, is there some advantage to having the Positive side of the Leds as a common? I have noted that this is the same practise as is used in decoders (i.e. the blue - positive wire) is the common). Thanks for helping me with many interesting projects.
@jackhattingh8814
4 жыл бұрын
I am not too clued up on Arduino programming as I cannot get this sketch to function. It shows an error in the line (enum CROSSINGSTATES) which i cannot fix. The error statement reads "use of enum CROSSINGSTATES without previous declaration". Please help!
@robertneglia1135
4 жыл бұрын
I am only just starting to get into arduino but what i would like is to see this connected on a layout just to see how the wires connect and not on a breadboard. Thanks
@l.rod2827
Жыл бұрын
Good video tutorial. I did the prototypical assembly and it worked like a champ, but when I installed the Arduino and grade crossing it didn't work well. My issue is that I'm using this code on a dual track grade crossing. Hence I have two IR sensors per approach (4 total) two upstream. The IR outputs are placed together utilizing and isolated with a 1N5819 diode so each IR output signal wont back feed into the other IR sensor and the same for the other side. My problem is the grade crossing flashers wont come on till both IR sensors are tripped and then the flasher wont turn off until the other two IR sensors are engaged. I noticed that the IR sensors LED flickers fairly quickly when the trains go by (never solid) Can I change the code to reflect a A1 A2 to 250 instead of the 500? or should separate each sensor and and add A3 and A4 to the code?
@hotrodsamson
5 жыл бұрын
Can this be set up with the flashing lights and also a crossing drop arm controlled all the Arduino?
@chriswisselo4329
5 жыл бұрын
Sure it can. You just need two servo's and you quite a lot more wiring. You can also add a sound module that sounds the bells. You can make it as fancy as you'd like.
@redwoodcityintheuknscalera7179
5 жыл бұрын
yes i have a question if you have two tracks on your crossing and trains running in two directions can this circuit still work obviously you would need 4 sensors but how to code this with 4 sensors?
@DIYDigitalRailroad
5 жыл бұрын
I don't think it would be all that difficult. you would have a few more states, but all if you have to do is to revert to the off state is make to where all 4 sensors are clear to revert to off in case of trains crossing at the same time.
@adamgoldsmith416
Жыл бұрын
can you do this video but with 8 sensors for a double track crossing
@JerseycentralRDfan1071
3 жыл бұрын
How do you connect the lights for the actual signal
@ModelRailroadTechniques
3 жыл бұрын
HI Jimmy could you use a Nano for this project?
@DIYDigitalRailroad
3 жыл бұрын
Yes you could!
@thunderbolt8582
5 жыл бұрын
This setup shuts off the blinking LED when the train enters the second sensor. Actually, this would not work since we want the blinking led to keep flashing until the entire train passes the second sensor. You need more programming to make this work correctly.
@DIYDigitalRailroad
5 жыл бұрын
Thank you for your comment. I think you may have misunderstood the program. The purpose of the Crossing state ST_FLASHING3 is actually to keep the crossing flashing until the train has cleared the second sensor. Thank you for double checking though!
@seanpepple6110
5 жыл бұрын
hi jimmy do you have access to adding a bell to the sketch
@DIYDigitalRailroad
5 жыл бұрын
Hey Sean. I will be working on that soon. It should be possible!
@rickgorske2357
4 жыл бұрын
followed your sketch getting error message not declared case ST_OFF: crossingoff(valA1, valA2); break;
@steventrimm4204
2 жыл бұрын
I am having problems getting the program to load, Where can I go for help to figure out where I messed up? ( crossingflashimg1, was not declared in this scope )
@DIYDigitalRailroad
2 жыл бұрын
If that is exactly how it is written. It looks like there may be a typos with crossingflashing1
@steventrimm4204
2 жыл бұрын
@@DIYDigitalRailroad Got it figured out, thank you for the program
@lennykimball
5 жыл бұрын
what happens if a train pulls over the sensor and then backs up never hitting the other sensor the light just stays on forever. is there a way to put something into the program to recognize that and be able to turn off the lights after a certain amount of time between the two sensors showing nothing being triggered. Say 30 seconds. I'm really curious if this is something that you can do in code I'm not big on code I'm just starting.
@DIYDigitalRailroad
5 жыл бұрын
So after I did this video. I did another video that improved the code and fixed this. Here you go! kzitem.info/news/bejne/yaiKyIOqbGWndJw
@lennykimball
5 жыл бұрын
@@DIYDigitalRailroad thank you for sending me the update I've got that prototype already up and running on the breadboard I will be installing it an our club train set. I've been racking my brain trying to figure out how to add a bell to that program I thought of MP3 players etc. A lot of people can get the lights but it's very difficult to get the Bell on did you come out with it please let me know what your thoughts are.
@lennykimball
5 жыл бұрын
@@DIYDigitalRailroad sorry I hit enter too fast lol! I do have a drawing night shows and Arduino relay bored connected to the Arduino and it connects to an mp3 external he just have to figure out how to get it to work with the switch on and switch off functions on all 5 states as your update shows.
@DIYDigitalRailroad
5 жыл бұрын
Hey Lenny! I haven't had a chance to work on it, but it is on my list!
@frankneher9192
5 жыл бұрын
How about some code for two more sensors to cover a double rail?
@chriswisselo4329
5 жыл бұрын
I think the IR sensors could reach double rail, but it would take a lot of adjusting possibly not trip correctly, but try it out
@johnprater9522
3 жыл бұрын
is there a wiring schematic
@asaprocky8195
Жыл бұрын
What happens if there are two trains, one heading north and one heading south at the same speed, and they each trip sensors as they approach or leave? What if one train stops on the track at the crossing, and the other one leaves? I guess I'll have to build a test track to find out! LOL
@Madmaximuss
2 жыл бұрын
Is there a schematic for this?
@jeffemaxse8928
Жыл бұрын
Hi Jimmy, Hi everyone, Nice video and very nice job from which I was inspired to make a level crossing with leds and servos (allowing to lower barriers). I live in France (so, please forgive my really poor english writing), and level crossings operate very slightly differently from certain crossings in the United States. The problem I encounter with the infrared sensors is that they are "activated" as soon as the loco passes, both on entry AND on exit. In order to solve my problem, I would like the input sensor to be effectively active as soon as the loco passes, but the output sensor to only "activate" after the LAST wagon of the convoy has passed. TOTALLY new to using and coding Arduino, I considered for a moment using a reed sensor module, with a magnet placed on each car at the end of the convoy, but if someone has a solution with infrared sensors, any tips or code snippets would be VERY highly appreciated. For a multi-track use I imagine that the ideal solution would be a detection of occupation of the block on which the level crossing is ? but I have NO idea how to do this detection. Thank you in advance to all and again a huge BRAVO Jimmy for this video (and all the others ;-))
@alanlarsson5126
6 жыл бұрын
OK, great vid. One catch I am seeing, what happens if you trip IR 1, but never trip IR2.... like a train trips 1, then reverses and leaves the area, or visa versa.. The code would be stuck blinking with no train., maybe check IR states and if neither is triggered, reset to flash off after it goes through the flash loop a certain number of times?
@alanlarsson5126
6 жыл бұрын
Add flashcount = 0 to flash off, increment it in each flash 1 and 2 loop. At end of each flash 1 and 3 check both vala1 and vala2 to be untripped, and the count to be more than say 480 blink cycles (4 minutes real time), reset crossing state to OFF. This would mean no train sitting on the crossing.
@DIYDigitalRailroad
6 жыл бұрын
I've actually been struggling with this for awhile. The tricky part is keeping the signal flashing if the train is slowly heading through the signal area. As soon as I figure that part out. There will definitely be an update to this video.
@alanlarsson5126
6 жыл бұрын
Here is an adjusted code to try. It compiles, but I have no hardware setup to test it. docs.google.com/document/d/1Rv8l8H3Xe0LkRs-zb8SokXFkZIxjEiBPLjTnAhsSGSA/edit?usp=sharing
@DIYDigitalRailroad
6 жыл бұрын
This is some awesome inspiration! I learned something new today! I've rewritten the program to add an extra flashing state that the program goes to after 5 seconds so long as neither sensor is being tripped. That flashing state will go to the old final flashing state once a sensor is triggered. I'm going to test the program tonight. Thank you so much for the help! This community is awesome!
@tedmiller6770
6 жыл бұрын
Else if (valA1>500 && valA2
@wayneburling3157
3 жыл бұрын
I am not a C++ programmer, I am getting an error "redefinition of 'int sensePin1' " and do not know what is causing it. I am using the exact code that is in the link above.
@rhtservicesllc
2 жыл бұрын
That means the variable has been defined more than once. Search for the all the occurrences of "int sensePin1". Then remove all but the first one.
@paulhayden3446
5 жыл бұрын
Why do you waste an output for power to the leds when you could just feed them from ground or 5vcc
@DIYDigitalRailroad
5 жыл бұрын
That's a great question. I power my infrared sensors off the 5V and I have noticed through testing that the more I hook up through the 5V, the lower the untriggered sensor value of the infrared sensor and making it more likely to mistrigger. So I decided to use the 5V should only be used for sensors and use the digital pins for the LEDs
@paulhayden3446
5 жыл бұрын
DIY & Digital Railroad That would mean you do not have an adequate power supply for the load and are getting a voltage drop. I can't see how using your technique would make any difference.
@DIYDigitalRailroad
5 жыл бұрын
That's a good point, I have 12 volt power supply hooked up, but maybe it's malfunctioning. The sensor input would drop from near 1023 to around 600 and I would get glitches. Maybe I should try a different board?
@paulhayden3446
5 жыл бұрын
DIY & Digital Railroad When you are reading low sensor value check your voltage make sure it maintains 5 volt. if it is dropping use a regulated power supply with enough output for your load.
@alexlile5561
5 жыл бұрын
Can you run more than one grade crossing with this set up?
@alexlile5561
5 жыл бұрын
Also does this make the bell sound when the crossing lights are on?
@DIYDigitalRailroad
5 жыл бұрын
You would have to add some arduino based audio features that could make the bell work. The code would become significantly more complex as you add multiple grade crossings. You can do multiple tracks with a single crossing, like a double track main.
@alexlile5561
5 жыл бұрын
DIY & Digital Railroad Ok. But what about grade crossing on different parts of the layout? Double track I get. Just wanted to know about adding multiple crossing one arduino?
@alexlile5561
5 жыл бұрын
Thanks for the reply.
@chriswisselo4329
5 жыл бұрын
In theory, it is possible. But you would need to run a LOT of wiring all over your layout. Why not just install an Arduino Nano (5 packs are available for under 20 US$) and safe yourself the headache. Keep your wiring as simple as you can, so you will not spend weeks on end troubleshooting if you have a failure somewhere.
@apachehalloween
3 жыл бұрын
Would I be able to use the Walthers crossing signals that have the LEDS in them already? Thanks Walthers Crossing signals - www.walthers.com/crossing-flashers-relay-box-set-of-2-working-signals-use-with-949-4359-sold-separately
@rhtservicesllc
2 жыл бұрын
Hi. We currently working on a product that would allow you to provide your own signals with our controller. Would you be interested in a controller that you wire up yourself to the signals you already have?
@slambert71
3 жыл бұрын
I am curious why you used one side to turn it on and the other to turn it off. Wouldn't you want the crossing flashing if either one or both is covered? If you trigger one to turn it on, then the other to turn it off, when the engines hit the second sensor, the crossing will turn off while the rest of the train is still in the crossing. The logic should really be if either one is covered, then the signals should be flashing.
@DIYDigitalRailroad
3 жыл бұрын
Thanks for the comment Shane! So the signal actually turns off once the second sensor has cleared after being, not when it is covered. It's kind of hard to see when you don't have an actual crossing. Basically what happens is: First sensor gets covered and starts the crossing, the second sensor gets covered and it tells the arduino to switch to a different set of instructions that basically say "The second sensor is now covered, once it becomes uncovered again, turn off the crossing." This is done in case you have a longer stretch to detect trains and some trains are short enough to fit inside the entire detection area. This is also an older project and I have done some updates.
@robertschworm6036
5 жыл бұрын
Can you put the sketch here please? Thanks
@DIYDigitalRailroad
5 жыл бұрын
I have double checked the link and replaced it to make sure it works. There is a link in the description
@robertschworm6036
5 жыл бұрын
Thanks fir the sketch jimmy. Bob
@jamesdavenport4583
2 жыл бұрын
This seems way more complicated than it really should be. In my opinion.
@rhtservicesllc
2 жыл бұрын
As a technology service provider, I agree that the coding here could be improve upon. We considering doing a review to the code to improve it and simplify how it works
@jdshenanigans9265
5 жыл бұрын
Great videos but i cant get to grips with the Arduino language ive ordered a couple and will download software . Im 50 + with 50% schooling so programing is like an ailen language .not fot this lifetime lol.. again thanks
@dexterdog62
5 жыл бұрын
JD shenanigans I know how you feel... the guy lost me 20 seconds into the video...
@dexterdog62
5 жыл бұрын
Chris Stromberg thanks for the info!
@BK-oo1bl
4 ай бұрын
I don’t mean to sound bad but it seems to me trying to program the arduino is not for computer illiterate people like me it seems complicated with 1000 steps
Пікірлер: 104