WEEK OF CODE: Jewelbots Challenge THREE


#1

Welcome to The Jewelbots Week of Code Challenge 3!!

Every day this week we will be bringing you a code challenge to bring you more fun with your Jewelbots. These challenges will start of easy and get progressively more difficult as the week goes on!

Above is a Coding Tutorial Challenge video! The beginning portion explains the basics of coding conditionals for your Jewelbot! Skip straight to 6:34 for the challenge.

Helpful Links:
https://jewelbots.com/go

Below is the code to easily copy and paste. Try changing the conditionals and their values around to see the different Jewelbot reactions!

LED led;
Timer timer;

void setup() {
  // put your setup code here, to run once:
}
void loop() {
  // put your main code here, to run repeatedly:
}

void button_press(void){
  for(int x = 1; x <= 9; x = x+2){
    led.flash_all(BLUE, 1000);
    timer.pause(500);

    //the || operator means "or". the && operator means "and".
    //when using conditionals, you have to use double == to mean "if x equals to 5"
    if(x == 5 || x == 9){
      led.flash_all(YELLOW, 1000);
      timer.pause(500);
    }
  }
}

#2

@Amy this time i triple uploaded my code to make sure there’s no errors! LOL hope you find it interesting and fun :smiley:


#3

It took me a minute to wrap my head around how these conditionals work, but this example code in the challenge was really helpful. Thanks!