In this tutorial, we will be making a IoT Desk Traffic Light using a Dot One and a Wia button module and a few LEDS.
What you will need :
- Account at Wia - You will need to be logged in and / or registered into an account at Wia
- Wia Button Module - Buy Yours Here
- Wia Dot One - Buy Yours Here
- Micro Usb Cable - Buy Yours Here
- Jumper Wires
- LED's (x 3)
- 220 Ohm Resistors (x 3)
Create an account at Wia if you haven't already - refer to this tutorial to get started with Wia here.
- Set up your Dot One - You will need to have set up a Dot One and you can find the tutorial on how to do that Here.
Once you have finished the tutorials above and learned all about the Dot One, you are all set to do this tutorial below.
Create a Code Project
- Note: This portion requires a decent background in coding, specifically in C++ in order to understand how the Dot One and TFT Screen work to print the prices
- Below is the code for this project which you can follow by reading the comments attached to the side of the code.
- Feel free to try and rewrite this code yourself so you can better understand the device! Some advice if you are having trouble is to make a temporary Block Project and take note of what code is pasted into the preview window when you drag certain blocks over!
#include <WiFi.h>
int item = 0;
const int button = 17;
const int red = 25;
const int yellow = 27;
const int green = 32;
void setup() {
WiFi.begin();
delay(2500);
pinMode(button, INPUT_PULLDOWN);
pinMode(green, OUTPUT); //green
pinMode(yellow, OUTPUT); //yellow
pinMode(red, OUTPUT); //red
}
void loop() {
if (digitalRead(button) == HIGH ) {
item++;
delay(500);
}
switch (item) {
case 0:
digitalWrite(green, HIGH);
digitalWrite(yellow, LOW);
digitalWrite(red, LOW);
break;
case 1:
digitalWrite(green, LOW);
digitalWrite(red, HIGH);
digitalWrite(yellow, LOW);
break;
case 2:
digitalWrite(yellow, HIGH);
digitalWrite(red, LOW);
digitalWrite(green, LOW);
break;
case 3:
item = 0;
break;
}
}
You can then upload the above code to your Dot One by clicking the rocket icon and now once wired up the LED's should turn on one by one depending on button click
Now that we have successfully wrote the software for this tutorial, it's time to wire up the hardware to make the buttons turn on the LED's and behave as required.
Wiring ConnectionsUsing 4 jumper wires connect the Dot One to the pins as specified (in above code) as shown below:
Once the connections are made, you are ready to connect the Micro USB cable and the Dot One to your computer.
Now, that we have it all wired up and coded to do as indicated, this gif represents what should be displayed once the Dot One is given power.
Congratulations and Well Done on completing the tutorial, hope you enjoyed it.
Here's another to keep you entertained - Get the beer of the day to display on your TFT screen
If you are more into building and making your own electronic devices and hooking them up to the cloud, why not try out some of these tutorials:
Coffee Counter with TFT Screen and Button
Slack Toggle Presence with Wia Button Module and Dot One
or build something from our hackster projects
Comments