Fun with Arduino - a Series of Introductory Videos

Post all your model railway electronic problems, solutions and discoverys here.
User avatar
TimberSurf
Posts: 2435
Joined: Wed Jan 08, 2014 5:47 pm
Location: N.Wales
Contact:

Re: Fun with Arduino - a Series of Introductory Videos

Postby TimberSurf » Tue Feb 26, 2019 5:26 pm

Flashbang wrote:TS... The lowering sequence isn't quite correct, both AHB barrier booms lower together not one after the other.
Its only on full barriers that the approach two barriers lower then once proved down the trailing (exit) two lower.
Also, though often not modelled, when the yellow light extinguishes the red lights all come on for around 0.5 second followed by them flashing. Flashing is all left hand red lights on together then all right hand red lights on and so on. Called a Wig Wag sequence.
Now you need the warbling (Yodel alarm) pedestrian warning tone added :D

Hi Flashbang, I am planning for a full (4 barrier) crossing, the sim only shows two servo's, but two servo's would be paired diagonally, the picture does show only one side of the crossing, entrance and exit (the second side has yet to be built :shock: ).
I did note all red start on, I suppose I will have to add another line of code :(
Always left red duly noted! (that's just down to good wiring practice and selecting the correct channel)

The blue alarm is the audio output (to an MP3 player card)
Image
Lumsdonia <--- Hit link to go to my website for full story and wiring advice!

User avatar
Flashbang
Posts: 3371
Joined: Thu Oct 18, 2007 1:07 pm
Location: SE United Kingdom
Contact:

Re: Fun with Arduino - a Series of Introductory Videos

Postby Flashbang » Tue Feb 26, 2019 11:31 pm

Ah OK. Your video shows AHB pedestals hence the assumption they would be half barriers. AHB Pedestals are not used on full barriers. :o
Anyway we're infringing on Rudy's excellent tutorials.
[Image << Click the Icon to go to my website
Broken? It was working correctly when I left it.

User avatar
RudyB
Posts: 191
Joined: Sat Sep 20, 2014 9:29 am

Re: Fun with Arduino - a Series of Introductory Videos

Postby RudyB » Wed Feb 27, 2019 7:30 am

There has been a request to also do a UK crossing. Maybe it can be in one video, else there will be an extra video with the yellow and double red additions when the continential one is finished.
Always try to have fun - website/blog - youtube channel

User avatar
dubdee1000
Posts: 901
Joined: Mon Mar 31, 2008 9:59 pm
Location: cwm brynbuga

Re: Fun with Arduino - a Series of Introductory Videos

Postby dubdee1000 » Wed Feb 27, 2019 8:55 pm

Hi Rudy,

When you do this, can you look at one with track detection, so the the barrier is controlled by an approaching and departing train? Thx.

User avatar
RudyB
Posts: 191
Joined: Sat Sep 20, 2014 9:29 am

Fun with Arduino 18 Railway Crossing, Servo Motor to Operate the Gate

Postby RudyB » Thu Feb 28, 2019 9:56 am

In part 2 of the railway crossing project we are going to connect the servo motor that operates the gate and control it with the Arduino. With the example in the video, the gate beam is mounted directly on the servo. On a layout, the servo motor will probably be mounted under the board, and a metal rod pulls / pushes the beam up and down, through a hole. No matter how it is mounted ... we need to find the correct servo angles. We will write some code with which we can fine tune the servo to find the angles to be used in the code later on.


Fun with Arduino 18 Railway Crossing, Servo Motor to Operate the Gate


Image
Always try to have fun - website/blog - youtube channel

User avatar
RudyB
Posts: 191
Joined: Sat Sep 20, 2014 9:29 am

Fun with Arduino 19 Railway Crossing Train Detection with Optical Sensor

Postby RudyB » Thu Mar 07, 2019 10:35 am

There are several ways to do train detection, like sensing rail current, or a magnet under the train that triggers reed switches along the track, or with an optical sensor. The latter is used in this video, only because I had some TRCT5000's lying around and they were easy to setup for a demo. As soon as we have them working, we have some fun with them by making a train speed measurement device.


Fun with Arduino 19 Railway Crossing Train Detection with Optical Sensor


Image
Always try to have fun - website/blog - youtube channel

User avatar
RudyB
Posts: 191
Joined: Sat Sep 20, 2014 9:29 am

Fun with Arduino 20 Railway Crossing Putting it all Together

Postby RudyB » Sun Mar 10, 2019 11:21 am

We have seen the separate ingredients for a level crossing in the previous three videos: blinking LEDs, servo to operate the gate, sensors to detect the train ... it is time to put it all together now into one piece of software. We'll use the State Transition Diagram as our starting point and build up the software in 5 easy to follow steps.


Fun with Arduino 20 Railway Crossing Putting it all Together

Railway Crossing UK version


Image
Always try to have fun - website/blog - youtube channel

User avatar
RudyB
Posts: 191
Joined: Sat Sep 20, 2014 9:29 am

Fun with Arduino 22 Step Sequencer for LEDs with array[] and for() loop

Postby RudyB » Thu Mar 14, 2019 2:22 pm

A police car, fire fighter car or an ambulance with flashing lights can liven up any model railway laout. The challenge that we set ourselves is not to have to write different code any time we want another flashing pattern. We want to hav one and the same code and we only want to configure the number of stepd, number of LEDs and the flashing step sequence. Can we manage that? Yes of course we can ...


Fun with Arduino 22 Step Sequencer for LEDs


Image
Always try to have fun - website/blog - youtube channel

User avatar
RudyB
Posts: 191
Joined: Sat Sep 20, 2014 9:29 am

Fun with Arduino 23 Neopixel Addressable LED, WS2812, struct{...}

Postby RudyB » Thu Mar 21, 2019 2:13 pm

Neopixels, or addressable LEDs, are color LEDs with a built in chip that takes care of the one wire data communication and of the Pulse Width Modulation for the built in RGB(+W) LEDs. The LEDs are connected via just 3 wires, GND, 5V, Data. The Data line is connected to an Arduino output and we can control the color and brightness of multiple LEDs, via just one output. Wonderful to use in say a village with multiple houses on our model railway layout. The wiring is super simple and the lights in every house switch independently and can each have their own color an brightnes ... just like real.


Link to Fun with Arduino 23 Neopixel Addressable LED, WS2812, struct{...}


Image
Always try to have fun - website/blog - youtube channel

User avatar
RudyB
Posts: 191
Joined: Sat Sep 20, 2014 9:29 am

Fun with Arduino 24 Neopixel Sequencer with Flexible Timing and Colors

Postby RudyB » Fri Mar 29, 2019 11:12 am

In video 23 we made a step sequencer for addressable LEDs (Neopixel). The beauty of it is that a LED on/off sequence is created in a visual way by editing a series of ‘1’s and ‘0’s: 1,1,1,0,0,0,1,1,0,0,1,0,1,1,0,0. The drawback being that the color of every LED is fixed and also the interval time is fixed. The sequencer in this video has full flexibility, every action step has its own timing and LED color / brightness.


Link to Fun with Arduino 24 Neopixel Sequencer with Flexible Timing and Colors


Image
Always try to have fun - website/blog - youtube channel

User avatar
RudyB
Posts: 191
Joined: Sat Sep 20, 2014 9:29 am

Fun with Arduino 25 Rotary Encoder with Switch

Postby RudyB » Fri Apr 05, 2019 1:51 pm

A rotary encoder is a digital device, approximately the size of an analog potentiometer. When rotated, it generates 2 pulse signals from which we can deduct the number of rotation steps and the direction of rotation. It also has a push button on board. When connected to the Arduino we can read out the encoder and change the value of a variable. The variable can be used for anything we like: control the brightness of a LED(strep), control the angle of a servo motor, and more.

In this video we build the software to read out the encoder and switch and control the brightness of a LED (via PWM). In the next video we are going to beuild a servo tune application based on it.


Fun with Arduino 25 Rotary Encoder with Switch


Image
Always try to have fun - website/blog - youtube channel

User avatar
RudyB
Posts: 191
Joined: Sat Sep 20, 2014 9:29 am

Fun with Arduino 26 Tune a Servo with a Rotary Encoder

Postby RudyB » Thu Apr 11, 2019 10:38 am

In the previous video we wrote code to read out the pulses and the switch of a rotary encoder. We are now going to use this to tune a servo motor.

With every mechanical construction where a servo is used to move something (garage doors, a gate beam, a turnout), the minimum and maximum servo angles need to be found for the construction to operate like we want it to. In this video we are going to build a 'servo tuner' to find those angles.

Fun with Arduino 26 Tune a Servo with a Rotary Encoder


Image
Always try to have fun - website/blog - youtube channel

User avatar
RudyB
Posts: 191
Joined: Sat Sep 20, 2014 9:29 am

Fun with Arduino 27 Recognize Slow / Fast Rotation of Rotary Encoder

Postby RudyB » Thu Apr 18, 2019 10:04 am

The Servo Tuner that we built in the previous video can be enhanced with two features:
1: Recognition of slow or fast rotation of the rotary encoder, to be able to increment the motor with small steps or with larger steps.
2: Recognition of short or long press of the button, to be able to move to the min/max angles or to the midpoint of the servo.
In this video we will have a look how we can add these functions.

On the blog there's also code available to operate the Servo Tuner with a wire or with push buttons, in case you don't have a rotary encoder available.

Fun with Arduino 27 Rotary Encoder Slow / Fast Recognition


Image
Always try to have fun - website/blog - youtube channel

User avatar
RudyB
Posts: 191
Joined: Sat Sep 20, 2014 9:29 am

Fun with Arduino 28 Use an External Editor like Notepad++

Postby RudyB » Thu Apr 25, 2019 11:00 am

When writing more code than just a few lines, it might be worthwhile to invest a little bit of time to to start using a more capable editor than the one integrated in the Arduino IDE. There are several free editors around that have a wealth of features that make code editing more efficient and more pleasurable.

Link to Fun with Arduino 28 Use an External Editor like Notepad++


Image
Always try to have fun - website/blog - youtube channel

User avatar
RudyB
Posts: 191
Joined: Sat Sep 20, 2014 9:29 am

Fun with Arduino 29 DCC Accessory Decoder

Postby RudyB » Mon May 06, 2019 11:29 am

With the aid of very little extra hardware we can use Arduino as a DCC decoder, with a price tag that is almost 10x lower than commercially available decoders. In this video we create a DCC Accessory Decoder. In the next video we'll make a DCC Servo Decoder.

In stead of DIY, alternatively you can use the ARCOMORA software, which is fully configurable via a user interface.


Link to Fun with Arduino 29 DCC Accessory Decoder


Image
Always try to have fun - website/blog - youtube channel


Return to “Electronics”

Who is online

Users browsing this forum: No registered users and 1 guest