|
Arduino UNO, or any similar one |
x 1 | |
|
Adafruit Motor Shield V2 |
x 1 | |
|
Wii Nunchuk |
x 1 | |
|
7-segment LED display with common cathode |
x 1 | |
|
330 Ohm resistor |
x 1 | |
|
12-volt DC power source |
x 1 |
Wii Nunchuk Controlled Model Railroad
Intro
A while back, I came across this Instructable which inspired me to create my own version of that project with some of my own additions. A Wii Nunchuk communicates via the I2C bus and there is an Arduino library to easily integrate the controller in our projects.
In this project, let's control our model railroad layout with a Wii Nunchuk. Let's get started!
Supplies
For this project, you will need:
- An Adafruit Motor Shield V2
- *An Arduino microcontroller board compatible with the Adafruit Motor Shield V2(UNO, Leonardo, etc)
- A Wii Nunchuk
- A common-cathode, 7-segment LED display.
- 4 male to male jumper wires(For connecting the Wii Nunchuck to the Arduino board)
- 2 male to male jumper wires(For connecting the track power to the motor shield)
- ^2 male to male jumper wires(For connecting each turnout to the motor shield)
- °8 wires to connect the LED display to the Arduino board.
- A 330 Ohm Resistor(For connecting the common cathode of the LED display)
- A 12-volt DC power source with a current capacity of at least 1A(1000mA).
* Other non-compatible Arduino microcontrollers can also be used with the motor shield as long as they have I2C.
^ The code in the project can control only 3 turnouts, for controlling more turnouts, more motor shields can be stacked on top of the earlier one and the code can be modified to accommodate them.
° You can either cut an end of each jumper wires and solder them to the display's pins, you can also make a breakout board by soldering the display on a dot-matrix PCB and connect the pins to a 1x8 female header.
Step 1: Program the Microcontroller
You can get the code from here.
I would recommend you going through the code before uploading to understand how it works. It will help you modify it in the future.
Step 2: Prepare the 7 Segment Display
You can either make wiring connections on the breadboard or you can solder the display module on a PCB and add some male or female header pins to connect them to the microcontroller using jumper wires. If you are soldering the display on a PCB, connect the 330Ohm resistor to the common pin of the display.
Step 3: Set Up the Layout
You can set up a basic layout with a turnout or two to test all the controls.
Step 4: Install the Motor Shield on the Microcontroller Board
Install the motor shield by carefully aligning the pins of the shield with the headers of the microcontroller board. The pins of stackable shields can be bent and require care.
Step 5: Connect the Feeder Track to the Motor Shield
Connect the track power feeder wires to the output terminal marked M4 of the motor shield.
Step 6: Connect the Turnouts to the Motor Shield
The terminals marked M1, M2, and M3 correspond to turnouts 1, 2, and 3. This information is useful while determining which number to assign to each turnout.
Step 7: Connect the Nunchuk to the Microcontroller
Connect the +ve supply(VCC) wire of the Nunchuk to the +3.3-volt DC source(Most Arduino boards have a 3.3-volt power pin), -ve supply(GND) wire of the Nunchuk to the GND of the microcontroller, SCL wire of the Nunchuk to the SCL pin of the microcontroller and the SDA wire of the Nunchuk to the SDA pin of the microcontroller.
In most Arduino boards, pin A4 is SDA, and pin A5 is SCL.
Step 8: Connect the LED Display to the Microcontroller
Connect the common pin of the display to GND through a 330Ohm resistor if it has a common cathode, else connect the common pin to +5-volts if it has a common anode. Proceed with making the following connections:
- Segment A to D4
- Segment B to D5
- Segment C to D6
- Segment D to D7
- Segment E to D8
- Segment F to D9
- Segment G to D10
Double-check all the wiring connections and make sure the segments are connected to the right digital outputs of the microcontroller.
Step 9: Connect the Setup to Power
You can connect the 12-volt DC power source to the microcontroller board's DC jack or to the motor shield's power input terminal block.
Step 10: Place the Locomotive on the Tracks
Place a locomotive, preferably in a siding, in the layout. Use of a rerailing tool is recommended, especially for steam locomotives to ensure the locomotive is set on the track properly.
Step 11: Power Up the Setup
Turn of the power, you should be able to see the number '1' is displayed on the LED display. If the display does not light up, check if the common pin is connected and check the wiring connections again.
Step 12: Test the Controls
You can watch the above video to understand the controls and check if the controls of your setup work as shown above.
If moving the joystick or tilting the Nunchuk to either side does not give any response, as shown above, check the wiring connections of the Nunchuk, the track power, the turnouts, and make sure both the Nunchuk and the motor shield are not faulty.
Step 13: Expand the Setup
Since the motor shield used in the project communicates via I2C with the microcontroller, you can add multiple shields with distinct addresses by stacking them(You can learn this here). By modifying the code appropriately, you can control dozens of turnouts, and perhaps, some other things on your layout. There is a lot to do.
If possible, do share your creation. All the best!
Wii Nunchuk Controlled Model Railroad
- Comments(0)
- Likes(1)
- ElectroMaker Jun 13,2021
- 1 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
-
9design
-
7usability
-
10creativity
-
10content
More by KushagraK7
- Raspberry Pi Pico RC Vehicle SuppliesA Raspberry Pi Pico(Almost any microcontroller can be used here, but the Pico offers great f...
- Stepper Motor Controlled Stepper Motor Without Microcontroller! Step 1: Watch the VideoWatch the video to get a full understanding of the project and learn how to t...
- Automated Model Railroad Layout Running Two Trains I made an Automated Model Train Layout with Passing Siding a while back. Upon request from a fellow ...
- Program the Raspberry Pi Pico With the Arduino IDE The Raspberry Pi Pico is a recently launched product in the family of microcontrollers and its load ...
- Reuse an Old Laptop's Touchpad to Control a Computer! PS/2 laptop touchpads are among the coolest user interface devices to use with a microcontroller. Th...
- Automated Model Railroad Layout With Reverse Loops In one of my previous projects, I showed how to make a Simple Automated Point to Point Model Railroa...
- Use a Stepper Motor As a Rotary Encoder Rotary encoders are great for use in microcontroller projects as an input device but their performan...
- Keyboard Controlled Model Train(PS/2 Interface) Using Arduino microcontrollers, there are a lot of ways of controlling model railway layouts. A keyb...
- Stepper Motor Speed and Direction Control Without a Microcontroller In one of my previous projects, I showed you how to control a stepper motor's speed using a 555 time...
- Smartphone Controlled 4X4 Robot With ESP8266 SuppliesFor this project, you will need:An ESP8266 microcontroller(Node MCU)A dual H-bridge motor dr...
- Touchpad Controlled Digital Servo Motor Here is a quick and simple project where we control a digital servo motor with the slide of our fing...
- Smartphone Controlled Model Railroad With an ESP8266 IntroA while back, I made a project where a stepper motor's position is controlled using a smartphon...
- Simple USB Volume Controller with Arduino This project uses a rotary encoder connected to an Arduino Leonardo to control the audio volume of a...
- Motor Speed and Direction Control with a Web-Server using an ESP01 Supplies:For this project, you will need:An ESP01 microcontroller(You can use any ESP8266-based micr...
- Wi-Fi Controlled Stepper Motor With an ESP Microcontroller Step 1: Get All the Required StuffFor this project, you will need:An ESP8266 microcontrollerA Steppe...
- Simple Automated Model Railroad Loop With Yard Siding Video:Supplies: For this project, you will require:An Arduino microcontroller board compatible with ...
- Laptop Touchpad Controlled Model Railroad Supplies:For this project, you will require:An Arduino microcontroller compatible with Adafruit Moto...
- Control a Stepper Motor with a Slide of Your Finger Supplies:An Arduino microcontroller boardA PS/2 touchpad from a laptop(Try to get one with a Synapti...
-
-
-
3D printed Enclosure Backplate for Riden RD60xx power supplies
39 0 0 -
-
-
-
Sega Master System RGB Encoder Switcher Z80 QSB v1.2
47 0 0 -
18650 2S2P Battery Charger, Protection and 5V Output Board
58 0 0 -
High Precision Thermal Imager + Infrared Thermometer | OpenTemp
360 0 5 -
Sony PlayStation Multi Output Frequency Oscillator (MOFO) v1
117 0 2