This circuit is designed to control four LEDs using an Arduino UNO microcontroller. The LEDs are controlled via serial commands sent from MobiFlight. Each LED can be turned on or off based on specific commands received by the Arduino. Additionally, the circuit includes pushbuttons and resistors to manage the LED states and ensure proper current flow.
Arduino UNO
Resistor (220 Ohms)
LED: Two Pin (red)
Pushbutton
5V: Connected to the power supply.
GND: Connected to:
D8: Connected to the anode of LED 4.
D7: Connected to the anode of LED 3.
D6: Connected to the anode of LED 2.
D5: Connected to the anode of LED 1.
D4: Connected to Pin 1 (in) of Pushbutton 3.
D3: Connected to Pin 1 (in) of Pushbutton 2.
D2: Connected to Pin 1 (in) of Pushbutton 1.
// Define pin numbers for LEDs
const int ledPin1 = 5;
const int ledPin2 = 6;
const int ledPin3 = 7;
const int ledPin4 = 8;
void setup() {
// Initialize the LED pins as output
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(ledPin4, OUTPUT);
// Start serial communication at 9600 baud rate
Serial.begin(9600);
}
void loop() {
// Check if data is available to read from the serial port
if (Serial.available() > 0) {
// Read the incoming byte
char command = Serial.read();
// Control the LEDs based on the received command
switch (command) {
case 'A': // Turn on LED 1
digitalWrite(ledPin1, HIGH);
break;
case 'a': // Turn off LED 1
digitalWrite(ledPin1, LOW);
break;
case 'B': // Turn on LED 2
digitalWrite(ledPin2, HIGH);
break;
case 'b': // Turn off LED 2
digitalWrite(ledPin2, LOW);
break;
case 'C': // Turn on LED 3
digitalWrite(ledPin3, HIGH);
break;
case 'c': // Turn off LED 3
digitalWrite(ledPin3, LOW);
break;
case 'D': // Turn on LED 4
digitalWrite(ledPin4, HIGH);
break;
case 'd': // Turn off LED 4
digitalWrite(ledPin4, LOW);
break;
default:
// Do nothing if an unknown command is received
break;
}
}
}
ledPin1
, ledPin2
, ledPin3
, and ledPin4
.This setup allows you to control the LEDs via MobiFlight inputs by sending specific commands to the Arduino.