![]() ![]() The value of “newbrightness” looks at the current value of “brightness”. And that’s where the “newbrightness” level comes into play. For simplicity’s sake, an intensity value of “0” means the LED is off. I can see, for example, that a variable called “brightness” is created to hold the value of the LED bulb’s intensity. That’s one of the benefits of using a commonly-used modern language. TofelĮven if you’re not a coder, you can probably understand the gist of the sample code. A sample DeviceScript project to blink a simulated LED every 200 milliseconds. every second I modified it in the below image. Note that the default code changes the state every 1,000 milliseconds, i.e. This code switches the LED state between on and off every 200 milliseconds. ![]() Here you can see the code along with the simulated LED when I run the project. This is definitely a basic example project but it provides a quick understanding of DeviceScript’s power and simplicity. To get started, I ran through the LED blink example code and simulated a LED. Looking through the choices, I see light bulbs, LEDs, and a range of sensors including humidity, motion, and temperature to name a few. Nope! The DeviceScript extension includes a device simulator with dozens and dozens of virtual devices. Without either supported microcontroller board, I’m out of luck, right? The whole point of DeviceScript is to create code that can read or write commands and data to connected devices. Since I don’t currently have any Raspberry Pico or ESP32 boards lying around, I thought I might be stymied at this point. The necessary code “scaffolding” is built for you. It’s definitely a more modern, simple approach that anyone who builds prototypes with breadboards or dev kits will appreciate. ![]() Tofelīy using the DeviceScript command to create a new project, the extension builds a project, complete with all of the required files and folders to get going. Some of the many integrated DeviceScript commands. And from there, getting started was a keyboard shortcut to see the DeviceScript commands available and choosing the one to create a new project. All I needed was the DeviceScript extension and one Terminal command to install the DeviceScript CLI or command line interface. Since I’m learning to code in JavaScript, I already had Node installed. Like many JavaScript or TypeScript apps, it leans on Node.js, which is a runtime environment for those two similar coding languages. That’s because DeviceScript is packaged as a Visual Studio Code extension, not as a standalone environment. When I said I “installed” DeviceScript, you might have thought this was a complicated process. If you’re a JavaScript or TypeScript developer already, you’ll like what Microsoft has created here. I can already say that I’m probably never going to code an IoT prototype on an Arduino board using that hardware’s native coding language again. ![]() Given my ongoing development education, I took a brief look at DeviceScript by installing it and running through some of the code examples. DeviceScript apps are meant to bring a more modern coding approach to small connected devices that run on microcontrollers. Microsoft last month introduced DeviceScript, a sub-set of the company’s TypeScript programming language, specifically for the IoT. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |