mirror of
https://gitlab.dit.htwk-leipzig.de/phillip.kuehne/dezibot.git
synced 2025-05-19 19:11:48 +02:00
Update Measurement sketches
This commit is contained in:
parent
b57e955dc2
commit
9acca9e5c7
@ -9,15 +9,26 @@ void setup() {
|
|||||||
dezibot.infraredLight.begin();
|
dezibot.infraredLight.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void blink_times(int times) {
|
||||||
|
constexpr int ioPin = 17;
|
||||||
|
pinMode(ioPin, OUTPUT);
|
||||||
|
for(int i = 0; i<times; i++) {
|
||||||
|
digitalWrite(ioPin,1);
|
||||||
|
delay(300);
|
||||||
|
digitalWrite(ioPin,0);
|
||||||
|
delay(300);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// put your main code here, to run repeatedly:
|
// put your main code here, to run repeatedly:
|
||||||
// Just turn the lights on alternating each five seconds, to get the consumption
|
// Just turn the lights on alternating each five seconds, to get the consumption
|
||||||
dezibot.infraredLight.front.turnOn();
|
dezibot.infraredLight.front.turnOn();
|
||||||
|
blink_times(1);
|
||||||
delay(cycleMillis);
|
delay(cycleMillis);
|
||||||
dezibot.infraredLight.front.turnOff();
|
dezibot.infraredLight.front.turnOff();
|
||||||
dezibot.infraredLight.bottom.turnOn();
|
dezibot.infraredLight.bottom.turnOn();
|
||||||
delay(cycleMillis);
|
delay(cycleMillis);
|
||||||
//Turn off and wait a little to measure baseline consumption
|
blink_times(2);
|
||||||
dezibot.infraredLight.bottom.turnOff();
|
dezibot.infraredLight.bottom.turnOff();
|
||||||
delay(cycleMillis);
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,80 @@
|
|||||||
|
#include <Adafruit_NeoPixel.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
╔══════════════════════════════════════════════════════════════════════════════╗
|
||||||
|
║ WARNING: This example controls the RGB-LEDs directly, bypassing the ║
|
||||||
|
║ MultiColorLight component. This is not recommended for normal use, as it ║
|
||||||
|
║ bypasses the safety checks and color normalization. This is only intended ║
|
||||||
|
║ for diagnostic purposes. ║
|
||||||
|
╚══════════════════════════════════════════════════════════════════════════════╝
|
||||||
|
*/
|
||||||
|
|
||||||
|
Adafruit_NeoPixel rgbLeds(3, 48);
|
||||||
|
|
||||||
|
void setup() { rgbLeds.begin(); }
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
// Ramp up the brightness of each color channel
|
||||||
|
// Allows for the PWM behaviour to quickly be observed on an oscilloscope
|
||||||
|
// Red
|
||||||
|
for (int bri = 0; bri < 0xFF; bri += 0x1) {
|
||||||
|
rgbLeds.setPixelColor(0, rgbLeds.Color(bri, 0, 0));
|
||||||
|
rgbLeds.show();
|
||||||
|
delay(10);
|
||||||
|
}
|
||||||
|
// Red
|
||||||
|
for (int bri = 0; bri < 0xFF; bri += 0x1) {
|
||||||
|
rgbLeds.setPixelColor(0, rgbLeds.Color(0, bri, 0));
|
||||||
|
rgbLeds.show();
|
||||||
|
delay(10);
|
||||||
|
}
|
||||||
|
// Blue
|
||||||
|
for (int bri = 0; bri < 0xFF; bri += 0x1) {
|
||||||
|
rgbLeds.setPixelColor(0, rgbLeds.Color(0, 0, bri));
|
||||||
|
rgbLeds.show();
|
||||||
|
delay(10);
|
||||||
|
}
|
||||||
|
// Combinations of the color channels
|
||||||
|
// Yellow (Red + Green)
|
||||||
|
for (int bri = 0; bri < 0xFF; bri += 0x1) {
|
||||||
|
rgbLeds.setPixelColor(0, rgbLeds.Color(bri, bri, 0));
|
||||||
|
rgbLeds.show();
|
||||||
|
delay(10);
|
||||||
|
}
|
||||||
|
// Purple (Red + Blue)
|
||||||
|
for (int bri = 0; bri < 0xFF; bri += 0x1) {
|
||||||
|
rgbLeds.setPixelColor(0, rgbLeds.Color(bri, 0, bri));
|
||||||
|
rgbLeds.show();
|
||||||
|
delay(10);
|
||||||
|
}
|
||||||
|
// Cyan (Green + Blue)
|
||||||
|
for (int bri = 0; bri < 0xFF; bri += 0x1) {
|
||||||
|
rgbLeds.setPixelColor(0, rgbLeds.Color(0, bri, bri));
|
||||||
|
rgbLeds.show();
|
||||||
|
delay(10);
|
||||||
|
}
|
||||||
|
// White (Red + Green + Blue)
|
||||||
|
for (int bri = 0; bri < 0xFF; bri += 0x1) {
|
||||||
|
rgbLeds.setPixelColor(0, rgbLeds.Color(bri, bri, bri));
|
||||||
|
rgbLeds.show();
|
||||||
|
delay(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now some constant states for comparable measurements
|
||||||
|
// Full brightness R+G+B
|
||||||
|
rgbLeds.setPixelColor(0, rgbLeds.Color(255, 255, 255));
|
||||||
|
rgbLeds.show();
|
||||||
|
sleep(5);
|
||||||
|
// Half brightness R+G+B
|
||||||
|
rgbLeds.setPixelColor(0, rgbLeds.Color(127, 127, 127));
|
||||||
|
rgbLeds.show();
|
||||||
|
sleep(5);
|
||||||
|
// Minimum brightness R+G+B
|
||||||
|
rgbLeds.setPixelColor(0, rgbLeds.Color(1, 1, 1));
|
||||||
|
rgbLeds.show();
|
||||||
|
sleep(5);
|
||||||
|
// Off (baseline)
|
||||||
|
rgbLeds.setPixelColor(0, rgbLeds.Color(0, 0, 0));
|
||||||
|
rgbLeds.show();
|
||||||
|
sleep(5);
|
||||||
|
}
|
@ -3,7 +3,7 @@
|
|||||||
Dezibot dezibot;
|
Dezibot dezibot;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
dezibot.lightDetection.begin();
|
dezibot.colorDetection.begin();
|
||||||
//dezibot.motion.detection.end();
|
//dezibot.motion.detection.end();
|
||||||
// put your setup code here, to run once:
|
// put your setup code here, to run once:
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
@ -13,7 +13,7 @@ void setup() {
|
|||||||
}
|
}
|
||||||
delay(1000);
|
delay(1000);
|
||||||
// Test if VEML6040 is working correctly
|
// Test if VEML6040 is working correctly
|
||||||
char light_value = dezibot.lightDetection.getValue(DL_FRONT);
|
char light_value = dezibot.colorDetection.getColorValue(VEML_WHITE);
|
||||||
if (light_value != UINT16_MAX) {
|
if (light_value != UINT16_MAX) {
|
||||||
Serial.printf("Light detection seems to be working (detected value: %d). Starting measurements...\r\n", light_value);
|
Serial.printf("Light detection seems to be working (detected value: %d). Starting measurements...\r\n", light_value);
|
||||||
} else {
|
} else {
|
||||||
@ -29,6 +29,6 @@ void setup() {
|
|||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// put your main code here, to run repeatedly:
|
// put your main code here, to run repeatedly:
|
||||||
dezibot.lightDetection.getValue(DL_FRONT);
|
dezibot.colorDetection.getColorValue(VEML_WHITE);
|
||||||
delay(10);
|
delay(10);
|
||||||
}
|
}
|
@ -3,6 +3,17 @@
|
|||||||
|
|
||||||
Dezibot dezibot = Dezibot();
|
Dezibot dezibot = Dezibot();
|
||||||
|
|
||||||
|
void blip_io(int times) {
|
||||||
|
constexpr int ioPin = 17;
|
||||||
|
pinMode(ioPin, OUTPUT);
|
||||||
|
for(int i = 0; i<times; i++) {
|
||||||
|
digitalWrite(ioPin,1);
|
||||||
|
delay(500);
|
||||||
|
digitalWrite(ioPin,0);
|
||||||
|
delay(500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.begin(112500);
|
Serial.begin(112500);
|
||||||
@ -18,10 +29,12 @@ void setup() {
|
|||||||
Serial.println("Set up receive. Printing incoming messages:");
|
Serial.println("Set up receive. Printing incoming messages:");
|
||||||
Serial.println("Sending broadcast messages to generate TX power consumption:");
|
Serial.println("Sending broadcast messages to generate TX power consumption:");
|
||||||
#endif
|
#endif
|
||||||
|
blip_io(1);
|
||||||
delay(5000);
|
delay(5000);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.println("Starting Transmission...");
|
Serial.println("Starting Transmission...");
|
||||||
#endif
|
#endif
|
||||||
|
blip_io(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_receive(String &message) {
|
void handle_receive(String &message) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user