Connect Arduino to internet over USB (with Processing) – Simple Space Weather forecast meter example
Transcript:
Have you ever wanted to connect your Arduino to the internet? Your first thought was probably like okay, I guess I’ll need some type of Wi-Fi shield or a Wi-Fi enabled board in order to connect to the internet. But what if you’re building something that’s more of a desktop project? That is you fully anticipate that it’s gonna be sitting right next to your computer. And if you want this thing to have internet access, like does it really have to connect over Wi-Fi? So then your next thought might be well, if it’s not gonna be Wi-Fi, I probably need to get an Ethernet shield or something like that so I can connect my Arduino directly into the Ethernet. But there is another option that doesn’t require Wi-Fi or Ethernet. It’s just connecting your Arduino via USB to your computer, assuming that your computer’s connected to the internet. What you’re able to do is use the Arduino Serial library to communicate with an application on your computer that manages your internet requests. So if you go this route, all you need is an Arduino board and a USB cable, and you can connect to the internet. No other hardware needed. All you have to do is install some open source software called Processing and write a small program to grab the information that you want from the internet. Now, what we’re gonna do in this lesson is walk through that process from start to finish. So by the time you’re done here, you will be able to get information from the internet down to your Arduino board over a USB connection to your computer. Now, to demonstrate getting some information off the internet, we need some type of example. So what I’ve set up and what we’ll demonstrate in this lesson is grabbing some space weather forecast information from the NOAA website, that’s the National Oceanic and Atmospheric Administration website. So our program is gonna grab some information, it’s gonna be called the Planetary K-index. It’s a measure of the magnitude of geomagnetic storms. It’s just a number, it’s a number from zero to nine. We’re gonna grab the current forecasted number from the internet, and then we’re gonna pass that number down to our Arduino board and then our Arduino is gonna light up a number of LEDs based on that number. So if the forecast, if the KP forecast is five, then we’re gonna light up five LEDs. If it’s eight, we’ll light up eight LEDs. I think you get the idea. So by the time we’re done here, we’re gonna have a super simple space weather forecast widget sitting next to your computer. All right, let’s get started. Subscribe to our YouTube channel to get more videos like this. Before we start, just a big shout out to Altium for sponsoring this video. Huge thanks. You can check the description to get a free trial of the Altium software. All right, so this is what we’re gonna do. We want a computer program on our computer to grab specific data from the internet and then pass that data over the USB cable to our attached Arduino board. And then we want our Arduino board to be running a program that keeps an eye out for incoming serial data. And when it gets that data, we’re gonna have it do something with it. And in this case, we’re gonna light up some LEDs. So that sounds like a lot but thanks to open source libraries, it’s not gonna be all that crazy. Now, when I’m working on a project like this, there’s two principles I like to keep close to my heart. The first one is I always like to start with just a simple plan. The second thing is I always like to look for code examples to kinda get me started. So first, let’s go ahead and write out a simple plan of what we need to do. I wanna connect to the internet with some program on my computer. I wanna send data from that program to my Arduino. I wanna have my Arduino read in data from that program. And then I wanna light up some LEDs on my Arduino based on that data. The first thing I’m gonna try and figure out is how to write a program that sits on my computer and sends data to my Arduino. So what I’m gonna do is use a programming language called Processing to do this. Now, you can download Processing for free. It’s open source software, just like the Arduino. So I’m gonna go ahead and download the processing. What we are downloading here is an IDE, so an integrated development environment. So when you download Arduino, and you install it, same idea. You’re downloading and installing an IDE, and what I’m doing is downloading and then installing the Processing IDE. So it’s really simple to download and install. Do you need a printed circuit board design software to move your prototype to the next level? Altium Designer is a great choice for designing PCBs, sharing your design with team members and even getting your design manufactured. What really kind of blows me away about this software is that even though it’s a super powerful tool, at the same time, it’s really intuitive to use. They’ve got helpful video tutorials built right into the software so you can kickstart your learning process and actually get something made. Right now, you can get a free trial to Altium Designer with our link in the description. That’s right, you can test drive this super powerful software with a free trial. Just check out the link in the description. Now, when you open up Processing, you are gonna notice that it looks a lot like the Arduino IDE. And that’s because the Arduino IDE was actually based on the Processing IDE. All right, so here we are on the Processing IDE. And what I wanna do is open up an example sketch. So if you go up to File, and you go to Examples, they’ve got a bunch of different examples in here, and the one we’re gonna use is from their Serial library. Here it is right here. And you can play around with any of these but we’re gonna play around with the SimpleWrite. I just wanna write a program in here. I wanna use a program in here that’s gonna send a piece of data to my Arduino. So lemme click on this and here is this sketch right here. So what’s cool about this sketch is that not only does it have the Processing code in here that’s going to run on the computer but it also has the code that runs on the Arduino. So what I’m gonna do is I’m gonna copy this code right here and I’m gonna paste it in my Arduino IDE. I’ll get rid of these comments here. Do some formatting. Now, on my Arduino, I’m gonna have an LED attached to pin six. So I’m just gonna change that but otherwise, it should be the same. I’ll make sure to save this. And then I’m gonna make sure my Arduino board is connected. So Arduino Uno, yip, there it is. The port. All right, COM3, Arduino Uno. I just wanna take note of that. All right, COM3, Arduino Uno. And let me just upload this sketch to my Arduino. Now I’m using the kit on a shield on top of my Arduino so I don’t actually have the, like I don’t have a breadboard wiring up the LED. I’ve just got the kit on a shield there. But it’s just gonna have an LED at pin six. And all this sketch is doing is it sets the mode of the pin as an output, so pin six is gonna be an output. Start serial communication using a baud rate of 9,600. And then down in the loop, it’s got a while loop inside the loop. And it says hey, if anything’s available on the Serial buffer, then we wanna read that value. So Serial.available is gonna return either true or false based on whether or not there’s information in the buffer. So if it’s true, read the value from the Serial buffer and store it in a variable called val. And that value is either gonna be an H or it won’t be anything. If it’s an H, if you get a value, then the LED is gonna turn on. We’ll do digitalWrite HIGH, so we’ll turn the LED on. Otherwise, we’re just gonna turn the LED off and then there’s gonna be a delay of 100 milliseconds. That’s it. So right here, this line 14 is what’s looking for data coming into the Serial buffer. This is what’s allowing the Arduino to sit there and wait for information to come in and respond when information does come in. All right, so let’s take note of that. So it was COM3 is the port we’re using. And we’ve already got the Arduino. They gave us the sketch to set it up to look for information coming to the Serial port. Now we’re gonna come over to this Processing sketch. Now, I’m not trying, you know, this isn’t gonna be a lesson on teaching you all the ins and outs of Processing ’cause one, I couldn’t do it, I don’t know Processing all that well but I know it enough to kind of like be dangerous. So let’s just start at the top here. Basically, what this sketch is doing is it’s importing the serial library from Processing. And then it creates a Serial object. This Serial object is what allows Processing to talk to the Arduino, okay? Now, in this case, we are calling the Serial object myPort. So that’s what they’re using here, myPort. Now, I like to call it like Arduino but you can call it myPort, it doesn’t really matter. Now, they’ve also got another integer called val here. I’m not sure I’m actually gonna use that in here. Are we using val? No, I don’t even think they use val in this program but I think that’s a carryover from another example they have. All right, so Processing, just like Arduino, has two very important functions. So one is called setup, just like Arduino’s setup. It runs once. And then the other one is called draw. So draw is to Processing what loop is to Arduino. So Processing is a visual arts software. The idea is that you use this software to make like these visual like graphics I guess is the way to put it or interactions, I don’t know. It’s really pretty cool. I’ve played around with it a bit. It’s been a while but it’s super fun to work with. Anyhow, what happens is every time you hit this play button, a little app opens up on the computer and like there’s a little window that opens up. Here, I’ll just hit play here real quick here and you’ll see this little window pop up. You’ll see this little window. This is like where stuff happens inside your app. So like visual stuff, what happened here. But the size of that window is determined by the size function. So that’s what this size is doing. Now, this is where we’re interested down here at line 21 and 22. All right, so this is probably gonna be the toughest part of this entire thing, right? ‘Cause it’s just a little bit confusing. So we use this function called Serial.list, all right? Serial.list is going to return an array. So an array is just a list of things. In this case, it’s going to return an array of all the Serial ports on your computer. So there’s gonna be a list starting at one or starting at zero, going down to whatever of all the Serial ports. Now, right now, we have zero selected, okay? So this is saying whatever the first element in this Serial.list array is, we are gonna set it equal to portName, okay? So basically, the port we wanna associate with this Serial object up here, we are saying it’s the first element in this array but we don’t know that yet, right? This is just kind of a default setting. So what we need to do though to figure out which Serial port our Arduino is attached to on this list is we actually have to print this out to kind of get an idea of where it is. So I’m gonna use the printArray function to print off the list of Serial ports. So lemme do that. All right, so now when I hit play, down here, I should see a list of all the Serial ports attached to my computer. So here, there is only one Serial port, it’s COM3. So that’s your Arduino I have attached. Now, you might be like wow, why did you go through the trouble of printing it off? On most computers, or at least on other computers I’ve used, there’s a huge list of different ports available, right? This one happens to be at zero. Okay, so this is gonna work. I’ll just set this to zero and that should work fine. But if it’s not, let’s say there was like a COM1, a COM2, a COM20, whatever, wherever COM3 was, whatever value in that associated array, that’s what I would wanna set line 22 equal to, if that makes sense. All right, so this line 21, we’ve got a string, we’re calling it portName and we’re setting it equal to the zeroth element in this list of Serial ports. Right now there’s only one Serial port in the list, so it’s gonna be set at zero. All right, then what we do is we initialize that Serial object. And it takes three parameters. This portName, which is the name of the port, so you’ve gotta put the port that we’re gonna have it look at or send to right there and then the baud rate. So that’s gotta match up. Whatever you’re using in your Arduino IDE, you need to use here. So we’re gonna be using 9600 as the baud. So I know this syntax is a little bit different. We’re using a, it’s like the Serial constructor to create a new Serial object. So that’s a little weird but if you just kind of use the example code, it kinda draws it out there. So what this is gonna do, and this isn’t too important. I think the most important thing I wanna focus on here, down here is what this line of code right here where it says myPort.write. If we wanna send something serially over to the Arduino to the Serial port that the Arduino’s monitoring, we use the .write function. So myPort.write, again myPort is a Serial object that we created up here, right? So myPort is a Serial object and so when we say myPort.write, write is a function of that Serial object and so whatever we write here, that’s what’s gonna get sent over. Now, in this case, what happens is lemme go ahead and hit play here, is this opens up a little square. So with this program, when my mouse is over the square, the square changes color and it sends an H to the Arduino and so when the Arduino gets the H, it turns on the LED. And then when I’m off the square, it sends an L and then that tells the Arduino, hey, don’t write anything. So you can turn the LED on and off like this, which is kinda fun to do. Really simple, you know what I mean? But again, the basic concept here is we need to use this myPort.write. Okay, so again, this is just waiting. Here we are in the Arduino IDE. We’re waiting for some information. Once it comes in, we check hey, what is the information? Based on the information, we do something. In this case, we’re turning an LED on or off. Okay, so now we’re armed with this basic information but now what we wanna do, instead of sending like an H or an L based on like hey, some square, mouse over square, what we wanna do is grab information from the internet and send that to the Arduino. Okay, so how are we gonna do that? All right, well, what we’re gonna do is we’re gonna reach out and connect to an API. So that is an Application Programming Interface. You’ve probably heard of APIs before or at least in passing but basically, it’s a way for organizations or companies or whatever to expose information in a database so that you can use it publicly. So you might think like Google Maps, right? Google Maps has an API so that other applications can basically point to that API or grab from that API and then implement those Google Maps inside their app. Or think of weather, right? There’s all different types of applications out there that show you weather but they’re all probably getting their information from different weather APIs out there. They’re actually pulling down the actual forecasts from some API, like NOAA, for example. So that’s what we’re gonna do. So here I am on the NOAA website and I am just gonna go, I happen to know where this is. If you just search Space Weather API would probably be quicker, but I’m just gonna kind of go and walk through this. So here I am at home, I wanna go to the tools and resources and let’s see satellites, techie. I wanna get information from satellites. I’m looking for Space Weather. I wanna get a three-day forecast. So let me click on this. And now it takes me to this Space Weather Prediction Center. That sounds cool. So now I’m gonna go to Products and Data. And this is kind of where they list some of their different APIs over here. And we said we were interested in, let’s see, we’re interested in some observations. Here we go. There we go. We wanna get planetary K index right here. So right here, this is the graph of that K index that I was talking about, or I guess it’s KP index. So on January 22nd, it was three. It was two, let’s see, on January 23rd, it was three, it went down to two, today, it’s like up at one right now. That’s the number? That’s this K number. So what I wanna do is I actually wanna get this number from their API. So I have to have a URL that I go to and when I go to that URL, and I do a GetRequest, I will be able to get data based on this value right here. So that sounds all crazy and stuff. What the heck am I talking about? Well, let me just show you here real quick. Let me, so what I’m gonna do is let me get out of full screen mode so we can see this URL up here. So how can I actually get this value? So let’s go back to products and data, and we’re gonna come down here and we’re gonna say data access. So we’re at this data access, and now we wanna go to, we wanna get this via JSON, so we can go here. And it’s gonna give us a list of a bunch of different stuff we can access. So this is like a list of their different API end points, basically. And we’re looking at the geospace stuff. So here we go. There’s a one hour, the seven day. And then this is the estimate. This is like what they forecast right here. So I’m gonna click on this and then you see all this information right here. So this right here is the JSON response. So like when we go to this URL right here, when we go to this URL, what gets returned is all of this stuff right here. Now, if you’re not familiar with, like this looks kind of get gobbLEDygook. But this is actually any format called JSON. And JSON stands for JavaScript Object Notation. And it’s basically a way of organizing data and sending it over the internet. It’s really pretty common. There’s other ways to do it, for example, XML. But JSON is really pretty popular. Now this looks like gobbLEDygook, but if you go to a website, you can make it look nicer. So let me just find a website real quick and we’ll translate this to something nice. So what we’re gonna do now is I’m just gonna take all this stuff that looks kind of gobbledygook ish. I’m gonna copy it and I’m gonna paste it right in here. And now you’ll notice, look how not gobbledygook this looks. This is all of this data, but now it’s kind of like laid out so that it looks more clear. And what we can see is that there’s many entries of the exact same thing. And there’s two values inside here. And each name has a value associated with it. So model prediction times. So this is the time that this K value was taken or this observation or prediction was made. And then we actually get the K value itself. In this case, it’s a floating point value. It’s 1.66. So when we go to that URL, we get an array of all this stuff. We get an array of a bunch of JSON objects. And that’s just, you see these curly braces. And so basically you have a curly brace that is gonna delineate one of these objects from another. So there’s a big list of stuff. What we’ve got to do basically is first we’ve got to grab this information and then we need to parse it. Like we need to go through each one of these. We’ve got to find which one of the observations we want. And then we need to dig into that observation and pull just the K index, just this K value. We wanna get that value. So let’s do that real quick here. We’re gonna do that inside processing. And the way we’re gonna do it is using a library, an open source library that is gonna do the GetRequest for us. So what I’m gonna do is go to sketch, import library, and I’m gonna add a library. And the one I’m looking for is called HTTP Requests. Let’s see if this will find it for us. There it is. HTTP Requests for Processing, right here. So I’m gonna go ahead and install this. It’s instalLED. And now when I go to file, examples, I should see a new folder down here called contributed libraries. And I can see they’ve got a bunch of examples for HTTP Requests. Now, if you don’t see this, if you don’t see contributed libraries after you install that, you might have to close processing and open it back up in order to see this. When I was on my Mac, I had to do that. But what we’re gonna do is open up this, JSON get. So I keep saying like, getrequests. You might be like, what am I talking about? So like with a HTTP or hypertext transfer protocol, there’s different ways of communicating from one computer to another. One of those ways is called a get. It’s like a getrequest. And it’s just like a standard protocol for getting information from another website. So when I’m saying, get, that’s what I’m talking about. So I’m gonna go ahead and open this up. And in this program we can see on line one, it says, import HTTP.requests. So this is the library we just instalLED and we gotta make sure to import it. And then we can see what is it doing here? So it’s got an object here called GetRequest. They name it get, and they sit at equal to GetRequests. And then they put a URL in here. And what this is doing is it’s hitting, just a kind of dummy end point right here. So what we need to do is get our URL and paste it inside here. So let’s do that. So here’s our URL up here. I’m just gonna copy that. And now here I am inside here. Now we need to keep these quotes. So what this program is doing this first line right here is it’s creating this GetRequest object. We’re naming it get. And this GetRequest object is gonna be associated with that URL end point that we put in here. So that’s what the GetRequest is. And again, we need to get. So now when we do get. Send, the program’s gonna go out and it’s gonna look at this URL end point and any data that comes back, any JSON data, it’s gonna store inside this get object. And then there’s other functions that we can call. Like here we’re using get. Send. But we got getContent and just some other stuff that we’re able to do. So let’s go ahead and hit play. And what we should be doing is printing off the stuff that we saw on that webpage. So let me just hit play here and see what happens. Cool. So now we did get an error, that’s never fun. Did get an error, but we do see that we got all this information. So you see down here in this console, this is all that stuff that we just pulLED. So that’s pretty cool. So we’re onto something. We’re actually able to grab the information. So now what we do is we have to parse it. Now, the error that we’re getting here has to do with the fact that we are getting an array back and we are trying to parse it as a simple object. So what we need to do is we need to get this content and then put it into an array. So let me do that. So this might look like a bit of like, gobbLEDygook, like what the heck’s going on. So let me try to walk through this. So we said that the GetRequest is going out, it’s getting all of that data. So all that data is still down here. It’s like this huge, this glut of stuff, it’s an array of JSON objects. So what we do first is we create another object called a JSONArray. We name it response, and we set it equal to this parse function. So it’s parsedJSONArray. And what we’re doing is we’re grabbing all the content. So this whole thing is getting passed into this parseJSONArray. And basically it allows us to organize this data into a JSONArray. So we’ve got all this information in a JSONArray. Now what we wanna do is we wanna grab a specific reading out of that array. So what I’m doing is I’m creating another object called JSONObject. And again, this is all, these are like keywords from the processing library. If you go to the documentation and you look at JSON, it’ll come up with these different functions and objects that you can use. So that’s kind of what I did. I just looked at the documentation. It’s pretty straightforward on their website, but again, the idea is we’ve got an array of these objects, and then we wanna make a specific object. So what I do is I get that JSONObject. And the one I wanna get is the last reading. ‘Cause if we go to the webpage, we can see that the last reading, this is what, 2022, this one’s at 1945. So this last reading here is more current than this first reading. So this is the value we wanna grab. So I wanna grab the last value inside the array. So how can I get the last value inside the array? Well, what I can do is I can get the size of the array. So response again, is this JSONArray. So I just do response. Size. That’s gonna give me the length of the array. And then I subtract one. So let’s say there’s like, I don’t know, 10 elements inside this array. If I wanna get the last element in the array, since arrays are zero indexed, I have to actually look at the ninth, I’ve got to look at the ninth index. Hopefully that makes a little bit of sense. If you’ve got questions about arrays, make sure to check out the other videos on our channel. We talk about arrays and the fact that there’s zero index, if odd to you, then you can check those out. Any who? So all you do is you subtract one from that. So we’ve got the size, we subtract one. That’s gonna give us the last element in the array. So now this object, this data object is equal to this right here, this last entry. So we’re gonna get model prediction time. It’s gonna give us this time. And then it’s also gonna give us the K value. But all we’re interested in is the K value. So to dig down into this K value, I create another variable. It’s an integer, I call it K index. And I set it equal to data.getFloat. So data is that JSONObject. So data is the JSONObject and I wanna get a specific value from the object. So I use this getFloat function and I’m getting K. So K’s just the name. If I wanted to get model prediction time, I’d just write, model prediction time right in here. But I wanna get K, right? So I’m grabbing K. And then notice I have it inside this function called int. So this integer function is gonna take this float value and it’s going to turn it into an integer value because I wanna display it as a whole number. I don’t wanna display it as a floating point number. It’s just gonna be either a zero, one or two, so forth and so on. So that’s why I’m casting this as an integer. And then I’m just kind of printing that out down here. So if I look down in the console here, I can see that I am actually grabbing K index and it is currently a one. So hopefully that makes a little sense. So now what we’ve got to do is we’ve got to find a way, how can I get this value and send it over to the Arduino? So what I’m gonna do now is write a little bit of code and we’re gonna basically combine those two sketches we had before. So the other sketch was writing information to the Arduino. So I’m gonna just grab some of that code, I’m gonna write it in here and instead of sending, an H or an L, I’m gonna send this integer right here. So let me do that. So I have reformatted this program a little bit, and this is what I’m doing. So up at the top, I’m importing HTTP requests and the processing serial library. So I’ve got both of these in here at the top of the sketch, I’m creating this serial object, I’m naming it Arduino. And then at the top, I’m also creating this GetRequest. So I’m passing that URL. That was the API end point for the Space Weather to get that forecast for the most recent hour. Then down and set up just for debugging purposes, I’m printing out the list of serial ports. And then I am assigning the first port in this array to this Arduino, this serial object that I created that I named Arduino. So again, it’s taken the port name and the bod rate, which is 9,600, which is what I’m using in the Arduino IDE. And again, this port list you got to figure out, Hey, which of your ports is actually assigned to the Arduino. In my case, it’s the first port in the list, which I would index with zero. Hopefully that’s clear. Can be a little bit confusing. So then down in draw, again, draws gonna happen over and over and over again. I just set the background color of that little app that shows up that box that shows up. And then what I do is I create an integer called K and I set it equal to the return value of this function called getSpaceWeather. So getSpaceWeather is just this function down here. And it does exactly what we just did. It sends that request. Then I have it print the request off, and then it parses the JSON response that it gets, remember we get an array. So I parse all of those things into a JSONArray. And then I grabbed the object, just one object out of the array, I wanna get the last object in the array. So I used the size of the response minus one, that gets me the last object. And then to get a specific field, I use the getFloat function, which is just a function of this JSONObject. So again, data is the name of the JSONObject. So getFloat is a function of that object. And I’m grabbing the named field called K. And then I cast it into an integer ’cause it’s a floating point value. I turn it into an integer and then I save it in this value called K index. Then I just print that off and then I return that value. And right now we can see down here, the key index is currently two. So we were messing around earlier, it was, I think, I don’t know, one or 0.66 or whatever. Now it’s two. So then up here, back up and draw. So getSpaceWeather, whatever this value is, is going to get assigned to K. And then all we do is we call arduino.write k. So again, just not to confuse anything, this Arduino is just the name we’ve given to that serial object. So up at top we create a serial object and I named it Arduino. In the example before, I think they called it myport. This time, I’m just calling it Arduino. So that’s what we’re doing up there. And then down in draw, we’re saying arduino.write, and we’re passing it this value K. So that should get the value to over to Arduino. So what we need to do now is go over to the Arduino IDE and set it up so that it can take that value and then turn it into a number of LEDs that light on. So right now it’s two. So we would wanna LEDs to light up. So let me do that and then we’ll talk about it. So that was a lot of code. Let me talk about what I was doing here. So the first thing I did is I created an array. That’s gonna hold the pin numbers associated with each like K value essentially. So we’re gonna get a K value between one and nine. Now my array only goes up to eight ’cause I’ve got eight LEDs on my kit on a shield. So I figured out I’ll just have a special case for the ninth one that I haven’t implemented yet, but that should be easy enough. Anyway, so number six, the sixth pin is connected to an LED. The seventh pin is connected to an LED, the eighth and ninth, the 10th and so on and so forth. So when I see one, I wanna be able to turn on the LED connected at pin six. When I see two come in as the key index, I wanna light up LED six and seven that is, so forth and so on. Anyway, I make this array, it’s holding pin numbers, and then I have this value right here, this key indices, this is basically the size of the array. So I’m just passing that in here. And it’s a constant. Otherwise that wouldn’t work for setting the size of an array. You need to use a constant, or just like a primitive value, like an eight or something like that. And set up, I’m starting serial communication. It’s important that the bond rate here matches what you had in processing in that serial object that we created. And then I’m using a for-loop and I am walking through the array and I’m setting each of these pins as outputs. Now, if you’re not familiar with what is going on here, and you’re wondering like, man, this is all crazy, you can check out the other videos we have on using arrays or you can check out our training program we teach, all about like this type of programming with Arduino, and that’ll make a lot more sense. But basically we’re sitting each one of the pins as outputs on the Arduino that we’re gonna be using here. Then down in the loop what we’re doing is we are checking, Hey, is anything available at the serial buffer? If something is available at the cereal buffer, if there’s data in the cereal buffer, then we are going to read from the cereal buffer and whatever we read, we’re gonna assign to this byte called K index. Then we’re gonna pass that K index value. Again, it’s gonna be a number between zero and nine. At least that’s what we’re expecting. We’re gonna take that number and pass it to a function that I wrote called a set K indicator LEDs. So what does this function do? Well, it’s pretty simple. It’s just right down here. Set K indicator values. It takes an integer value, which I call K inside this program. And the first thing it does is it just goes ahead and turns off all of the LEDs in that K indices array. So it uses a for-loop just like we did up and set up, except now it’s instead of setting pin modes, it’s just writing all of those pins low. And then what it does is it goes through and based on this value, K, it writes up to those number of LEDs high. So this is gonna turn off all the LEDs. And then this is gonna just turn on the LEDs that matter. And that’s pretty much it. So now we’ve got a program that is looking for serial input. When it sees serial input, it’s gonna go ahead and set the LEDs appropriately. And I don’t know what the Space Weather is looking like right now. Right now it’s showing zero. So let’s look at the space weather forecast here. So this isn’t very pretty, but you can see the current forecast is zero, but a little bit ago it was two. So it would have lit up to LEDs, but basically, this works now. So what we’re doing is we are going out, grabbing information from the internet, with this processing sketch that we wrote and then we are sending that information to a port on our computer, where the Arduino is looking, and the Arduino is able to grab that information and then do something with it. And in this case, we’re just displaying some values on our kit-on-a-shield. So I hope that was helpful. I hope that made some sense. If you have any up questions on this, please post them in the comments. I would love to hear them.