Fun with Arduino - a Series of Introductory Videos


Fun with Arduino 37 Control a NEMA 17 Stepper Motor with Easy Driver

Several driver circuits are available to control a more powerful stepper motor like a NEMA 17. In this video the EasyDriver is used, but the software is applicable to any driver with Enable, Direction and Step inputs.

Link to Fun with Arduino 37 Control a NEMA 17 Stepper Motor with Easy Driver


36205987bk.jpg
 
Fun with Arduino 38 - Ultrasonic Distance Measurement with HC-SR04

The HC-SR04 is a sensor that has a little loudspeaker and a little microphone via which the distance to an object can be measured. It's ultrasonic, humans can not hear it.

Don't expect super high accuracy of this less than $1,- costing device, yet I was pleasantly surprised to see that measurements with an accuracy of a couple of mm are very well possible.

Link to Fun with Arduino 38 - Ultrasonic Distance Measurement HC-SR04


36544908fy.jpg
 
Fun with Arduino 39 - OLED display SSD1306

We're going to add an OLED display to the ultrasonic distance measurement of the previous video. Together with a battery it now becomes a fully handheld portable device. This is just for fun, the actual purpose is to introduce the OLED display ... once we have that up and running there's a whole lot of fun and useful applications where they can be applied.

Link to Fun with Arduino 39 - OLED dDisplay SSD1306


36717754og.jpg
 
Fun with Arduino 40 - Station Platform Departure Display with Analog Clock

In the previous video we attached an OLED and we saw how to display a text and some lines. In this video we take this a step further, we'll make a station platform train departure sign with a working analog clock.

Via digital inputs a selection can be made of 6 different messages to display. This can be controlled via push buttons or via a DCC decoder.

The clock starts at a random time, this requires no other hardware than the Arduino and the OLED. In the next video we'll add a Real Time Clock module to make the clock run on actual time.

Link to Fun with Arduino 40 Station Platform Departure Display with Analog Clock


36827560uc.jpg
 
Fun with Arduino 30 DCC Servo Decoder

Based on the code for the DCC Accessory Decoder we can create a Servo Decoder. All we have to do is add a couple lines of code to toggle the setpoint of the servo, based on the DCC status, and add the code to rotate the servos based on a millis() timer.

Link to Fun with Arduino 30 DCC Servo Decoder
This is interesting. I'm about to do something similar. For those that are interested, I found a 3d printable mount for these servos. It looks like a very similar design to what you've got there, just rotated a bit.
For those who want to 3d print the bracket: https://www.thingiverse.com/thing:1543113
 
Fun with Arduino 41 Real Time Clock DS1307

The station platform clock of the previous video runs, but it shows a random time. We can add a Real Time Clock module to have it show the current time. Several versions of Real Time Clock modules are available. This video is about the DS1307 RTC, which can be had for under $1,-.

Link to Fun with Arduino 41 Real Time Clock DS1307


37939342lr.jpg
 
Do you think it feasible to measure the length of a train by combining 2 of the above procedures as follows? When the train emerges from a storage area onto a straightaway it crosses an Optical Sensor which programmatically triggers a distance reading (d1) from the Ultrasonic Sensor positioned ahead of the straightaway just beyond a curve (so the train does not ram it). When the Optical Sensor registers that the train is no longer blocking it (because it has completed passing it) that event triggers another distance reading (d2) and stores the difference d1-d2 as the train length. I would like to use this to restrict choices on yard tracks or sidings, rendering as "not available" those which are actually shorter than the measured train. (I realize that the sensor beam would have to be skew to the track so as not to be fooled by space between cars.) If you think it feasible, do you know of methods for camouflaging the Ultrasonic Sensor?
 
I can't imagine the ultrasonic detector to be accurate enough, or be able to measure train distance at all when facing the nose.
I don't know what software you use to control your layout, but usually control software already have built in options to decide allowed tracks based on train lengths. Can't you measure the length with one optical sensor, keeping the train speed constant in that section to facilitate the measurement?
 
I'm writing my own software. I don't know the constant speed, but it occurs to me that by placing a second optical sensor a fixed distance beyond the first, I can determine the speed by dividing that distance by the time elapsed between triggering the first and second sensor, and then compute the train length by multiplying that speed by the elapsed time between the train triggering and un-triggering the first sensor.
 



Back
Top