Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create example files for cpx for existing examples #50

Open
totally-not-frito-lays opened this issue Jul 17, 2024 · 0 comments
Open

create example files for cpx for existing examples #50

totally-not-frito-lays opened this issue Jul 17, 2024 · 0 comments

Comments

@totally-not-frito-lays
Copy link
Member

Is your feature request related to a problem? Please describe.

Describe the solution you'd like

/**
 * Activity 1: Get those lights on!
 * 
 */
#include <Lantern.h>

Lantern lantern;

/**
 * @brief This function only runs once to "setup" the Lantern.
 * 
 */
void setup() {
  lantern.begin();
}

/**
 * @brief This function repeats itself, like a loop!
 * 
 */
void loop() {

  if (lantern.slideSwitch()) {
    // slide switch is left
    checkLight();
    checkLightWheel();
    rainbowWheel();
    checkLightWheelBig();
  } else {
    // slide switch is right
    changeWheel();
  }
}

/**
 * @brief Sets color values for our lantern. Used to check if our Lantern is 
 * ready to accept instructions.
 * 
 * Not getting the color you want? Check out this website to learn how to pick
 * your color using just Red, Green, and Blue!
 * - [RGB Color Picker](https://www.w3schools.com/colors/colors_rgb.asp)
 */
void checkLight() {
  int red = 0;
  int green = 150;
  int blue = 0;
  float seconds = 0.5;

  lantern.setColor(seconds, lantern.rgb(red, green, blue));
  wait(1);
}

/**
 * @brief Sets color values for our lantern. Used to check if our lantern is
 * ready to accept instructions.
 * 
 * Instead of using 3 numbers, we can just a single number! This allows us
 * to grab a color from the rainbow if the rainbow was a line from 0-255 
 * starting at red, then going to green, then blue, the finally back to red.
 * 
 */
void checkLightWheel() {
  // Try changing the number to any other number you want!
  lantern.setColor(0.5, lantern.colorWheel(0));
  wait(1);
}

/**
 * @brief Sets the color values for our lantern. Goes through all the colors
 * of the rainbow this time!
 * 
 */
void rainbowWheel() {
  for (int i = 0; i < 255; i++) {
    lantern.setColor(0.1, lantern.colorWheel(i));
  }
  wait(1);
}

/**
 * @brief Sets the color values for our lantern. Demonstrates that any number
 * fits in the color wheel.
 * 
 */
void checkLightWheelBig() {
  float seconds = 0.5;

  lantern.setColor(seconds, lantern.colorWheel(-500));
  lantern.setColor(seconds, lantern.colorWheel(500));
  wait(1);
}

void changeWheel() {
  int wheelPos = 0;
  if (lantern.leftButton()) {
    wheelPos += 1;
  } else if (lantern.rightButton()) {
    wheelPos -= 1;
  }
  lantern.setColor(lantern.colorWheel(wheelPos));
}

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant