Let's make Spencer talk
Let's try something more advanced now - we're going to make Spencer generate and "say" a unique piece of dialogue every time we smack his big red button.
Start fresh by creating a new sketch. Save it right away and name it something snazzy (I've named mine "best_code_ever").

Next, we need to connect Spencer to a WiFi network.
Spencer needs internet access to "talk". The way this works is that Spencer connects to our server and sends the text it wants to say. The server then generates an audio clip using a TTS (Text To Speech) algorithm and sends it back to your Spencer.
For connecting to the WiFi network, you'll need the "Set SSID and password" block located under the "Network" category.

Drag the block on the drawing area and enter your WiFi network's name and password.
SSID is the name of your network.

When we set the login details for the network, let's make Spencer show the "WiFi" animation. We can do this by adding this block over here:

Now you need to drag and drop the "Connect to WiFi network" block. This block initiates a connection routine.

Place the block here:

Now we'll need the logic IF-THEN-ELSE block. We'll use this block to check whether the WiFi network connection was established successfully.

Take the "wifi is connected" condition from the "Network" section.

Place it into the logic IF-THEN-ELSE block as a condition like this:

Let's play a specific sound sample and animation if the wifi connection is successfully established.
I've chosen the smiling animation and a sound effect named "badum 0" because it sounded funny:

If the WiFi internet connection is not successfully established, let's play the animation and audio sample called "no WiFi".

This program will proceed if Spencer successfully connects to the network. If not, Spencer will tell you that it's having trouble connecting to the WiFi network.
Now let's add the "When button gets pressed" event block:

Check whether WiFi is connected every time the button gets pressed. Do it with the same IF-THEN logic block and put "wifi is connected" as its condition:

Spencer will need a short time to generate the audio sample that we want. Let's play a loading animation while the sample is generating:

For the next step, open the category called "Speech" and find the "synthesize and say" block.

Place the block here and type in the sentence you want Spencer to say. I've typed in "Hellow world. This is my first program".

When the dialogue voice sample gets generated (synthesized), it will be automatically played.
When that happens, let's make spencer's face look like he's talking by playing the animation named "talk".
When Spencer finishes talking, I'm going to play the animation called "wink".

Remember to save your hard work by pressing the save button on the top left.
Run the code and upload it to your Spencer. Every time you press Spencer's button, it should read aloud the text you have written into the "Synthesize and
say" block.
If your Spencer is having trouble connecting to the Wi-Fi network, check the network name and password and try turning your spencer off and on again.
Remember, Spencer only works with 2.4GHz (IEEE 802.11 b/g/n) WiFi access points.
5GHz (IEEE 802.11 ac) networks, unfortunately, aren't supported.
If you're having trouble making your Spencer talk, reach out to us via contact@circuitmess.com, and we'll help.