/*
* Project midTerm_dChavez
* Description:midTerm Project
* Author: Dan Chavez
* Date: 7-MAR-2023
*/
#include <colors.h>
#include "IoTClassroom_CNM.h"
#include "neopixel.h"
#include <math.h>
#include "particle.h"
//#include "hue.h"
Adafruit_NeoPixel pixel (WS2812B);
IoTTimer wemoTimer;
Button testButton (D6);
// laser and photo stuff
const int photoPin=A2;
const int laserPin=D4;
int photoValue;
// relay stuff
const int relayPin=D5;
int relayHigh;
int relayLow;
bool RelayState;
bool offOn=1;
bool onOff=0;
int MYWEMO=3;
// neopixel stuff
int brightness;
const int pixelPin=D3;
const int PIXEL_COUNT=1;
// hue stuff
int hueBulb;
SYSTEM_MODE(SEMI_AUTOMATIC);
// setup() runs once, when the device is first turned on.
void setup() {
Serial.begin(9600);
pinMode(laserPin, OUTPUT);
pinMode(photoPin, INPUT);
pinMode(relayPin, OUTPUT);
Serial.printf("Basic Speed Test:");
waitFor(Serial.isConnected,15000);
WiFi.on();
WiFi.setCredentials("IoTNetwork");
WiFi.connect();
while(WiFi.connecting());
{
Serial.printf(".");
pixel.begin();
pixel.show();
pixel.setPixelColor(1, yellow);
delay(1000);
}
Serial.printf("\n\n");
}
void loop() {
turnRelayOn();
delay(5000);
turnRelayOff();
delay(5000);
digitalWrite(laserPin, HIGH);
photoValue=analogRead(photoPin);
Serial.printf("photoValue=analogRead %d\r",photoValue);
}
void turnRelayOn(){
Serial.printf("Turning on Wemo# %i\n",MYWEMO);
switchON(MYWEMO);
digitalWrite(relayPin, offOn);
pixel.setPixelColor(1, yellow);
for(hueBulb=1; hueBulb <=6; hueBulb++){
setHue(hueBulb,true,HueIndigo,127, 127);
}
}
void turnRelayOff() {
digitalWrite(relayPin, onOff);
Serial.printf("Turning off Wemo# %i\n",MYWEMO);
switchOFF(MYWEMO);
for(hueBulb=1; hueBulb <=6; hueBulb++){
setHue(hueBulb,true,HueRed,127, 127);
}
}
Comments