#include // Pin definitions #define AUDIO_PIN1 D2 #define AUDIO_PIN2 D9 #define LED_PIN3 D6 #define LED_PIN1 D7 #define LED_PIN2 D0 #define BUTTON_PIN1 D1 #define BUTTON_PIN2 D10 // Number of NeoPixels #define NEOPIXEL_PIN 12 int Power = 11; #define NUMPIXELS 1 // NeoPixel object Adafruit_NeoPixel pixels(NUMPIXELS, NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800); // Led and button setup int leds[] = {LED_PIN3, LED_PIN1, LED_PIN2}; // Color definitions uint32_t colors[] = { pixels.Color(255, 0, 0), pixels.Color(230, 26, 0), pixels.Color(204, 51, 0), pixels.Color(179, 77, 0), pixels.Color(153, 102, 0), pixels.Color(128, 128, 0), pixels.Color(102, 153, 0), pixels.Color(77, 179, 0), pixels.Color(51, 204, 0), pixels.Color(26, 230, 0), pixels.Color(0, 255, 0), pixels.Color(0, 230, 26) }; int colors_count = 0; int total_colors = sizeof(colors) / sizeof(colors[0]); void setup() { // Initialize pins pinMode(LED_PIN3, OUTPUT); pinMode(LED_PIN1, OUTPUT); pinMode(LED_PIN2, OUTPUT); pinMode(BUTTON_PIN1, INPUT); pinMode(BUTTON_PIN2, INPUT); pinMode(Power,OUTPUT); digitalWrite(Power, HIGH); // Initialize NeoPixel pixels.begin(); pixels.setBrightness(75); Serial.begin(9600); } void loop() { getting_ready(800, BUTTON_PIN2); // Tone frequency 800 Hz lets_get_out(500, BUTTON_PIN1); // Tone frequency 500 Hz } void color_chase(uint32_t color, int wait) { for (int i = 0; i < NUMPIXELS; i++) { pixels.setPixelColor(i, color); pixels.show(); delay(wait); } } void getting_ready(const int toneFrequency, int buttonPin) { delay(1000); Serial.println("Waiting for button press to continue!"); while (digitalRead(buttonPin) == HIGH) { delay(10); } for (int i = 0; i < 3; i++) { digitalWrite(leds[i], HIGH); tone(AUDIO_PIN1, toneFrequency); // Start playing tone for (int j = 0; j < total_colors; j++) { color_chase(colors[j], 200); } noTone(AUDIO_PIN1); // Stop playing tone } Serial.println("Engine Set"); } void lets_get_out(const int toneFrequency, int buttonPin) { Serial.println("Waiting for button press to escape!"); while (digitalRead(buttonPin) == LOW) { delay(10); } tone(AUDIO_PIN2, toneFrequency); // Start playing tone delay(2000); // Let the tone play for 2 seconds noTone(AUDIO_PIN2); // Stop playing tone }