Arduino code:
// By Dr. Sarra Minovsky for the Applied Plavsky Physics Research Institute // // https://www.reddit.com/r/SarraMinovskyNotes // https://www.reddit.com/r/BuildFightSystem // // License is granted to freely use and modify this code, unless you're putting it in a Zeon-based // Gunpla. They're insane fanatics who'd kill many to 'liberate' a few into their cult.
/* / / / First, setup any constants and variables that need to exist, then later define a looping set / of instructions for the Arduino microcontroller to follow over and over. Constants and variables / setup outside of the setup() function and loop() function / / */
/* / / / Setup microcontroller pins to use when communicating with the LED lights. / / Digital pins 4, 5, and 6 are pulse-width modulation (PWM) enabled; this lets you vary the LED's / brightness for each color channel across more intensities than just FULL ON and COMPLETELY OFF. / / Regular LEDs only have one wire in and one out, but since this is for multicolor LEDs, each RGB / color has its own wire and they share one more for the current in the other direction. Or / something like that. That shared LED pin connects to the Arduino's 5-volt power and doesn't / need to be defined. / / Below, 'const' means this is a constant/permanent value, not a variable (changing value). / / 'int' means we're defining the pins using integers (not floats like 3.14159 or Strings like / "Sarra is awesome."). / / Each line has to end with a semicolon because reasons. / / */
const int cyan_7_control_pin = 0; // soldered, tested
const int cyan_1_control_pin = 1; // soldered, tested
const int cyan_2_control_pin = 2; // center in harness, soldered, tested
const int cockpit_green_light_control_pin = 3; // PWM-ready pin
const int red_1_control_pin = 4; // soldered, tested
const int green_head_camera_control_pin = 5; // PWM-ready pin
const int red_head_camera_control_pin = 6; // PWM-ready pin
const int cyan_4_control_pin = 7; // soldered, tested
const int red_2_control_pin = 8; // soldered, tested
const int cyan_5_control_pin = 9; // PWM-ready pin, soldered, tested
const int cyan_6_control_pin = 10; // PWM-ready pin, soldered, tested
const int blue_head_camera_control_pin = 11; // PWM-ready pin
const int cyan_3_control_pin = 12; // soldered, tested
const int wingtip_lights_control_pin = 13; // PWM-ready pin
const int red_3_control_pin = A0; // soldered, tested
const int red_4_control_pin = A1; // soldered, tested
const int red_5_control_pin = A2; // soldered, tested
const int red_6_control_pin = A3;
const int yellow_running_lights_control_pin = A4;
const int red_7_control_pin = A5;
const int yellow_running_lights_off_duration = 1000; // milliseconds const int yellow_running_lights_flash_duration = 100; const int yellow_running_lights_max_flashes_count = 3;
const int wingtip_lights_dim_duration = 1000; const int wingtip_lights_flash_duration = 60; const int wingtip_lights_max_flashes_count = 2;
const boolean debugging = false;
// End of defining globally-available constants and variables
/* / / / Next, store the brightness of each color channel outside the main loop below so that the / Arduino microcontroller doesn't forget them each time the loop runs again. This approach lets / you adjust each color channel smoothly over time if you want to. / / These values will change, so they don't have "const" by them. / / */
int head_camera_red_intensity = 255; int head_camera_green_intensity = 0; int head_camera_blue_intensity = 0;
int cockpit_green_light_intensity = 255; boolean cockpit_light_dimming = false;
long yellow_running_lights_last_cycle_timestamp = 0L; int yellow_running_lights_state = 1; // off during long interval int yellow_running_lights_flashes_count = 0;
long wingtip_lights_last_cycle_timestamp = 0L; int wingtip_lights_state = 1; // off during long interval int wingtip_lights_flashes_count = 0;
int fiber_optics_durations_array[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; boolean fiber_optics_states_array[] = { false, true, false, true, false, true, false, true }; long fiber_optics_last_cycle_timestamps[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
int display_mode = 2; /* //////////////////////////////////////////////////////////////////////////
/
/ Cyan Red
/ Fiber Cyan Fiber Red Wing Amber
/ Optics Head Optics Head Nav Caution Description
/ -2: Y Powerup sequence
/ -1: Y Normal running, RG inactive
/ 0: Y Y Y RG active mode
/ 1: Y Y Y Y RG --> Demon transition
/ 2: Y Y Demon RG/Beastmode
/ 3: Y Y Hangar maintenance mode
/ 4: Y Y Y Y Y Y Smoke/wiring test mode
/ 5: Distraction-free mode
/
///////////////////////////////////////////////////////////////////////////*/
// Done configuring globally available constants and variables ^
// Start setting up the Arduino microcontroller with stored constants and variables from above
void setup() {
/* /
/
/ Tell the Arduino microcontroller how to use those pins: to power things (OUTPUT) OR to
/ receive sensor data (INPUT).
/
/ I think the keywords are case-sensitive so that the Arduino knows they're keywords?
/
/ */
// Head camera RGB LED
pinMode( red_head_camera_control_pin, OUTPUT );
pinMode( green_head_camera_control_pin, OUTPUT );
pinMode( blue_head_camera_control_pin, OUTPUT );
// Interior running lights
pinMode( cockpit_green_light_control_pin, OUTPUT );
// Exterior running lights
pinMode( yellow_running_lights_control_pin, OUTPUT );
pinMode( wingtip_lights_control_pin, OUTPUT );
// Fiber optics LEDs
pinMode( cyan_1_control_pin, OUTPUT );
pinMode( cyan_2_control_pin, OUTPUT );
pinMode( cyan_3_control_pin, OUTPUT );
pinMode( cyan_4_control_pin, OUTPUT );
pinMode( cyan_5_control_pin, OUTPUT );
pinMode( cyan_6_control_pin, OUTPUT );
pinMode( cyan_7_control_pin, OUTPUT );
pinMode( red_1_control_pin, OUTPUT );
pinMode( red_2_control_pin, OUTPUT );
pinMode( red_3_control_pin, OUTPUT );
pinMode( red_4_control_pin, OUTPUT );
pinMode( red_5_control_pin, OUTPUT );
pinMode( red_6_control_pin, OUTPUT );
pinMode( red_7_control_pin, OUTPUT );
// Set startup values
analogWrite( red_head_camera_control_pin, 255 );
analogWrite( green_head_camera_control_pin, 255 );
digitalWrite( red_head_camera_control_pin, HIGH );
analogWrite( blue_head_camera_control_pin, 255 );
analogWrite( cockpit_green_light_control_pin, 255 );
digitalWrite( yellow_running_lights_control_pin, LOW );
digitalWrite( wingtip_lights_control_pin, LOW );
digitalWrite( cyan_1_control_pin, HIGH );
digitalWrite( cyan_2_control_pin, HIGH );
digitalWrite( cyan_3_control_pin, HIGH );
digitalWrite( cyan_4_control_pin, HIGH );
digitalWrite( cyan_5_control_pin, HIGH );
digitalWrite( cyan_6_control_pin, HIGH );
digitalWrite( cyan_7_control_pin, HIGH );
digitalWrite( red_1_control_pin, HIGH );
digitalWrite( red_2_control_pin, HIGH );
digitalWrite( red_3_control_pin, HIGH );
digitalWrite( red_4_control_pin, HIGH );
digitalWrite( red_5_control_pin, HIGH );
digitalWrite( red_6_control_pin, HIGH );
digitalWrite( red_7_control_pin, HIGH );
if( debugging ) {
Serial.begin(9600);
}
}
// End of configuring the Arduino microcontroller with stored constants and variables from above