Joined: 16/04/2014(UTC) Posts: 775 Location: Bangalore, India
|
Hello all, I realized that there are few members in the forum who have been using Arduino for automation on their layout. There are few like me and Johnvr who are learning. And few who might want to explore. In this thread let us share everything 'we had done\will be doing' using Arduino so that other members can benefit from that. I'll start with what I've understood about Arduino after having done small projects with the starter kit I bought. Note: I'm not from electronics background. So if I can understand Arduino, anybody else in this world can:) - Arduino is nothing but a programmable chip embedded on a piece of circuit with some interfaces. -We program the chip using a USB cable and a simple, freely available tool called Arduino Integrated Developement Environment (IDE) - The interfaces are input and output pins - Input pins let you connect Sensors- pressure sensor, -light sensor, -infrared sensor, -manual push button, -optical sensor -Temperature Sensor -Potentiometers (to gradually increase\decrease the voltage) and many more Output pins let you connect actuators - A Servo motor (a motor with builtin circuit that can turn only 180 degrees and back to 0 degrees) - A motor - Light Emitting Diodes (LEDs) - Display Screens - yes you can print custom texts on an LCD display and probably more In simple words, Arduino connects Sensors to Actuators using a few pieces of instructions called Code. From my limited knowledge at this point of time, I can say that we can achieve the following for our MRR needs - Flickering of red LED to simulate fire - A railway crossing gate with realistic slow movements of gates - Detect a moving train using infrared sensor - Make a wind mill rotate very slowly - Turnout switches - Traffic Signals - Station Announcements when the train is nearing the station - Use 1 LED to emit Red, Blue, Green and Yellow colors using a technique called Pulse Width Modulation -Control your layout's accessories using a smart phone by adding a "Bluetooth shield" and many more
Arduino starter kit is a great way to explore the potential of this invention. Here are two projects which I have uploaded on Youtube.
|
 3 users liked this useful post by madhu.gn.71
|
|
|
Joined: 03/10/2010(UTC) Posts: 1,293 Location: Cape Town, South Africa
|
Madhu, Thanks for the brief introductory chat, and for starting the topic on Arduino Projects and Model Railways. I am really a beginner at this hobby device, but I do see some great potential here. My current project is to connect up some Marklin Hobby Signals to the Arduino. These are Marklin Distant Signals so no switching of track current involved here, but I would like the signals to change to RED when the train passes, then back to GREEN again. Here is a picture of my simple setup so far. In Development Mode, Computer connects USB cable to the Arduino, and Arduino powers the signals. The Arduino can be powered by external power supply when project is complete. Programming the signals is done using some fairly basic programming language. Watch this space !  Regards, John
|
 1 user liked this useful post by Johnvr
|
|
|
Joined: 30/12/2012(UTC) Posts: 121 Location: Allegany
|
Here is a nice site for Arduino projects.https://rudysmodelrailway.wordpress.com/software/  Edited by user 24 May 2016 21:22:09(UTC)
| Reason: Not specified
|
 2 users liked this useful post by Oliver nagel
|
|
|
Joined: 16/04/2014(UTC) Posts: 775 Location: Bangalore, India
|
I'm trying to control speed of a DC motor so that the wind mill rotation looks realistic. In real world we might have to use either a gear train or set of pulleys to make the windmill rotate slow. With Arduino and pulse width modulation, we can generate slow speeds. The motor which I've used here is quite powerful and has high RPM. I'll try this experiment with small motors later. Here is the code to achieve the same and the end result is shown in the video. Caution: provide 9V dedicated power supply to Motor and let the ground be shared with Arduino. Use light weight material for windmill so that inertia is less while running at low speeds Code:const int motorPin = 9;
int motorSpeed;
void setup() {
pinMode(motorPin, OUTPUT);
}
void loop() {
analogWrite (motorPin, 14) ;
delay(23);
analogWrite (motorPin, 7);
delay(30);
}
|
 2 users liked this useful post by madhu.gn.71
