Adam O' CeallaighJack DuffSpiveyAndrew Berry
Published

Desk Traffic Light

In this tutorial, we will be making an IoT Desk Traffic Light using a Dot One and a Wia button module and a few LEDS.

BeginnerFull instructions provided18 minutes7

Things used in this project

Hardware components

Wia Dot One
Wia Dot One
×1
Wia Button Module
Wia Button Module
×1
LED (generic)
LED (generic)
×3
Wia Micro USB Cable
Wia Micro USB Cable
×1
Resistor 220 ohm
Resistor 220 ohm
×3

Software apps and online services

Wia
Wia

Story

Read more

Code

Code To make buttons turn on LED's Simultaneously

C/C++
#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;
    }
 
  }

Credits

Adam O' Ceallaigh

Adam O' Ceallaigh

15 projects • 4 followers
Jack Duff

Jack Duff

22 projects • 2 followers
Man of the people.Champion of the downtrodden.Marketing magic @ Wia
Spivey

Spivey

72 projects • 43 followers
Tourist in a Tutu || US Born || Melbourne/Mexico/California Raised || New Yorker at ❤️ || SF to Dublin to be COO of Wia the best IoT startup
Andrew Berry

Andrew Berry

18 projects • 1 follower

Comments