/* Blink - RP2040-Zero-makey_bot Test neopixel Test servo Turns an LED on for one second, then off for one second, repeatedly. This example code is in the public domain. https://docs.arduino.cc/built-in-examples/basics/Blink/ */ #include #include // Import Servo Library // create servo object to control a servo // my_servo can be any name. Servo makey_wave; int pos = 0; // variable to store the servo position #define LED 26 // LEARN: Built-in LED on pin 13 #define neo1_pin 16 // LEARN: NeoPixel data pin #define NUM_LEDS 1 // LEARN: How many NeoPixels are in the strip int BRIGHTNESS = 50; // LEARN: 0 (off) to 255 (full brightness) // LEARN: Create the strip object: (number of pixels, data pin, pixel type) Adafruit_NeoPixel neo_pixel = Adafruit_NeoPixel(NUM_LEDS, neo1_pin, NEO_GRB + NEO_KHZ800); // ---------------- Color Table ---------------- // the setup function runs once when you press reset or power the board void setup() { makey_wave.attach(2); // Servo on pin 9 to servo object pos = 0; // Set position Variable // initialize digital pin LED_BUILTIN as an output. pinMode(LED, OUTPUT); neo_pixel.begin(); // LEARN: Get the strip ready neo_pixel.setBrightness(BRIGHTNESS); // LEARN: Set the overall brightness neo_pixel.show(); // LEARN: Send the data, which turns all pixels off to start makey_wave.write(pos); // Set the default start position delay(1000); // Delay just a bit to get into position } void neo_pixel_blue(){ int PIXEL = 0; neo_pixel.clear(); neo_pixel.show(); neo_pixel.setPixelColor(PIXEL, neo_pixel.Color(0, 0, 255)); // LEARN: Color(red, green, blue) neo_pixel.show(); // LEARN: Nothing changes until show() runs } void neo_pixel_red(){ int PIXEL = 0; neo_pixel.clear(); neo_pixel.show(); neo_pixel.setPixelColor(PIXEL, neo_pixel.Color(255, 0, 0)); // LEARN: Color(red, green, blue) neo_pixel.show(); // LEARN: Nothing changes until show() runs } // the loop function runs over and over again forever void loop() { delay(500); neo_pixel_blue(); delay(1000); neo_pixel_red(); delay(1000); makey_wave.write(120); delay(1000); makey_wave.write(0); delay(1000); digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }