int LEDState = 0;
int LEDPin = 3;
int LEDPin2 = 4;
int LEDPin3 = 5;
int LEDPin4 = 6;
int LEDPin5 = 7;
int LEDPin6 = 8;
int LEDPin7 = 9;
int LEDPin8 = 10;
int LEDPin9 = 11;
int LEDPin10 = 12;
int LEDPin11 = 13;
int buttonPin = 2;
int buttonNew;
int buttonOld = 1;
int buttonRead;
int dt = 100;
void setup() {
setup1();
setup2();
setup3();
setup4();
}
void loop() {
loop1();
loop2();
loop3();
loop4();
}
void setup1() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode (LEDPin, OUTPUT);
pinMode (LEDPin2, OUTPUT);
pinMode (LEDPin3, OUTPUT);
pinMode (LEDPin4, OUTPUT);
pinMode (LEDPin5, OUTPUT);
pinMode (LEDPin6, OUTPUT);
pinMode (LEDPin7, OUTPUT);
pinMode (LEDPin8, OUTPUT);
pinMode (LEDPin9, OUTPUT);
pinMode (LEDPin10, OUTPUT);
pinMode (LEDPin11, OUTPUT);
pinMode (buttonPin, INPUT);
}
void loop1() {
// put your main code here, to run repeatedly:
buttonNew = digitalRead(buttonPin);
if (buttonOld == 0 && buttonNew == 1) {
if (LEDState == 0) {
digitalWrite (LEDPin, HIGH);
delay (1500);
digitalWrite (LEDPin2, HIGH);
delay (1500);
digitalWrite (LEDPin3, HIGH);
delay (1500);
digitalWrite (LEDPin4, HIGH);
delay (1500);
digitalWrite (LEDPin5, HIGH);
delay (1500);
digitalWrite (LEDPin6, HIGH);
delay (1500);
digitalWrite (LEDPin7, HIGH);
delay (1500);
digitalWrite (LEDPin8, HIGH);
delay (1500);
digitalWrite (LEDPin9, HIGH);
delay (1500);
digitalWrite (LEDPin10, HIGH);
delay (1500);
digitalWrite (LEDPin11, HIGH);
delay (1500);
LEDState = 1;
}
else {
digitalWrite (LEDPin, LOW);
LEDState = 0;
digitalWrite (LEDPin2, LOW);
LEDState = 0;
digitalWrite (LEDPin3, LOW);
LEDState = 0;
digitalWrite (LEDPin4, LOW);
LEDState = 0;
digitalWrite (LEDPin5, LOW);
LEDState = 0;
digitalWrite (LEDPin6, LOW);
LEDState = 0;
digitalWrite (LEDPin7, LOW);
LEDState = 0;
digitalWrite (LEDPin8, LOW);
LEDState = 0;
digitalWrite (LEDPin9, LOW);
LEDState = 0;
digitalWrite (LEDPin10, LOW);
LEDState = 0;
digitalWrite (LEDPin11, LOW);
LEDState = 0;
}
}
buttonOld = buttonNew;
delay(dt);
}
//phasers
int buttonState = 0;
const int ledPin_ph = 22; // the number of the LED pin
const int ledPin_ph1 = 23;
int buttonPin_ph = 24;
// Variables will change:
int ledState = LOW; // ledState used to set the LED
int ledState1 = LOW; // ledState used to set the LED
// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0; // will store last time LED was updated
unsigned long previousMillis1 = 0; // will store last time LED was updated
// constants won't change:
const long interval = 1550; // interval at which to blink (milliseconds)
const long interval1 = 1150; // interval at which to blink (milliseconds)
void setup2() {
// set the digital pin as output:
pinMode(ledPin_ph, OUTPUT);
pinMode(ledPin_ph1, OUTPUT);
pinMode(buttonPin_ph, INPUT_PULLUP);
}
void loop2() {
// here is where you'd put code that needs to be running all the time.
// check to see if it's time to blink the LED; that is, if the difference
// between the current time and last time you blinked the LED is bigger than
// the interval at which you want to blink the LED.
buttonState = digitalRead(22);
if (buttonState == HIGH) {
digitalWrite(23, HIGH);
delay(45);
digitalWrite(23, LOW);
delay(45);
}
else if (buttonState == LOW) {
digitalWrite(23, LOW);
}
buttonState = digitalRead(22);
if (buttonState == HIGH) {
digitalWrite(24, HIGH);
delay(45);
digitalWrite(24, LOW);
delay(45);
}
else if (buttonState == LOW) {
digitalWrite(24, LOW);
}
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
// if the LED is off turn it on and vice-versa:
if (ledState == LOW) {
ledState = HIGH;
} else {
ledState = LOW;
}
// set the LED with the ledState of the variable:
digitalWrite(ledPin_ph, ledState);
}
unsigned long currentMillis1 = millis();
if (currentMillis1 - previousMillis1 >= interval1) {
// save the last time you blinked the LED
previousMillis1 = currentMillis1;
// if the LED is off turn it on and vice-versa:
if (ledState1 == LOW) {
ledState1 = HIGH;
} else {
ledState1 = LOW;
}
// set the LED with the ledState of the variable:
digitalWrite(ledPin_ph1, ledState1);
}
}
//Photon Torpedo
// constants won't change. They're used here to set pin numbers:
const int buttonPin_pt = 17; // the number of the pushbutton pin
int LEDPin_pt = 18; // the number of the LED pin
int LEDPin_pt2 = 19; // the number of the LED pin
int LEDPin_pt3 = 20;
// variables will change:
int buttonState_pt = 0; // variable for reading the pushbutton status
void setup3() {
// initialize the LED pin as an output:
pinMode(LEDPin_pt, OUTPUT);
pinMode(LEDPin_pt2, OUTPUT);
pinMode(LEDPin_pt3, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin_pt, INPUT);
}
void loop3() {
// read the state of the pushbutton value:
buttonState_pt = digitalRead(buttonPin_pt);
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState_pt == HIGH) {
for (int fadeValue = 0; fadeValue <= 40; fadeValue += 5) {
// sets the value (range from 0 to 255):
analogWrite(LEDPin_pt, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(11);
}
// fade out from max to min in increments of 5 points:
for (int fadeValue = 255; fadeValue >= 0; fadeValue -= 5) {
// sets the value (range from 0 to 255):
analogWrite(LEDPin_pt, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(11);
}
// fade in from min to max in increments of 5 points:
for (int fadeValue = 0; fadeValue <= 40; fadeValue += 5) {
// sets the value (range from 0 to 255):
analogWrite(LEDPin_pt2, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(115);
}
// fade out from max to min in increments of 5 points:
for (int fadeValue = 255; fadeValue >= 0; fadeValue -= 5) {
// sets the value (range from 0 to 255):
analogWrite(LEDPin_pt2, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
// fade in from min to max in increments of 5 points:
for (int fadeValue = 0; fadeValue <= 40; fadeValue += 5) {
// sets the value (range from 0 to 255):
analogWrite(LEDPin_pt3, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(115);
}
// fade out from max to min in increments of 5 points:
for (int fadeValue = 255; fadeValue >= 0; fadeValue -= 5) {
// sets the value (range from 0 to 255):
analogWrite(LEDPin_pt3, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
}
}
//Navigation\Stobe Lights
//created 2005
//by David A. Mellis
// modified 8 Feb 2010
// by Paul Stoffregen
// modified 11 Nov 2013
// by Scott Fitzgerald
// modified 9 Jan 2017
//by Arturo Guadalupi
// This example code is in the public domain.
// https://www.arduino.cc/en/Tutorial/BuiltInExamples/BlinkWithoutDelay
//*/
// constants won't change. Used here to set a pin number:
const int ledPin_ns = 26; // the number of the LED pin
const int ledPin_ns1 = 27;
// Variables will change:
int ledState_ns = LOW; // ledState used to set the LED
int ledState_ns1 = LOW; // ledState used to set the LED
// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis_ns = 0; // will store last time LED was updated
unsigned long previousMillis_ns1 = 0; // will store last time LED was updated
// constants won't change:
const long interval_ns = 1000; // interval at which to blink (milliseconds)
const long interval_ns1 = 250;
void setup4() {
// set the digital pin as output:
pinMode(ledPin_ns, OUTPUT);
pinMode(ledPin_ns1, OUTPUT);
}
void loop4() {
// here is where you'd put code that needs to be running all the time.
// check to see if it's time to blink the LED; that is, if the difference
// between the current time and last time you blinked the LED is bigger than
// the interval at which you want to blink the LED.
unsigned long currentMillis_ns = millis();
unsigned long currentMillis_ns1 = millis();
if (currentMillis_ns - previousMillis_ns >= interval_ns) {
// save the last time you blinked the LED
previousMillis_ns = currentMillis_ns;
// if the LED is off turn it on and vice-versa:
if (ledState_ns == LOW) {
ledState_ns = HIGH;
} else {
ledState_ns = LOW;
}
// set the LED with the ledState of the variable:
digitalWrite(ledPin_ns, ledState_ns);
}
if (currentMillis_ns1 - previousMillis_ns1 >= interval_ns1) {
// save the last time you blinked the LED
previousMillis_ns1 = currentMillis_ns1;
// if the LED is off turn it on and vice-versa:
if (ledState_ns1 == LOW) {
ledState_ns1 = HIGH;
} else {
ledState_ns1 = LOW;
}
// set the LED with the ledState of the variable:
digitalWrite(ledPin_ns1, ledState_ns1);
}
}