Catch The Cupid!


#1

Yes, I needed help from Sara to make this program possible. I also needed my dad. Thank you both! This program is like catch the leprechaun but it’s valentine themed. Instead of green, you wanna press Magenta.

bool isMagenta;
uint8_t rand_value;

void setup() {
  // put your setup code here, to run once:
    set_arduino_button();
}

void loop() {
  // put your main code here, to run repeatedly:
  rand_value = get_random_int(1,7);
  color_chooser(rand_value);
}

void color_chooser(uint8_t ran_number){
    Color color = Color(0,0,0);

  if(ran_number == 1)
    color = Color(255,0,255); //magenta
  if(ran_number == 2)
    color = Color(255,20,147);
  if(ran_number == 3)
    color = Color(255,105,180);
  if(ran_number == 4)
    color = Color(255,192,203);
  if(ran_number == 5)
    color = Color(255,20,147);
  if(ran_number == 6)
    color = Color(220,20,60);
  if(ran_number == 7)
    color = Color(178,34,34);
    
   flash(color);
}

void flash(Color color){
  LED led;
  Timer timer;
  if((color.r == 255) && (color.g == 0) && (color.b == 255))
    isMagenta = true;
  else
    isMagenta = false;
    
  turn_on_all_special_color(led, color);
  timer.pause(500);
  led.turn_off_all();
}

void turn_on_all_special_color(LED led, Color color)
{
  led.setLight(0,color.r, color.g, color.b);
  led.setLight(1,color.r, color.g, color.b);
  led.setLight(2,color.r, color.g, color.b);
  led.setLight(3,color.r, color.g, color.b);
}

void button_press(void){
    LED led;
    Animation animation;
    Buzzer buzz;

    led.turn_off_all();
    
    Timer timer;
    if(isMagenta){
        animation.rainbows();
        animation.rainbows();
     }
     else{
        led.turn_on_all(RED);
        buzz.short_buzz();
        timer.pause(300);
        led.turn_off_all();
        timer.pause(100); 
        led.turn_on_all(RED);
        buzz.short_buzz();
        timer.pause(300);
        led.turn_off_all();
        timer.pause(100); 
        led.turn_on_all(RED);
        buzz.short_buzz();
        timer.pause(300);
        led.turn_off_all();
        timer.pause(100); 
     }
}

#2

Ooh, cool! :wink:


#3

Whoa, this is great! I’m going to load this on my Jewelbot today and play.