Now that you've created the solo gem fusion, it's easy to modify it to work on a dual gem setup. You'll use two Circuit Playground Express boards and then code them in a way that they can send messages to each other!
This will allow you to press the B button on one of them, for example, and they will both go into the Garnet fusion sequence fully synchronized!
Currently, there is a bug when using IR (infrared) communications and music blocks in the same code. So for this version, we'll start from the previous code and then delete the music related blocks and functions.
We want to send and receive messages using IR between the two Circuit Playground Express boards.
Click the Network category and add an infrared send number 0 block to the on button A click block as shown.
This means that whenever you click button A, an IR message will be sent out containing the number 0 as its message. We'll now duplicate this block and add it to the button b block, but change the message to be a number 1.
OK, now we are sending out unique messages with the two different buttons, but we need to also tell the Circuit Playground Express boards what to do when they receive a message!
From the Network category, add an on infrared received num block.
Conditionals and Comparisons
When the on infrared received block receives a message, we want to check to see if the message is a 0, meaning the A button was pressed, or if the message is a 1, meaning the B button was pressed.
The way we do this is with a conditional block found in the Logic category called if true then...else and a comparison block called 0 = 0.
Add them to the received block as shown here.
Now, we can tell the conditional block what to do in the two different cases. We'll duplicate the existing animation and light block contents of our on button A click block and place it into the if section, and then do the same with the on button B click block and place it in the else section. We don't need to duplicate the infrared send blocks.
Now, as you can see, when a button is placed on one Circuit Playground Express, it will send an IR message to the second one and they will both run through the same animation and light code together!
Upload the final code to both of your Circuit Playground Express boards (one at a time) and then plug both into power and try it out! Garnet's Fusion is complete!!
Tip: You can even try it out in the simulator! Just press one of the virtual buttons and a second CPX will appear.