Advertisement
Guest User

Pedal Plane

a guest
Nov 11th, 2019
756
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <FastLED.h>
  2.  
  3. #define LED_PIN     3
  4. //#define DATA_PIN 4
  5. #define NUM_LEDS    14
  6. #define LED_TYPE    WS2812B
  7. #define COLOR_ORDER GRB
  8. #define BRIGHTNESS  5
  9.  
  10. CRGB leds[NUM_LEDS];
  11.  
  12.  
  13.  
  14.  
  15.  
  16. /**
  17.  * file:    Mini Plane
  18.  * author:  Davcio
  19.  *
  20.  * description:
  21.  * Beleuchtung des Kruemers V12 Motor
  22.  * und Soundmodulsteuerung
  23.  *
  24.  * date:    06.11.2019
  25.  * version: 0.1
  26.  */
  27.  
  28.  
  29. int Zeit_zw_zylinder;
  30. int Zeit_Zuendung;
  31. int NEO_LED_NR;
  32. int Zuendung_AN = 7;
  33. int Motor_AN = 9;
  34. unsigned long ZeitbisBlink1_Rot;
  35. unsigned long ZeitbisBlink1_Gruen;
  36. unsigned long Motor_Lauft_Z0;
  37. unsigned long Motor_Lauft_Z1;
  38. unsigned long Motor_Lauft_Z2;
  39. unsigned long Motor_Lauft_Z3;
  40. unsigned long Motor_Lauft_Z4;
  41. unsigned long Motor_Lauft_Z5;
  42. unsigned long Motor_Lauft_Z6;
  43. unsigned long Motor_Lauft_Z7;
  44. unsigned long Motor_Lauft_Z8;
  45. unsigned long Motor_Lauft_Z9;
  46. unsigned long Motor_Lauft_Z10;
  47. unsigned long Motor_Lauft_Z11;
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54. void setup() {
  55.  
  56.     delay(1000);
  57.     LEDS.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS);
  58. //  LEDS.addLeds<LED_TYPE, LED_PIN, CLOCK_PIN COLOR_ORDER>(leds, NUM_LEDS);
  59.     FastLED.setBrightness(BRIGHTNESS);
  60.   pinMode(Zuendung_AN, INPUT_PULLUP);
  61.   pinMode(Motor_AN, INPUT_PULLUP);
  62.  
  63.   Serial.begin(9600);
  64.  
  65.  
  66.  
  67.   ZeitbisBlink1_Rot = millis();
  68.   ZeitbisBlink1_Gruen = millis();
  69.  
  70.  Motor_Lauft_Z0 = millis();
  71.  Motor_Lauft_Z1 = millis();
  72.  Motor_Lauft_Z2 = millis();
  73.  Motor_Lauft_Z3 = millis();
  74.  Motor_Lauft_Z4 = millis();
  75.  Motor_Lauft_Z5 = millis();
  76.  Motor_Lauft_Z6 = millis();
  77.  Motor_Lauft_Z9 = millis();
  78.  Motor_Lauft_Z8 = millis();
  79.  Motor_Lauft_Z9 = millis();
  80.  Motor_Lauft_Z10 = millis();
  81.  Motor_Lauft_Z11 = millis();
  82. }
  83.  
  84. void loop() {
  85.    
  86.   if(! digitalRead(Zuendung_AN) ) {
  87.       //Merlin motor Start
  88.        Zeit_zw_zylinder = 50;
  89.         Zeit_Zuendung = 10;
  90.      
  91.     if( millis() - Motor_Lauft_Z0 >= 100) {  
  92.         NEO_LED_NR = 0;
  93.         leds[NEO_LED_NR] = CRGB::Red;
  94.         FastLED.show();
  95.       Serial.println(NEO_LED_NR, millis() - Motor_Lauft_Z0 );
  96.     }
  97.  
  98.   if( millis() - Motor_Lauft_Z0 >= 110) {
  99.      leds[NEO_LED_NR].setRGB(0,0,0);
  100.       FastLED.show();
  101.      
  102.     }  
  103.     if( millis() - Motor_Lauft_Z11 >= 200) {
  104.        NEO_LED_NR = 11;
  105.      leds[NEO_LED_NR] = CRGB::Red;
  106.         FastLED.show();
  107.       Serial.println(NEO_LED_NR,millis() - Motor_Lauft_Z11);
  108.     }
  109.  
  110.   if( millis() - Motor_Lauft_Z11 >= 210) {
  111.        leds[NEO_LED_NR].setRGB(0,0,0);
  112.       FastLED.show();
  113.     }
  114.    
  115.     if( millis() -  Motor_Lauft_Z3 >= 500) {
  116.       NEO_LED_NR = 3;
  117.        leds[NEO_LED_NR] = CRGB::Red;
  118.         FastLED.show();
  119.       Serial.println(NEO_LED_NR, millis() -  Motor_Lauft_Z3 );
  120.     }
  121.  
  122.   if( millis() -  Motor_Lauft_Z3 >= 510) {
  123.       leds[NEO_LED_NR].setRGB(0,0,0);
  124.       FastLED.show();
  125.     }
  126.  
  127.    
  128.     if( millis() -  Motor_Lauft_Z8 >= 700) {
  129.       NEO_LED_NR = 8;
  130.        leds[NEO_LED_NR] = CRGB::Red;
  131.         FastLED.show();
  132.       Serial.println(NEO_LED_NR, Motor_Lauft_Z8);
  133.     }
  134.  
  135.   if( millis() -  Motor_Lauft_Z8 >= 710) {
  136.        leds[NEO_LED_NR].setRGB(0,0,0);
  137.       FastLED.show();
  138.     }
  139.    
  140.    
  141.     if( millis() - Motor_Lauft_Z1 >= 900) {
  142.        NEO_LED_NR = 1;
  143.        leds[NEO_LED_NR] = CRGB::Red;
  144.         FastLED.show();
  145.       Serial.println(NEO_LED_NR,Motor_Lauft_Z1);
  146.     }
  147.  
  148.   if( millis() - Motor_Lauft_Z1 >= 910) {
  149.        leds[NEO_LED_NR].setRGB(0,0,0);
  150.       FastLED.show();
  151.     }
  152.    
  153.    
  154.     if( millis() -  Motor_Lauft_Z10 >= 1100) {
  155.       NEO_LED_NR = 10;
  156.        leds[NEO_LED_NR] = CRGB::Red;
  157.         FastLED.show();
  158.       Serial.println(NEO_LED_NR, Motor_Lauft_Z10);
  159.     }
  160.  
  161.   if( millis() - Motor_Lauft_Z10 >= 1110) {
  162.        leds[NEO_LED_NR].setRGB(0,0,0);
  163.       FastLED.show();
  164.     }
  165.    
  166.    
  167.     if( millis() - Motor_Lauft_Z5 >= 1300) {
  168.       NEO_LED_NR = 5;
  169.       leds[NEO_LED_NR] = CRGB::Red;
  170.         FastLED.show();
  171.       Serial.println(NEO_LED_NR,Motor_Lauft_Z5);
  172.     }
  173.  
  174.   if( millis() - Motor_Lauft_Z5 >= 1310) {
  175.        leds[NEO_LED_NR].setRGB(0,0,0);
  176.       FastLED.show();
  177.     }
  178.    
  179.    
  180.     if( millis() - Motor_Lauft_Z6 >= 1500) {
  181.       NEO_LED_NR = 6;
  182.       leds[NEO_LED_NR] = CRGB::Red;
  183.         FastLED.show();
  184.       Serial.println(NEO_LED_NR,Motor_Lauft_Z6);
  185.     }
  186.  
  187.   if( millis() - Motor_Lauft_Z6 >= 1510) {
  188.        leds[NEO_LED_NR].setRGB(0,0,0);
  189.       FastLED.show();
  190.     }
  191.    
  192.    
  193.     if( millis() - Motor_Lauft_Z2 >= 1700) {
  194.       NEO_LED_NR = 2;
  195.        leds[NEO_LED_NR] = CRGB::Red;
  196.         FastLED.show();
  197.       Serial.println(NEO_LED_NR,Motor_Lauft_Z2);
  198.     }
  199.  
  200.   if( millis() - Motor_Lauft_Z2 >= 1710) {
  201.        leds[NEO_LED_NR].setRGB(0,0,0);
  202.       FastLED.show();
  203.     }
  204.    
  205.    
  206.     if( millis() - Motor_Lauft_Z9 >= 1900) {
  207.        NEO_LED_NR = 9;
  208.       leds[NEO_LED_NR] = CRGB::Red;
  209.         FastLED.show();
  210.       Serial.println(NEO_LED_NR,Motor_Lauft_Z9);
  211.     }
  212.  
  213.   if( millis() - Motor_Lauft_Z9 >= 1910) {
  214.        leds[NEO_LED_NR].setRGB(0,0,0);
  215.       FastLED.show();
  216.     }
  217.    
  218.    
  219.     if( millis() - Motor_Lauft_Z4 >= 2000) {
  220.       NEO_LED_NR = 4;
  221.        leds[NEO_LED_NR] = CRGB::Red;
  222.         FastLED.show();
  223.       Serial.println(NEO_LED_NR,Motor_Lauft_Z4);
  224.     }
  225.  
  226.   if( millis() - Motor_Lauft_Z4 >= 2010) {
  227.        leds[NEO_LED_NR].setRGB(0,0,0);
  228.       FastLED.show();
  229.     }
  230.    
  231.    
  232.     if( millis() - Motor_Lauft_Z7 >= 2100) {
  233.       NEO_LED_NR = 7;
  234.        leds[NEO_LED_NR] = CRGB::Red;
  235.         FastLED.show();
  236.       Serial.println(NEO_LED_NR,Motor_Lauft_Z7);
  237.     }
  238.  
  239.   if( millis() - Motor_Lauft_Z7 >= 2110) {
  240.       leds[NEO_LED_NR].setRGB(0,0,0);
  241.       FastLED.show();
  242.  Motor_Lauft_Z0 = millis();
  243.  Motor_Lauft_Z1 = millis();
  244.  Motor_Lauft_Z2 = millis();
  245.  Motor_Lauft_Z3 = millis();
  246.  Motor_Lauft_Z4 = millis();
  247.  Motor_Lauft_Z5 = millis();
  248.  Motor_Lauft_Z6 = millis();
  249.  Motor_Lauft_Z7 = millis();
  250.  Motor_Lauft_Z8 = millis();
  251.  Motor_Lauft_Z9 = millis();
  252.  Motor_Lauft_Z10 = millis();
  253.  Motor_Lauft_Z11 = millis();
  254.        
  255.     }
  256.  
  257.    
  258.     //Pos_Light Gruen EIN
  259.     if(millis() - ZeitbisBlink1_Gruen >= 1000) {   
  260.         leds[12].setRGB(0,255,0);
  261.       FastLED.show();
  262.       }
  263.    
  264.     //Pos_Light Gruen AUS
  265.     if(millis() - ZeitbisBlink1_Gruen >= 1020) {  
  266.         leds[12].setRGB(0,0,0);
  267.       FastLED.show();
  268.       }
  269.     //Pos_Light Gruen EIN
  270.     if(millis() - ZeitbisBlink1_Gruen >= 1200) {   
  271.          leds[12].setRGB(0,255,0);
  272.       FastLED.show();
  273.       }
  274.     //Pos_Light Gruen AUS
  275.     if(millis() - ZeitbisBlink1_Gruen >= 1230) {   
  276.          leds[12].setRGB(0,0,0);
  277.       FastLED.show();
  278.         ZeitbisBlink1_Gruen = millis();
  279.        
  280.        }  
  281.      
  282.        //Pos_Light Rot EIN
  283.     if(millis() - ZeitbisBlink1_Rot >= 1000) {  
  284.         leds[13] = CRGB::Red;
  285.         FastLED.show();
  286.       }
  287.       //Pos_Light Rot AUS
  288.     if(millis() - ZeitbisBlink1_Rot >= 1020) {  
  289.        leds[13].setRGB(0,0,0);
  290.       FastLED.show();
  291.       }
  292.     //Pos_Light Rot EIN
  293.     if(millis() - ZeitbisBlink1_Rot >= 1200) {  
  294.        leds[13] = CRGB::Red;
  295.         FastLED.show();
  296.       }
  297.       //Pos_Light Rot AUS
  298.     if(millis() - ZeitbisBlink1_Rot >= 1230) {  
  299.          leds[13].setRGB(0,0,0);
  300.       FastLED.show();
  301.         ZeitbisBlink1_Rot = millis();
  302.        
  303.        
  304.       }
  305.  
  306.        }
  307.    
  308.  
  309.  
  310.  
  311.  
  312.  
  313. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement