My entry for Week 3 - Fruit


#1

This code is for @elliegalloway’s multiweek coding challenge, namely the current week, themed Fruit. The lights are supposed to look like various fruits, in order a banana, a strawberry, a blueberry, a fig, a mango, and a watermelon. There are comments within the code telling you which code modules make which fruit. The video also has captions telling you what each fruit is.

In addition to the Jewelbots API, I used the setLight command to make a few colors more detailed. I made a lovely golden-orange that I like quite a lot. The video does not do it justice. (The color code is 255, 140, 0, if you were wondering.) I used the RGB chart that @clara shared a link to a few months ago.

LED led;
Timer timer;
Animation animation;

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

}

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

}

void button_press (void) {
// first we have a banana
led.setLight(0, 255, 255, 0);
led.setLight(1, 255, 255, 0);
led.setLight(2, 255, 255, 0);
timer.pause(3000);
led.turn_off_all();
timer.pause(100);
// and now a strawberry
led.turn_on_single(NW, RED);
led.turn_on_single(SW, RED);
led.turn_on_single(NE, RED);
led.setLight(3, 0, 204, 0);
timer.pause(3000);
led.turn_off_all();
timer.pause(100);
// how about a blueberry
led.turn_on_single(NW, BLUE);
led.turn_on_single(SE, BLUE);
led.turn_on_single(NE, MAGENTA);
led.turn_on_single(SW, MAGENTA);
timer.pause(3000);
led.turn_off_all();
timer.pause(100);
// and now a fig that has been cut in half
led.setLight(1, 25, 0, 51);
led.setLight(0, 25, 0, 51);
led.turn_on_single(SE, RED);
led.turn_on_single(NE, RED);
timer.pause(3000);
led.turn_off_all();
timer.pause(100);
// a mango
led.setLight(0, 255, 140, 0);
led.setLight(1, 255, 140, 0);
led.setLight(2, 255, 140, 0);
led.setLight(3, 255, 140, 0);
timer.pause(3000);
led.turn_off_all();
timer.pause(100);
// a watermelon cracking open
led.turn_on_all(GREEN);
timer.pause(1000);
led.turn_on_single(SE, RED);
led.turn_on_single(SW, RED);
timer.pause(500);
led.turn_on_single(NW, RED);
led.setLight(2, 0, 0, 0);
timer.pause(3000);
led.turn_off_all();

}


#2

THIS IS SO GREAT. WHAT AN AWESOME VIDEO. I love it.


#3

Thank you, @sara! That means so much to me!


#4

AWESOME! :grinning: