mirror of
https://gitlab.dit.htwk-leipzig.de/phillip.kuehne/dezibot.git
synced 2025-07-04 01:31:41 +02:00
added example sketches
This commit is contained in:
@ -1,48 +0,0 @@
|
|||||||
#include "Dezibot.h"
|
|
||||||
|
|
||||||
Dezibot dezibot = Dezibot();
|
|
||||||
const int centeredThreshold = 50 ;
|
|
||||||
|
|
||||||
void setup() {
|
|
||||||
// put your setup code here, to run once:
|
|
||||||
dezibot.begin();
|
|
||||||
Serial.begin(115200);
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop() {
|
|
||||||
int32_t leftValue = (int32_t)dezibot.lightDetection.getAverageValue(IR_LEFT, 20, 1);
|
|
||||||
int32_t rightValue = (int32_t)dezibot.lightDetection.getAverageValue(IR_RIGHT, 20, 1);
|
|
||||||
switch(dezibot.lightDetection.getBrightest(IR)){
|
|
||||||
case IR_FRONT:
|
|
||||||
//correct Stearing to be centered
|
|
||||||
if( abs(leftValue-rightValue)
|
|
||||||
< centeredThreshold){
|
|
||||||
dezibot.motion.move();
|
|
||||||
}else{
|
|
||||||
if (leftValue > rightValue){
|
|
||||||
dezibot.motion.rotateAntiClockwise();
|
|
||||||
} else{
|
|
||||||
dezibot.motion.rotateClockwise();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dezibot.multiColorLight.setTopLeds(BLUE);
|
|
||||||
break;
|
|
||||||
case IR_LEFT:
|
|
||||||
dezibot.motion.rotateAntiClockwise();
|
|
||||||
dezibot.multiColorLight.setTopLeds(RED);
|
|
||||||
break;
|
|
||||||
case IR_RIGHT:
|
|
||||||
dezibot.motion.rotateClockwise();
|
|
||||||
dezibot.multiColorLight.setTopLeds(GREEN);
|
|
||||||
break;
|
|
||||||
case IR_BACK:
|
|
||||||
if(leftValue > rightValue){
|
|
||||||
dezibot.motion.rotateAntiClockwise();
|
|
||||||
} else {
|
|
||||||
dezibot.motion.rotateClockwise();
|
|
||||||
}
|
|
||||||
dezibot.multiColorLight.setTopLeds(YELLOW);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
//delay(100);
|
|
||||||
}
|
|
19
example/advanced/Ampel1/Ampel1.ino
Normal file
19
example/advanced/Ampel1/Ampel1.ino
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#include "Dezibot.h"
|
||||||
|
|
||||||
|
Dezibot dezibot = Dezibot();
|
||||||
|
void setup() {
|
||||||
|
// put your setup code here, to run once:
|
||||||
|
dezibot.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
// put your main code here, to run repeatedly:
|
||||||
|
dezibot.multiColorLight.setLed(TOP, RED);
|
||||||
|
delay(2000);
|
||||||
|
dezibot.multiColorLight.setLed(TOP, YELLOW);
|
||||||
|
delay(2000);
|
||||||
|
dezibot.multiColorLight.setLed(TOP, GREEN);
|
||||||
|
delay(2000);
|
||||||
|
dezibot.multiColorLight.setLed(TOP, YELLOW);
|
||||||
|
delay(2000);
|
||||||
|
}
|
29
example/advanced/Ampel2/Ampel2.ino
Normal file
29
example/advanced/Ampel2/Ampel2.ino
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#include "Dezibot.h"
|
||||||
|
|
||||||
|
Dezibot dezibot = Dezibot();
|
||||||
|
void setup() {
|
||||||
|
// put your setup code here, to run once:
|
||||||
|
dezibot.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
// put your main code here, to run repeatedly:
|
||||||
|
dezibot.multiColorLight.setLed(TOP, RED);
|
||||||
|
delay(2000);
|
||||||
|
dezibot.multiColorLight.setLed(TOP, YELLOW);
|
||||||
|
delay(2000);
|
||||||
|
dezibot.multiColorLight.setLed(TOP, GREEN);
|
||||||
|
delay(2000);
|
||||||
|
dezibot.multiColorLight.turnOffLed();
|
||||||
|
delay(1000);
|
||||||
|
|
||||||
|
for(int i=0; i<3; i++){
|
||||||
|
dezibot.multiColorLight.setLed(TOP, GREEN);
|
||||||
|
delay(500);
|
||||||
|
dezibot.multiColorLight.turnOffLed();
|
||||||
|
delay(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
dezibot.multiColorLight.setLed(TOP, YELLOW);
|
||||||
|
delay(2000);
|
||||||
|
}
|
34
example/advanced/Ampel3/Ampel3.ino
Normal file
34
example/advanced/Ampel3/Ampel3.ino
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#include "Dezibot.h"
|
||||||
|
|
||||||
|
Dezibot dezibot = Dezibot();
|
||||||
|
void setup() {
|
||||||
|
// put your setup code here, to run once:
|
||||||
|
dezibot.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
// put your main code here, to run repeatedly:
|
||||||
|
|
||||||
|
if(dezibot.motion.detection.isShaken()){
|
||||||
|
dezibot.multiColorLight.setLed(TOP, YELLOW);
|
||||||
|
delay(2000);
|
||||||
|
dezibot.multiColorLight.setLed(TOP, GREEN);
|
||||||
|
delay(2000);
|
||||||
|
dezibot.multiColorLight.turnOffLed();
|
||||||
|
delay(1000);
|
||||||
|
|
||||||
|
for(int i=0; i<3; i++){
|
||||||
|
dezibot.multiColorLight.setLed(TOP, GREEN);
|
||||||
|
delay(500);
|
||||||
|
dezibot.multiColorLight.turnOffLed();
|
||||||
|
delay(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
dezibot.multiColorLight.setLed(TOP, YELLOW);
|
||||||
|
delay(2000);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
dezibot.multiColorLight.setLed(TOP, RED);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -6,12 +6,43 @@ const int centeredThreshold = 50 ;
|
|||||||
void setup() {
|
void setup() {
|
||||||
// put your setup code here, to run once:
|
// put your setup code here, to run once:
|
||||||
dezibot.begin();
|
dezibot.begin();
|
||||||
//Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
dezibot.infraredLight.bottom.turnOn();
|
|
||||||
dezibot.infraredLight.front.turnOn();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
int32_t leftValue = (int32_t)dezibot.lightDetection.getAverageValue(IR_LEFT, 20, 1);
|
||||||
|
int32_t rightValue = (int32_t)dezibot.lightDetection.getAverageValue(IR_RIGHT, 20, 1);
|
||||||
|
switch(dezibot.lightDetection.getBrightest(IR)){
|
||||||
|
case IR_FRONT:
|
||||||
|
//correct Stearing to be centered
|
||||||
|
if( abs(leftValue-rightValue)
|
||||||
|
< centeredThreshold){
|
||||||
|
dezibot.motion.move();
|
||||||
|
}else{
|
||||||
|
if (leftValue > rightValue){
|
||||||
|
dezibot.motion.rotateAntiClockwise();
|
||||||
|
} else{
|
||||||
|
dezibot.motion.rotateClockwise();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dezibot.multiColorLight.setTopLeds(BLUE);
|
||||||
|
break;
|
||||||
|
case IR_LEFT:
|
||||||
|
dezibot.motion.rotateAntiClockwise();
|
||||||
|
dezibot.multiColorLight.setTopLeds(RED);
|
||||||
|
break;
|
||||||
|
case IR_RIGHT:
|
||||||
|
dezibot.motion.rotateClockwise();
|
||||||
|
dezibot.multiColorLight.setTopLeds(GREEN);
|
||||||
|
break;
|
||||||
|
case IR_BACK:
|
||||||
|
if(leftValue > rightValue){
|
||||||
|
dezibot.motion.rotateAntiClockwise();
|
||||||
|
} else {
|
||||||
|
dezibot.motion.rotateClockwise();
|
||||||
|
}
|
||||||
|
dezibot.multiColorLight.setTopLeds(YELLOW);
|
||||||
|
break;
|
||||||
|
}
|
||||||
//delay(100);
|
//delay(100);
|
||||||
}
|
}
|
||||||
|
23
example/advanced/phototaxis/phototaxis.ino
Normal file
23
example/advanced/phototaxis/phototaxis.ino
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#include "Dezibot.h"
|
||||||
|
|
||||||
|
Dezibot dezibot = Dezibot();
|
||||||
|
void setup() {
|
||||||
|
// put your setup code here, to run once:
|
||||||
|
dezibot.begin();
|
||||||
|
dezibot.multiColorLight.turnOffLed();
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
// put your main code here, to run repeatedly:
|
||||||
|
dezibot.display.clear();
|
||||||
|
int light = dezibot.lightDetection.getValue(DL_FRONT);
|
||||||
|
dezibot.display.print(light);
|
||||||
|
|
||||||
|
if(light > 2000) {
|
||||||
|
dezibot.motion.move();
|
||||||
|
} else {
|
||||||
|
dezibot.motion.rotateClockwise();
|
||||||
|
}
|
||||||
|
delay(100);
|
||||||
|
|
||||||
|
}
|
@ -8,14 +8,9 @@ void setup() {
|
|||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// put your main code here, to run repeatedly:
|
// put your main code here, to run repeatedly:
|
||||||
|
dezibot.display.print("Starte Nachricht!");
|
||||||
delay(2000);
|
delay(2000);
|
||||||
dezibot.multiColorLight.setLed(ALL,dezibot.multiColorLight.color(100,0,0));
|
dezibot.display.clear();
|
||||||
delay(2000);
|
|
||||||
dezibot.multiColorLight.turnOffLed(ALL);
|
|
||||||
delay(2000);
|
|
||||||
//dezibot.display.print("Starte Nachricht!");
|
|
||||||
//delay(2000);
|
|
||||||
//dezibot.display.clear();
|
|
||||||
|
|
||||||
// T
|
// T
|
||||||
longSignal(1);
|
longSignal(1);
|
||||||
@ -46,13 +41,9 @@ void loop() {
|
|||||||
longSignal(1);
|
longSignal(1);
|
||||||
shortSignal(1);
|
shortSignal(1);
|
||||||
|
|
||||||
|
dezibot.display.print("Ende Nachricht!");
|
||||||
delay(2000);
|
delay(2000);
|
||||||
dezibot.multiColorLight.setLed(ALL,dezibot.multiColorLight.color(0,255,0));
|
dezibot.display.clear();
|
||||||
delay(2000);
|
|
||||||
dezibot.multiColorLight.turnOffLed(ALL);
|
|
||||||
delay(2000);
|
|
||||||
//dezibot.display.print("Ende Nachricht!");
|
|
||||||
//dezibot.display.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void shortSignal(int count){
|
void shortSignal(int count){
|
||||||
|
14
example/advanced/wuerfeln/wuerfeln.ino
Normal file
14
example/advanced/wuerfeln/wuerfeln.ino
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#include <Dezibot.h>
|
||||||
|
Dezibot dezibot = Dezibot();
|
||||||
|
void setup() {
|
||||||
|
dezibot.begin();
|
||||||
|
}
|
||||||
|
void loop() {
|
||||||
|
if(dezibot.motion.detection.isShaken()){
|
||||||
|
dezibot.display.clear();
|
||||||
|
dezibot.display.print(random(1,7));
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
14
example/advanced/zaehlen/zaehlen.ino
Normal file
14
example/advanced/zaehlen/zaehlen.ino
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#include <Dezibot.h>
|
||||||
|
Dezibot dezibot = Dezibot();
|
||||||
|
void setup() {
|
||||||
|
dezibot.begin();
|
||||||
|
}
|
||||||
|
void loop() {
|
||||||
|
for (int i=1; i<=10; i++){
|
||||||
|
dezibot.display.clear();
|
||||||
|
dezibot.display.print(i);
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
14
example/start/start.ino
Normal file
14
example/start/start.ino
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#include "Dezibot.h"
|
||||||
|
|
||||||
|
Dezibot dezibot = Dezibot();
|
||||||
|
|
||||||
|
void setup(){
|
||||||
|
dezibot.begin();
|
||||||
|
//comment in to use WIFI-Communication
|
||||||
|
//dezibot.communication.begin();
|
||||||
|
// put your setup code here, to run once:
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop(){
|
||||||
|
// put your main code here, to run repeatedly:
|
||||||
|
}
|
Reference in New Issue
Block a user