Luke FousheeQuentin McCullough
Created April 16, 2019

UNCC IoT Smart Stoplight Project

A simple project that my partner and I designed to imitate a stoplight that uses an inductive sensor to detect and change lights.

Full instructions provided28
UNCC IoT Smart Stoplight Project

Things used in this project

Hardware components

Amazon Web Services Inductive Sensor, 20 mm
×1
Amazon Web Services NeoPixel LED Strip RGB 12GB
×1
Photon
Particle Photon
×2
Jumper wires (generic)
Jumper wires (generic)
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×2
Wooden Dowel Rods
×1
Styrofoam Block
×1
Hot Wheels Cars
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
Google Sheets
Google Sheets

Story

Read more

Schematics

Neopixel Circuit Diagram

Inductive Sensor Circuit Diagram

Code

Neopixel Code

C/C++
// This #include statement was automatically added by the Particle IDE.
#include "neopixel/neopixel.h"
#define PIXEL_COUNT 24

//Strip Defenition
Adafruit_NeoPixel strip = Adafruit_NeoPixel(12, 6, WS2812);

//Colors
uint32_t red = strip.Color(255, 0, 0);
uint32_t orange = strip.Color(255, 128, 0);
uint32_t yellow = strip.Color(255, 255, 0);
uint32_t green = strip.Color(0, 255, 0);
uint32_t light_blue = strip.Color(0, 255, 255);
uint32_t blue = strip.Color(0, 0, 255);
uint32_t purple = strip.Color(127, 0, 255);

void setup() {Particle.subscribe("MEGR3171SP19/team10/lightstatus",LIGHT1);
    strip.begin();
    strip.setBrightness(100);
    strip.show();
 String tempMessage = "Cycle Starts";
Particle.publish("googleDocs", "{\"QuentinMcCullough\":\"" + tempMessage + "\"}", 60, PRIVATE);
}

void loop() {

  
}
  
void LIGHT1 (const char *event, const char *data) {// commented out for a single color
      strip.setPixelColor(1, red);
      strip.setPixelColor(7, red);
      strip.setPixelColor(4, green);
      strip.setPixelColor(10,green);
    strip.show();
    delay(10000);
   
    strip.setPixelColor(1, red);
    strip.setPixelColor(7, red);
      strip.setPixelColor(4,yellow);
      strip.setPixelColor(10,yellow);
    strip.show();
    delay(5000);
    
    strip.setPixelColor(1, red);
    strip.setPixelColor(7, red);
      strip.setPixelColor(4,red);
      strip.setPixelColor(10,red);
    strip.show();
    delay(2000);
    
    strip.setPixelColor(1, green);
    strip.setPixelColor(7, green);
      strip.setPixelColor(4, red);
      strip.setPixelColor(10,red);
    strip.show();
    delay(10000);
    
    strip.setPixelColor(1, yellow);
    strip.setPixelColor(7, yellow);
      strip.setPixelColor(4, red);
      strip.setPixelColor(10,red);
    strip.show();
    delay(5000);
    
    strip.setPixelColor(1, red);
    strip.setPixelColor(7, red);
      strip.setPixelColor(4,red);
      strip.setPixelColor(10,red);
    strip.show();
    delay(2000);
    
    strip.setPixelColor(1, red);
      strip.setPixelColor(7, red);
      strip.setPixelColor(4, green);
      strip.setPixelColor(10,green);
    strip.show();
    delay(10000);
     return;
String tempMessage = "Cycle Ends";
Particle.publish("googleDocs", "{\"QuentinMcCullough\":\"" + tempMessage + "\"}", 60, PRIVATE);
}

Inductive Sensor Code

C/C++
//Code for traffic light input photon:

int trapstatus = 1; //global variable

void setup() {
pinMode(D6,INPUT_PULLUP);

pinMode(D7,OUTPUT);
}

void loop() {

lightstatus = digitalRead(D6);
if (lightstatus == FALSE){
Particle.publish("MEGR3171F19/team10/mousestatus", "lighton",PUBLIC); //subscribe to this light event.
delay(10000);


digitalWrite(D7,HIGH); //make the LED turn on if the event occurs.
delay(10000);
digitalWrite(D7,LOW);
}
}

Credits

Luke Foushee

Luke Foushee

1 project • 0 followers
Quentin McCullough

Quentin McCullough

1 project • 0 followers

Comments