Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<FastLED.h>
  2.  
  3. #define LED_PIN 7
  4. #define NUM_LEDS 44
  5.  
  6. CRGB leds[NUM_LEDS];
  7. int i=0,j=0,k=0;
  8.  
  9. void setup() {
  10.  
  11.   FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
  12.  
  13.     pinMode(2,OUTPUT); //Moteur 1
  14.     pinMode(3,OUTPUT); //Moteur 1
  15.     pinMode(4,OUTPUT); //Moteur 2
  16.     pinMode(5,OUTPUT); //Moteur 2
  17.  
  18. for (int i = 28; i <= 36; i++) {
  19.     leds[i] = CRGB ( 255, 255, 255);
  20.     FastLED.show();
  21.     delay(40);
  22.   }
  23.   for (int i = 36; i >= 28; i--) {
  24.     leds[i] = CRGB ( 0, 0, 0);
  25.     FastLED.show();
  26.     delay(40);
  27.   }  
  28.   delay(40);
  29.   for (int i = 36; i >= 28; i--) {
  30.     leds[i] = CRGB ( 255, 255, 255);
  31.     FastLED.show();
  32.     delay(40);
  33.   }
  34.   for (int i = 28; i <= 36; i++) {
  35.     leds[i] = CRGB ( 0, 0, 0);
  36.     FastLED.show();
  37.     delay(40);
  38.   }
  39.    tone(6, 500, 100);
  40.   delay(200);
  41.   tone(6, 900, 100);
  42.  
  43. Serial.begin(9600);
  44. }
  45. void loop() {
  46. if(Serial.available()>0)
  47.    {    
  48.       char data= Serial.read(); // reading the data received from the bluetooth module
  49.       switch(data)
  50.       {
  51.     case 'A': digitalWrite(2, HIGH); digitalWrite(3, LOW); digitalWrite(4, HIGH); digitalWrite(5, LOW); break; //AVANT
  52.    
  53.     case 'B': digitalWrite(2, LOW); digitalWrite(3, HIGH); digitalWrite(4, HIGH); digitalWrite(5, LOW); break; //GAUCHE
  54.    
  55.     case 'C': digitalWrite(2, HIGH); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, HIGH); break; //DROITE
  56.    
  57.     case 'D': {digitalWrite(2, LOW); digitalWrite(3, HIGH); digitalWrite(4, LOW); digitalWrite(5, HIGH);
  58.                leds[8]  = CRGB ( 255, 255, 255);
  59.                leds[11] = CRGB ( 255, 255, 255);        
  60.                FastLED.show();
  61.               } break; //ARRIERE+feux de recul
  62.              
  63.     case 'e': digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); break;//STOP tout
  64.    
  65.     case 'd': digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW);
  66.                leds[8]  = CRGB ( 0, 0, 0);
  67.                leds[11] = CRGB ( 0, 0, 0);
  68.                FastLED.show();break; //STOP marche arrière et feux de recul
  69.                
  70.     case 'F':  leds[29] = CRGB ( 255, 255, 255); //Phares on
  71.                leds[35] = CRGB ( 255, 255, 255);
  72.                leds[7]  = CRGB ( 255, 0, 0);
  73.                leds[12] = CRGB ( 255, 0, 0);
  74.                FastLED.show();
  75.                break;
  76.     case 'f': leds[29] = CRGB ( 0, 0, 0); //Phares on
  77.                leds[35] = CRGB ( 0, 0, 0);
  78.                leds[7]  = CRGB ( 0, 0, 0);
  79.                leds[12] = CRGB ( 0, 0, 0);
  80.                FastLED.show();
  81.                break;
  82.     case 'G': leds[40] = CRGB (255, 68, 0); //veilleuse on
  83.               leds[5] = CRGB (255, 68, 0);
  84.               leds[14] = CRGB (255, 68, 0);
  85.               leds[24] = CRGB (255, 68, 0);
  86.               FastLED.show();
  87.               break;
  88.     case 'g': leds[40] = CRGB (0, 0, 0); //veilleuse oFF(
  89.               leds[5] = CRGB (0, 0, 0);
  90.               leds[14] = CRGB (0, 0, 0);
  91.               leds[24] = CRGB (0, 0, 0);
  92.               FastLED.show();
  93.               break;
  94.     case 'H': tone(6, 700, 1000); break;
  95.     case 'h': noTone(6); break;
  96.     case 'I': leds[0<44] = CRGB (255, 255, 255); break;//allume tout en blanc
  97.     case 'i': leds[0<44] = CRGB (0, 0, 0); break;
  98.     case 'P': for (i=700; i<2000; i++) {
  99.               tone(6, i);
  100.               delay(1);
  101.               }
  102.  
  103.               for (i=2000; i>700; i--) {
  104.               tone(6, i);
  105.               delay(1);
  106.               }
  107.     default : break;
  108.   }
  109.  Serial.println(data);
  110.  }
  111.  delay(30);
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement