Skip to content

Commit

Permalink
update 621
Browse files Browse the repository at this point in the history
  • Loading branch information
eagboola committed Jun 21, 2017
1 parent de1b528 commit 8710377
Show file tree
Hide file tree
Showing 2 changed files with 146 additions and 14 deletions.
34 changes: 20 additions & 14 deletions projectBuild.ino
Original file line number Diff line number Diff line change
Expand Up @@ -81,32 +81,38 @@ void loop() {
lox.rangingTest(&measure, true); // pass in 'true' to et debug in data printout

distVal = measure.RangeMilliMeter;
distVal= constrain(distVal, 10, 900);
//distVal= constrain(distVal, 10, 900);

/*
if(measure.RangeMilliMeter < 10) {

/*if(measure.RangeMilliMeter < 10) {
distVal = 0;
strip.setBrightness
}
else if(measure.RangeMilliMeter > 900){
*/

/* if(measure.RangeMilliMeter > 900){
distVal = 900;
strip.setBrightness(0);
}
*/
*/

if((measure.RangeMilliMeter > 0) && (measure.RangeStatus < 900) ) {
Serial.println("Distance (mm): "); Serial.println(measure.RangeMilliMeter);
distVal = measure.RangeMilliMeter;

if (distVal < 900) {
Serial.println("Distance (mm): " + measure.RangeMilliMeter); //Serial.println(measure.RangeMilliMeter);
Particle.publish("distance", String(distVal));
strip.setBrightness(distVal);
}

else {
Serial.println(" subject is out of range");
Particle.publish("subject is out of range");
Serial.println("No subject(s) witin range");
Particle.publish("No subject(s) within range");
strip.setBrightness(0);
}


distValMapped = map(distVal, 0, 900, 255, 5);
//distValMapped = map(distVal, 0, 900, 255, 5);
Serial.println("distance: " + String(distVal)); //Serial.println( String(distVal));
Serial.println("seconds since last read: " + String(Time.minute())); //Serial.println(millis());
strip.setBrightness(distValMapped);
Serial.println("seconds: " + String(Time.second())); //Serial.println(millis());
//strip.setBrightness(distValMapped);
Particle.publish("mapped distance value", distValMapped);

Serial.println("brightness: " + String(strip.getBrightness())); //Serial.println(String(strip.getBrightness()));
Expand Down
126 changes: 126 additions & 0 deletions projectBuild2_6-20.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>

// This #include statement was automatically added by the Particle IDE.
#include <Adafruit_VL53L0X.h>

/*
* Project projectBuild
* Description:
* Author: Ekerin M.A.
* Date: start.6/15/2017
* Components
Adafruit:
- VL53L0X, Time of Flight Distance Sensor
- library added
- SPW2430, MEMS Microphone Breakout
- Neopixels
- library added
Amazon:
- Amazon Dot with Alexa Capabilites
*/

#define VL53L0X_LOG_ENABLE 0
uint32_t _trace_evel = TRACE_LEVEL_ALL;

#if defined(PARTICLE) && (SYSTEM_VERSION >= 0x00060000)
SerialLogHandler logHandler(LOG_LEVEL_ALL);
#endif

Adafruit_VL53L0X lox = Adafruit_VL53L0X();

int distVal = 0;

// IMPORTANT: Set pixel COUNT, PIN and TYPE
#define PIXEL_PIN D6
#define PIXEL_COUNT 1
#define PIXEL_TYPE WS2812B

Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
//int analogVal = 0;
// in this, analogVal is the distance from the distVal
int distValMapped = 0;
// in this, analogValMapped is the distVal mapped to the neopixel range
int counter = 0;
// Prototypes for local build, ok to leave in for Build IDE




// setup() runs once, when the device is first turned on.
void setup() {
// Put initialization like pinMode and begin functions here.
Serial.begin(115200);

Serial.println("Adafruit VL53L0X test");

if (!lox.begin()) {
Serial.println(F("Failed to boot VL53L0X"));
while(1);
}

Serial.println(F("VL53L0X API Simple Ranging example\n\n"));
Particle.variable("sensor", distVal);


strip.begin();
strip.show();


}

// loop() runs over and over again, as quickly as it can execute.
void loop() {
// The core of your code will likely live here.
strip.setPixelColor(1, 0, 255, 0);


VL53L0X_RangingMeasurementData_t measure;

Serial.print("Reading a measurement...");
lox.rangingTest(&measure, true); // pass in 'true' to et debug in data printout

distVal = measure.RangeMilliMeter;
//distVal= constrain(distVal, 10, 900);


/*if(measure.RangeMilliMeter < 10) {
distVal = 0;
strip.setBrightness
}
*/

/* if(measure.RangeMilliMeter > 900){
distVal = 900;
strip.setBrightness(0);
}
*/


if (distVal < 900) {
Serial.println("Distance (mm): " + measure.RangeMilliMeter); //Serial.println(measure.RangeMilliMeter);
Particle.publish("distance", String(distVal));
strip.setBrightness(distVal);
}

else {
Serial.println("No subject(s) witin range");
Particle.publish("No subject(s) within range");
strip.setBrightness(0);
}

//distValMapped = map(distVal, 0, 900, 255, 5);
Serial.println("distance: " + String(distVal)); //Serial.println( String(distVal));
Serial.println("seconds: " + String(Time.second())); //Serial.println(millis());
//strip.setBrightness(distValMapped);
Particle.publish("mapped distance value", distValMapped);

Serial.println("brightness: " + String(strip.getBrightness())); //Serial.println(String(strip.getBrightness()));





delay(10);

}

0 comments on commit 8710377

Please sign in to comment.