In this tutorial you’ll set up a Particle account, claim the Particle Photon that drives your Infinity Kit, and see how to flash a program to your Infinity Kit by making a slight tweak to its default code.
Let's program our infinity Kit. To follow along you'll need a Wi-Fi network that has internet access and also a smartphone that has the Particle app already installed so if you haven't got that app installed, install it now and if you don't actually have access to a smartphone you can follow particles own guide to do this over USB.
The first thing we need to do is put our photon in the listening mode. So power up your Infinity kit and turn the knob all the way to the left which should be the off state. Then press the left button through the case that's the setup button and when you briefly press that your photon should start blinking blue. It's now ready and waiting to connect to a Wi-Fi network.
With the photon ready and waiting we can open up the particle application and hit the get started button if you haven't already created an account with particle here's a good opportunity to do it but I already have an account so I'm just going to log in with the link below.
Once logged in you should see an empty list if this is a new account I already have a photon on my account but to add our Infinity kit we just go to the top right and hit the plus button to add a device and I'm going to start a photon because that's what I'm using and now we just follow the prompts so we just hit ready making sure our photon is already flashing blue and we need to now connect to a little Wi-Fi network that the photon is hosting itself this is how we're going to pass it some information about what to do. So I'll navigate to my settings and I can see an entry second down which is photon and then a couple of letters that's a unique identifier so that is the little network the Wi-Fi network that's being hosted by the photon that I need to connect to and once that's happened I get a little notification to return back to the particle app. And I get presented with the option to claim this device because this is an unclaimed device I want to attach it to my particle account so I'll select YES for that and now we need to tell the particle photon what Wi-Fi network it needs to connect to this is how we're going to upload it code to it over the Internet so I'm just going to enter some Wi-Fi credentials.
And you see photon was flashing green there for a moment and now it's breathing cyan which means that it's connected to a Wi-Fi network I'll just wait for my application to finish verifying the ownership and okay so the the photon has been claimed now we have the opportunity to give it a name and it's really useful to just name it after whatever project that's being used in if you have multiple photons it makes sense that you refer to them by how they're deployed so I'm going to call this infinity kit and hit done. Excellent great big green success message and I can now see that I have an entry called infinity kid under my devices and even better we have this breathing blue or cyan next to it so that's telling me that this Photon is connected to the Particle cloud when it's online.
With the photon claimed jump over to particle.oi and login with that same particle cloud account that you use to claim your photon once you logged in just navigate to the IDE this is the code development environment and once you're in the IDE you can see where we have an empty script basically so I'm going to basically use the default firmware as an example for this tutorial and we'll just make a little tweak just to make sure that we can upload code correctly to our Photon. So in this in your application I'm just going to call it infinity default that's as good as any and I can just use this folder button on the left to save it so now under the heading my apps I have infinity mirror which is an old project and infinity default this is the code that we're going to essentially copy in for this project.
So just grab the code that's attached to this tutorial I've already copied it so I can just highlight everything that's already in the script that those empty set up and loop functions and paste it in and here is the default code that runs on your photon. The only other thing we need to do to get it to run properly includes a library so we can go down to this kind of bookmark tab here this is the libraries and on the very first page we have the neopixel library if you don't see that you can always type to search but click on neopixel all we need to do is click include in project it's just showing us a preview of the library for now but I'm just going to click include in project and we need to select which application.
So infinity default if you've already got two applications then you'll get that option and just confirm that decision. So here we are back in infinity default and if I scroll all the way to the top you can see a comment that says this was included automatically by the particle ID when you include libraries particle dropping a piece of code into your sketch or your script or particle app that invokes it. I already have that line in the code though so you can leave that in or you can delete it I'm just going to delete it for now because it's kind of redundant. Okay so now we have the default code on our browser and our particle is already running the default code so if we upload this to the Photon it's not going to behave any different, we need something to see that it's behaving differently.
So you can see that rainbow effect moves pretty slowly around the photon so just to make sure that everything's working I'm going to speed it up a bit.
So what I have in mind is for this rainbow effect to move a lot faster around the mirror and to do that I just need to a parameter so if we scroll down past the setup routine past the loop routine don't worry if you don't know what these things off and now it's not super important we're just looking to make sure we can upload code past get stayed past the comet we want to find this routine called rainbow so as it stands it's around to line 219 after I've pasted it in but I've made a few edits so it'll be around there for you as well and we want to find this delay this is the this is the time in between frames of animation you can think and it's in milliseconds so at the moment there's 42 milliseconds between each frame of that animation of those colors moving around the perimeter of the mirror so if we want to speed it up really fast we could put in a zero that would work I'm just going to put in something but let's let's put in zero let's see how that goes so I've changed the code.
We should now see if this is uploaded something happening to upload it to the photon remember it's already connected to Wi-Fi so I just need to make sure I have the right device selected there's my infinity kit and I can see that the device is connected I just need to make sure that this star is selected that's the device we want to program so just make sure that star is selected and when it is you'll even see a status down in the bottom right showing what it is it's a photon it's called infinity kit and it's connected. So once you've selected the target you can navigate up to the top left of the window this lightning bolt symbol that's going to flash our photon.
I've hit the flash button it's currently compiling and then it's going to flash to the photon so we should see this indicator lamp suddenly change its behaviour okay that might have happened already oh yeah. We spin it around we can see that rainbow effect is just going crazy it's gone full disco. So if everything's gone to plan you should see your your Infinity kit behaving a little differently now that rainbow effect is going full disco every made that should remain unchanged so if you as you turn the knob to look at the other modes you should see that they're all just about as you might remember them.
Just a quick note that if you're going to mess around with some more parameters and change some numbers you'll have to press that setup button once again to get your photon to connect to the network so you'll have to rotate the nut all the way to the left and just press that setup button except instead of flashing blue as if in listening mode the photon will now flash green and then breathe cyan to show it's connected.
So there you have it a quick tutorial to show you how to reapply the default firmware to your Infinity kit but then just tweak the parameters a little bit to make it changes behavior if you'd like to learn how the default code really works in depth then we're going to take a dive into it in the next tutorial I'll see you there.[Music]