|
|
|
Joined: 16/04/2014(UTC) Posts: 775 Location: Bangalore, India
|
Alien\UFO sound or siren: On your layout if you need fire alarm or siren or some eerie sound, you could try this:) This is one of the starter kit projects and the code is included in Arduino IDE itself (File>>Examples>>10. Starterkit>>p06_Light Thermin). In the example below, a light sensor is used as a feedback device. We can as well program so that a specific pattern of sound gets played repeatedly
|
 2 users liked this useful post by madhu.gn.71
|
|
|
Joined: 23/07/2014(UTC) Posts: 8,464 Location: ENGLAND, Didcot
|
Originally Posted by: madhu.gn.71  ...Use light weight material for windmill so that inertia is less while running at low speeds
If running at low % pwm (which I suspect you are, seeing you say you have a 'high speed' motor) then there may be some advantage in having a reasonable mass in the windmill blades to smooth out the motor pulses and give an appearance of smooth operation.
|
|
|
|
Joined: 16/04/2014(UTC) Posts: 775 Location: Bangalore, India
|
Originally Posted by: kiwiAlan  then there may be some advantage in having a reasonable mass in the windmill blades to smooth out the motor pulses and give an appearance of smooth operation.
Yes, you are right! However in the video I've posted above, the wings needed a small push (30th second) when the Arduino board was reset. That lead to my above assumption. I'll keep you all posted with my experiments with different DC motors Regards, Madhu
|
|
|
|
Joined: 16/04/2014(UTC) Posts: 775 Location: Bangalore, India
|
Scratch built a water crane using scrap materials. The crane is controlled by Arduino using IR sensor. Refer to the sketch annotations for more details Code:#include<Servo.h>
Servo servo;
int lastReading = 0;
const int SENSOR1 = A1;
const int SERVO = 9;
const int LIGHT = 12;
int sensor1Value = 0;
boolean spoutOpen = false;
void setup() {
pinMode(LIGHT, OUTPUT);
servo.attach(SERVO);
servo.write(0);
}
void loop() {
sensor1Value = analogRead(SENSOR1);
delay(15);
if (sensor1Value < 200)
{
delay(4000);
if (analogRead(SENSOR1) == lastReading) {
activateArm();
}
} else {
lastReading = analogRead(SENSOR1);
}
}
void activateArm() {
digitalWrite (LIGHT, HIGH);
for (int i = 0; i <= 80; i++)
{
servo.write(i);
delay(40);
}
delay(6000);
lastReading = analogRead(SENSOR1);
deactivatArm();
}
void deactivatArm() {
for (int i = 0; i <= 80; i++)
{
servo.write(80 - i);
delay(40);
}
lastReading = 0;
delay(1000);
digitalWrite (LIGHT, LOW);
}
|
 8 users liked this useful post by madhu.gn.71
|
|
|
Joined: 10/02/2006(UTC) Posts: 3,997
|
nice job on the crane too! I thought I would add my 'project' to the list too! The RemoteSign screens I make are also in the Arduino environment even though the boards are not made by Arduino. I use the ESP boards which come with WiFi built in. I have built up a whole ecosystem of software and signs with its own set of common commands. One can load my software onto ESP8266 or Wemos D1 mini processors and control output pins from other software in real-time over your wifi network, as well as drive small screens for station signs, etc. You can also respond to sensors etc. Edited by user 03 October 2020 19:17:07(UTC)
| Reason: typo |
|
 2 users liked this useful post by DaleSchultz
