Skip to content
Snippets Groups Projects
Commit 275a3c68 authored by Orhan-Timo Altan's avatar Orhan-Timo Altan
Browse files

kleine Änderungen

parent f7dc36a5
No related branches found
No related tags found
No related merge requests found
# **LED strip controller**
Eine Klasse für die Initializierung und Steuerung von LED-Streifen
Eine Klasse für die Initializierung und Steuerung von LED-Streifen<br />
<br />
## **Voraussetzung:**
- Die Biliothek von Adafruit [Adafruit NeoPixel](https://github.com/adafruit/Adafruit_NeoPixel) muss installiert sein
- [Adafruit NeoPixel](https://github.com/adafruit/Adafruit_NeoPixel)<br />
<br />
## **Installation:**
Um diese Klassen verwenden zu können, muss dieses Repository geklont und in das Libraries-Verzeichnis der Arduino-IDE kopiert werden.
Um diese Klassen verwenden zu können, muss dieses Repository geklont und in das Libraries-Verzeichnis der Arduino-IDE kopiert werden.<br />
<br />
## **Anwendung:**
Zur Verwendung siehe zunächst das Beispiel `ledshow.ino`
Zur Verwendung siehe zunächst das Beispiel `ledshow.ino`<br />
<br />
**Einbinden der Bibliothek:**
```Arduino
......@@ -22,7 +29,8 @@ thk_LedStripController example_strip(LED_NUMBER, PIN, brightness);
```
- `LED_NUMBER`: Anzahl der LEDs am Streifen
- `PIN`: Pin für die Steuerung des LED-Streifens
- `brightness`: LED Helligkeit. Dieser Wert muss nicht mit übergeben werden, in dem Fall wird der vordefinierte wert von 64 genommen. Minimale Helligkeit (ausgeschaltet) = 0 und maximale Helligkeit = 255.
- `brightness`: LED Helligkeit. Dieser Wert muss nicht mit übergeben werden, in dem Fall wird der vordefinierte wert von 64 genommen. Minimale Helligkeit (ausgeschaltet) = 0 und maximale Helligkeit = 255. <br />
<br />
### **Funktionen:**
......@@ -31,15 +39,17 @@ thk_LedStripController example_strip(LED_NUMBER, PIN, brightness);
example_strip.clear();
```
<br />
**Farbeinstellung der LEDs:**
```Arduino
example_strip.set_pixel_color(thk_LedStripController::Color(red, green, blue));
```
oder
```Arduino
example_strip.set_pixel_color(index, thk_LedStripController::Color(red, green, blue));
```
oder
```Arduino
example_strip.set_pixel_color(start_index, amount, thk_LedStripController::Color(red, green, blue));
```
......@@ -48,6 +58,16 @@ example_strip.set_pixel_color(start_index, amount, thk_LedStripController::Color
- `index`: Die LED Nummerierung welche gesteuert werden soll.
- `start_index`: Die LED Nummerierung von der begonnen werden soll.
- `amount`: Anzahl der LEDs, welche nach *start_index* angesteuert werden sollen.
<br />
<br />
**Ändern der Helligkeit:**
```Arduino
example_strip.set_brightness(brightness);
```
- `brightness`: Helligkeitswert von 0 bis 255
<br />
<br />
**Blinken & Regenbogen Effekt:**
```C++
......@@ -61,6 +81,8 @@ example_strip.rainbow_effect(wait_time);
- `wait_time`: Die Geschwindigkeit, wie schnell geblinkt bzw der wechsel beim Regenbogen Effekt ausgeführt werden soll in Millisekunden.
*Hinweis:* Für die Dauer des Regenbogen Effekts, wird der Mikrocontroller blockiert und kann keine weiteren Befehle ausführen.
<br />
<br />
**Lichtlauf:**
```Arduino
......
......@@ -17,6 +17,12 @@ void setup()
back_strip.init();
left_strip.init();
rigth_strip.init();
// Helligkeit ändern
front_strip.set_brightness(150);
back_strip.set_brightness(150);
left_strip.set_brightness(100);
rigth_strip.set_brightness(100);
}
void loop()
......
......@@ -74,10 +74,7 @@ void thk_LedStripController::rainbow_effect(unsigned long wait_time) {
void thk_LedStripController::running_light(unsigned long wait_time, uint8_t length, uint32_t color, bool direction) {
if (direction){
for(uint16_t i = 0; i <= ptrStrip->numPixels(); i++) { // For each pixel...
// pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255
// Here we're using a moderately bright green color:
for(uint16_t i = 0; i <= ptrStrip->numPixels(); i++) {
if(i <= ptrStrip->numPixels())
{
ptrStrip->setPixelColor(i, color);
......@@ -96,18 +93,14 @@ void thk_LedStripController::running_light(unsigned long wait_time, uint8_t leng
ptrStrip->setPixelColor(last_pixel, Color(0, 0, 0));
}
ptrStrip->show(); // Send the updated pixel colors to the hardware.
delay(wait_time); // Pause before next pass through loop
ptrStrip->show();
delay(wait_time);
}
clear();
show();
}
else {
for(int8_t i = ptrStrip->numPixels(); i >= 0; i--) { // For each pixel...
// pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255
// Here we're using a moderately bright green color:
for(int8_t i = ptrStrip->numPixels(); i >= 0; i--) {
if(i >= 0)
{
ptrStrip->setPixelColor(i, color);
......@@ -117,7 +110,6 @@ void thk_LedStripController::running_light(unsigned long wait_time, uint8_t leng
ptrStrip-> setPixelColor(i + ptrStrip->numPixels(), color);
}
int last_pixel = i + length;
ptrStrip->show();
delay(wait_time);
......@@ -126,9 +118,8 @@ void thk_LedStripController::running_light(unsigned long wait_time, uint8_t leng
ptrStrip->setPixelColor(last_pixel, Color(0, 0, 0));
}
ptrStrip->show(); // Send the updated pixel colors to the hardware.
delay(wait_time); // Pause before next pass through loop
ptrStrip->show();
delay(wait_time);
}
clear();
show();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment