of course, when looking at the code above, i detected one repeating pattern that helps to generalize this solution. although the code here is primitive and noobish, it still works and is easy enough to our simple solution. furthermore, connecting everything together on the electronics side was very simple.
Raspberry pi windows 10 iot windows 10#
Using windows 10 iot core and visual studio, it is easy to control led lights connected to a raspberry pi. the play() method runs 10 traffic light cycles. i’m using a separate method for the traffic light cycle so i can later add another method to blink the led lights. Let’s focus now on the primitive code needed to mimic traffic lights. If there are problems wiring things together, then make sure you followed all the instructions accurately. The cryptic constants 17, 18, and 27 are actually gpio pin numbers. if we run the code and all leds light up for 10 seconds, then everything is okay. the foreach loop in mainpage_loaded turns all leds on for 10 seconds. the init() method initializes gpio pins and adds them to a list.
The code here is just to test that the wiring went well and everything works. Pin.setdrivemode(gpiopindrivemode.output) Private void mainpage_loaded(object sender, routedeventargs e)ĭebug.writeline("gpio controller is missing!") Public sealed partial class mainpage : page open the code-behind file of mainpage.xaml and add the following code. after creating the project, add a reference to windows iot extensions for the uwp. Here i’m using the blank uwp application. if you just want to try things out, then the blank uwp application is a good starting point, as you can later build a ui for your application. what you prefer depends on what you want to do next. There are two options for uwp applications – a blank uwp application and the On the wiring side, things are actually so simple that even i was able to get it right on the first shot.Īfter the wiring is done, it’s time to write some code. they need to know that you are using a 3.3v power supply. ask the electronics store about the appropriate ones if you are newbie like me. The resistors you need depend on what led lamps you buy. To get started, we need some electronic parts (i expect you already have a raspberry pi with windows 10 iot core installed): this blog post is a short introduction about what i did. i’m an iot newbie, but using microsoft tools, it was actually easy to build this little example. i wrote a slightly more complex starting example, but it has some inspiration from real life – my example simulates traffic lights.
Raspberry pi windows 10 iot how to#
Most of beginner examples for raspberry pis introduce how to turn on and off leds.