Back

Sample Code for Friendship

There is a coding sample of how to use Friendship Coding board to do something cool when your Jewelbot sees your red friends. You can change this code to do different things for any and all color friends! Keep in mind that if you were to have code for two different friend colors AND you’re nearby both friend colors, then it will try to do both actions at the same time. This may cause animations to happen in a pattern or the color of the lights to blend.

Animation animation; void setup() { // put your setup code here, to run once } void loop() { //this code means “if see red friends, then do rainbow animations” if (see_red_friends()) { animation.rainbows(); } }

Note that the code for seeing red friends here is in the loop function, which means it will run continuously until you are out of range from red friends (so forever rainbows until you’re a part!!). However, if you want to see how to code an action for when you see the color friends for the FIRST time ONLY, then check out friendship code sample 2!

After pasting the code into Arduino...

1. Make sure your Jewelbots is plugged in to your computer

It is suggested that the original USB that came with your Jewelbots be used.

2. Select the correct Jewelbots Board and Port.

To select a Jewelbots Board: Go to Tools > Boards and scroll down to select "Solo Coding Mode".
To select the port: Go to Tools > Port. Windows should have "COMXX". Mac should have /dev/usberial-xxxx. (The X's representing numbers)

3. Press the magic button for 2 seconds to put your Jewelobts in Uploading Mode

Make sure it is 2 full seconds (1 mississippi...).
You should see a fading of purple lights, which represents the Jewelbots entering Uploade Mode.

4. Press the Upload Button on the Arduino IDE

It is the arrow button in the top left.

5. Unplug your Jewelbots to see the results!

When it says "Done Uploading", you can unplug your Jewelbots to see the code in action.
The act of your Jewelbots running custom code is called "Coding Mode".

Test out more code combinations

Try using different colors! (RED, BLUE, GREEN, WHITE, CYAN, YELLOW, MAGENTA)
Try using different animations too!

Share what you code for your Jewelbots

You can post your code creations on the Jewelbots Forums!