Sure, here's a project outline for creating an Arduino Uno-based controller for a model H0 scale semaphore signal with two arms, including a simulation of movement fading out.
Project Outline: Arduino Uno Semaphore Signal Controller
Components Needed:
- Arduino Uno
- LEDs (for simulating the semaphore arms)
- Resistors (appropriate values for LEDs)
- Transistors or MOSFETs (if using high-power LEDs or additional components)
- Potentiometer (for adjusting fade duration)
- Breadboard and jumper wires
- Power supply (if needed, depending on the LEDs)
Circuit Diagram:
- Connect the LEDs to digital pins on the Arduino Uno through resistors.
- Use a potentiometer to provide an analog input for fade duration adjustment.
Code:
const int ledPin1 = 9; // Pin for the first semaphore arm
const int ledPin2 = 10; // Pin for the second semaphore arm
const int potPin = A0; // Pin for the potentiometer
void setup() {
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(potPin, INPUT);
}
void loop() {
int potValue = analogRead(potPin); // Read the potentiometer value
int fadeDuration = map(potValue, 0, 1023, 500, 5000); // Map to a fade duration
// Simulate movement for the first arm
for (int brightness = 0; brightness <= 255; brightness++) {
analogWrite(ledPin1, brightness);
delay(fadeDuration / 255);
}
for (int brightness = 255; brightness >= 0; brightness--) {
analogWrite(ledPin1, brightness);
delay(fadeDuration / 255);
}
// Simulate movement for the second arm
for (int brightness = 0; brightness <= 255; brightness++) {
analogWrite(ledPin2, brightness);
delay(fadeDuration / 255);
}
for (int brightness = 255; brightness >= 0; brightness--) {
analogWrite(ledPin2, brightness);
delay(fadeDuration / 255);
}
delay(1000); // Wait before repeating the sequence
}
Explanation:
-
Setup:
- Initialize the LED pins as outputs and the potentiometer pin as input.
-
Loop:
- Read the potentiometer value to determine the fade duration.
- Map the potentiometer value to a fade duration between 500ms and 5000ms.
- Use
analogWrite to fade the LEDs in and out, simulating the movement of the semaphore arms.
- Repeat the sequence after a short delay.
Additional Tips:
- Transistors/MOSFETs: If your LEDs require more current than the Arduino can provide, use transistors or MOSFETs to control them.
- Power Supply: Ensure your power supply can handle the current draw of your LEDs.
- Enhancements: You can add more complex sequences or respond to external inputs (buttons, sensors) to control the semaphore signal.
This project will give you a functional H0 scale semaphore signal with fading arm movements, controlled by an Arduino Uno.