Here is how you code the Jewelbots for Friendship

Back

This Library contains the full Jewelbots firmware and enables the user to add custom reactions to your friends and their color groups. Because of conflicts with existing Jewelbots functionality not everything that is available in Solo Coding mode is available in this Library.

Inside the Jewelbots Friendship Library, there are 4 functions that can be used to create custom reactions to friends. These 4 functions each return a boolean (true / false value) that tells the user if there are any friends of the selected color group present nearby.

The four functions are:
see_red_friends() see_green_friends() see_blue_friends() see_cyan_friends()

Once the Jewelbots Friendship board is selected in the Arduino IDE, there are examples available in the File menu. The example called "Friend_colorgroup_usage" provides an example of checking if any friends in the green color group are present and causes the Jewelbot to buzz and show an animation when a green friend is seen for the first time.

If you can't find the Friendship Coding board, then go to "Set Up > Install Boards > Step 8" of the instructions to see how to install it.

The four functions show changes on the same time period as the lights showing friend group colors. Something to keep in mind, although the Jewelbot checks for other Jewelbots wirelessly multiple times a second the lights and the see friends functions are only updated every few seconds. Similarly, it is important to note that the functions will return true continually when a friend is nearby, which is why the example shows one simple way to make the reaction happen only once when the color group is first encountered.

COMPONENT INTIALIZATION

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

The different functions are called the "API", because they are the way you interact with the device. APIs are ways you can work with different interfaces, sometimes in a computer and sometimes online.

API

see_red_friends()

This function returns true if any friends in the red color group are nearby. It returns false if none are nearby.

if (see_red_friends()) { // Commands to carry out when red friends are nearby }

see_green_friends()

This function returns true if any friends in the green color group are nearby. It returns false if none are nearby.

if (see_green_friends()) { // Commands to carry out when green friends are nearby }

see_cyan_friends()

This function returns true if any friends in the cyan color group are nearby. It returns false if none are nearby.

if (see_cyan_friends()) { // Commands to carry out when cyan friends are nearby }

see_blue_friends()

This function returns true if any friends in the blue color group are nearby. It returns false if none are nearby.

if (see_blue_friends()) { // Commands to carry out when blue friends are nearby }