|
|
|
Joined: 16/04/2014(UTC) Posts: 775 Location: Bangalore, India
|
Hello Dale, I had seen it on your blog and it looks super cool. Let me read about ESP8266 and Wemos D1 mini. A quick Google search reveals that they can be programmed using Arduino IDE too. If devices on the layout can communicate to each other through WiFi, nothing's like it. Regards, Madhu
|
|
|
|
Joined: 16/04/2014(UTC) Posts: 775 Location: Bangalore, India
|
I made this welding, vehicle accident scene and two photo flash scenery using Arduino basic light flashing program. The welding flash is combined with photo flash. The vehicle accident scene has 3 flashing sequences namely police car, hazard lights of the crashed car and the railway crossing lights. https://www.instagram.co...mp;igsh=MzRlODBiNWFlZA==https://www.instagram.co...mp;igsh=MzRlODBiNWFlZA==Here is the Arduino code for the welding scene Code:
int led = 9;
int led1 = 3;
void setup() {
pinMode(led, OUTPUT);
pinMode(led1, OUTPUT);
}
void loop() {
for (int i = 0; i < 100000; i++) {
if (i % 240 == 0) {
analogWrite(led1, 0);
delay(30);
}
if (i % 375 == 0) {
analogWrite(led1, 255);
delay(20);
analogWrite(led1, 0);
delay(30);
analogWrite(led1, 80);
delay(5);
analogWrite(led1, 0);
delay(5);
}
if (i % 7500 == 0) {
analogWrite(led, 255);
delay(20);
analogWrite(led, 0);
delay(300);
analogWrite(led, 255);
delay(30);
analogWrite(led, 0);
delay(5000);
}
}
}
Here is the Arduino sketch for the accident scene Code:
int ledPolice1 = 10;
int ledPolice2 = 11;
int hazardLight = 9;
int railwayCrossing1 =6;
int railwayCrossing2 = 5;
int m=1;
void setup() {
pinMode(hazardLight, OUTPUT);
pinMode(ledPolice1, OUTPUT);
pinMode(ledPolice2, OUTPUT);
pinMode(railwayCrossing1, OUTPUT);
pinMode(railwayCrossing2, OUTPUT);
}
void loop() {
analogWrite(railwayCrossing1,0);
analogWrite(railwayCrossing2,0);
analogWrite(hazardLight, 0);
analogWrite(ledPolice1, 100);
analogWrite(ledPolice2, 0);
delay(200);
analogWrite(ledPolice2, 100);
analogWrite(ledPolice1, 0);
delay(200);
for (int i = 0; i < 25; i++) {
analogWrite(hazardLight, i*4);
delay(5);
}
railwayCrossingBlink();
}
void railwayCrossingBlink()
{
if (m==1) {
analogWrite(railwayCrossing2,0);
delay(5);
m=2;
} else {
analogWrite(railwayCrossing1,0);
delay(5);
m=1;
}
for (int i = 0; i < 100; i++) {
analogWrite(m==1?railwayCrossing1:railwayCrossing2, i*2);
delay(1);
}
}
|
 2 users liked this useful post by madhu.gn.71
|
|
|
Joined: 31/10/2023(UTC) Posts: 27 Location: Victoria, Melbourne
|
What you have done is very impressive. Can I make a small suggestion (which is certainly NOT meant to be criticism in any way) but the way you are approaching this by putting everything into the 'loop()' function and then using 'delay()' calls will (eventually) limit what you can do as each thing that is flashing will stop the other things - it all works in a linear manner. That works well for a few flashing lights that are isolated from each other. Although it is a more advanced programming technique, can I suggest that you look to using a timer that triggers in ISR (Interrupt Service Routine). and you put the flashing code in there. There are several ways you can do this. One is to work out the smallest time interval you need for any/all lights and then make a counter for each light. Each time the ISR is called you decrement each counter and when it gets to 0 then you turn the light on or off. You then reset the counter for however long until that light needs to toggle again. If the light (or lights) needs to flash in a more complex manner then you can perhaps consider creating a 'state machine' (which is in itself a level of complexity you may not wish to go to) and the lights that turn on or off depend on the state of the machine which is updated with each timer 'tick'. Just a random thought.... Susan
|
 1 user liked this useful post by Aussie Susan
|
|
|
Joined: 11/03/2024(UTC) Posts: 5 Location: Copenhagen
|
I am using the arcomora project https://www.arcomora.com/ to control my signals and ligth. I am useing the DCCnext DIY kits - easy to solder, but you can also ordre as finish kits or use your own Arduino, Erik |
ESU Ecos, ESU SwitchPilots, ESU Detector, Arcomora dccnext, Viessmann 5211, Viessmann S88, Traincontroller Silver, C-tracks, DCC protocol where possible |
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.