Benutzer-Werkzeuge

Webseiten-Werkzeuge


projekte:arduino_projekte:led_tannenbaum

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Nächste Überarbeitung
Vorhergehende Überarbeitung
projekte:arduino_projekte:led_tannenbaum [2017-01-17 14:11] – angelegt gamecompilerprojekte:arduino_projekte:led_tannenbaum [2021-03-27 09:59] (aktuell) – gelöscht gamecompiler
Zeile 1: Zeile 1:
-====== LED Tannenbaum ====== 
- 
-===== Übersicht ===== 
- 
-Es ist mal wieder Weihnachten und man ist unmotiviert zu basteln? Baue einen LED Tannenbaum, das bauen geht schnell - das programmieren dauert ewig. Perfekt (Ihr müsst ja nicht programmieren, habe ich ja für euch erledigt ;D) 
- 
-{{:projekte:arduino_projekte:img-20170110-wa00011.jpg?200|}} 
- 
-===== Material ===== 
-  * 12x LEDs in Bunt 
-  * Arduino in irgendeiner Art 
-  * Widerstände ca. 470Ohm 
-  * Kabel 
-  * Karton / Plexiglas 
- 
- 
-==== CODE ==== 
-<file lang="c" schimmelsensor.ino> 
-struct node { 
-  int symbol;         //a symbol, in this case it contains the number of the led 
-  /* Tree chematic 
-          1 
-      2       3 
-    4        7 
-    
-   */ 
-  struct node *left; //PTR to the left 
-  struct node *right; //PTR to the right 
-  int pin; //Pin, where is the led connected ? 
-}; 
- 
- 
-//The tree is programmed here. 
- 
-struct node node4 = {4, 0, 0, 10}; 
-struct node node5 = {5, 0, 0, 11}; 
-struct node node6 = {6, 0, 0, 12}; 
-struct node node7 = {7, 0, 0, 13}; 
- 
-struct node node2 = {2, &node4, &node5, 9}; 
-struct node node3 = {3, &node6, &node7, 8}; 
- 
-struct node root = {1, &node2, &node3, 7}; 
- 
-//_____________________________________________ 
- 
- 
-struct node *state = &root; // The code should start at top of the tree. 
- 
-void setup()   { 
-  Serial.begin(9600); 
- 
-  //Init all pins 
-  for(int i = 7;i<=13;i++)  { 
-    pinMode(i,OUTPUT); 
-  } 
- 
-  //RUDOLPHS NOSE PWM PINS 
-  pinMode(3,OUTPUT); 
-  pinMode(5,OUTPUT); 
-  pinMode(6,OUTPUT); 
-} 
- 
-long tree_oldmillis = 0; 
-const int UNIT = (2+1)*1000; //delay without using delay 
- 
-long rudolph_oldmillis = 0; 
-const int RUDOLPH_DELAY = round(UNIT / 3); //delay without using delay for rudolphs nose 
-void loop()   { 
- 
-  //Rudolphs nose 
-  if (millis() >= rudolph_oldmillis + RUDOLPH_DELAY) { //RUDOLPH_DELAY Delay without delay 
-    rudolph_oldmillis = millis(); 
-    //Write random color 
-    analogWrite(3,random(0,255)); 
-    analogWrite(5,random(0,255)); 
-    analogWrite(6,random(0,255)); 
-  } 
-   
-  //Christmas tree 
-  if (millis() >= tree_oldmillis + UNIT) {  //UNIT Delay without delay, 
-    digitalWrite(state->pin,LOW); //Put the last led off 
-    tree_oldmillis = millis();  //set tree_oldmillis to its new value 
-    Serial.println(state->symbol); //Print out the symbol, just for debuging. 
- 
-    if (random(1, 128) >= 64) { //random(0,1) didnt work, wether its a issue or not. Im not sure 
-      if (state->right != 0)  { //Has state->right childs? 
-        state = state->right; //Yep, jump to state->right address 
-      } 
-      else  { 
-        state = &root; //It got no childs (damn - thats terrible), jump back to root to make some 
-      } 
-    } 
-    else { 
-      if (state->left != 0)  { //Has state->left childs? 
-        state = state->left;  //Yep, jump to state->left address 
-      } 
-      else  { 
-        state = &root; //Nope, jump back to root 
-      } 
-    } 
-    digitalWrite(state->pin,HIGH); //Put the current state->pin led on 
-  } 
-} 
- 
-</file> 
- 
- 
  
projekte/arduino_projekte/led_tannenbaum.1484658681.txt.gz · Zuletzt geändert: 2022-11-17 22:34 (Externe Bearbeitung)