Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<FastLED.h>
- #define LED_PIN 7
- #define NUM_LEDS 44
- CRGB leds[NUM_LEDS];
- int i=0,j=0,k=0;
- void setup() {
- FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
- pinMode(2,OUTPUT); //Moteur 1
- pinMode(3,OUTPUT); //Moteur 1
- pinMode(4,OUTPUT); //Moteur 2
- pinMode(5,OUTPUT); //Moteur 2
- for (int i = 28; i <= 36; i++) {
- leds[i] = CRGB ( 255, 255, 255);
- FastLED.show();
- delay(40);
- }
- for (int i = 36; i >= 28; i--) {
- leds[i] = CRGB ( 0, 0, 0);
- FastLED.show();
- delay(40);
- }
- delay(40);
- for (int i = 36; i >= 28; i--) {
- leds[i] = CRGB ( 255, 255, 255);
- FastLED.show();
- delay(40);
- }
- for (int i = 28; i <= 36; i++) {
- leds[i] = CRGB ( 0, 0, 0);
- FastLED.show();
- delay(40);
- }
- tone(6, 500, 100);
- delay(200);
- tone(6, 900, 100);
- Serial.begin(9600);
- }
- void loop() {
- if(Serial.available()>0)
- {
- char data= Serial.read(); // reading the data received from the bluetooth module
- switch(data)
- {
- case 'A': digitalWrite(2, HIGH); digitalWrite(3, LOW); digitalWrite(4, HIGH); digitalWrite(5, LOW); break; //AVANT
- case 'B': digitalWrite(2, LOW); digitalWrite(3, HIGH); digitalWrite(4, HIGH); digitalWrite(5, LOW); break; //GAUCHE
- case 'C': digitalWrite(2, HIGH); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, HIGH); break; //DROITE
- case 'D': {digitalWrite(2, LOW); digitalWrite(3, HIGH); digitalWrite(4, LOW); digitalWrite(5, HIGH);
- leds[8] = CRGB ( 255, 255, 255);
- leds[11] = CRGB ( 255, 255, 255);
- FastLED.show();
- } break; //ARRIERE+feux de recul
- case 'e': digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); break;//STOP tout
- case 'd': digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW);
- leds[8] = CRGB ( 0, 0, 0);
- leds[11] = CRGB ( 0, 0, 0);
- FastLED.show();break; //STOP marche arrière et feux de recul
- case 'F': leds[29] = CRGB ( 255, 255, 255); //Phares on
- leds[35] = CRGB ( 255, 255, 255);
- leds[7] = CRGB ( 255, 0, 0);
- leds[12] = CRGB ( 255, 0, 0);
- FastLED.show();
- break;
- case 'f': leds[29] = CRGB ( 0, 0, 0); //Phares on
- leds[35] = CRGB ( 0, 0, 0);
- leds[7] = CRGB ( 0, 0, 0);
- leds[12] = CRGB ( 0, 0, 0);
- FastLED.show();
- break;
- case 'G': leds[40] = CRGB (255, 68, 0); //veilleuse on
- leds[5] = CRGB (255, 68, 0);
- leds[14] = CRGB (255, 68, 0);
- leds[24] = CRGB (255, 68, 0);
- FastLED.show();
- break;
- case 'g': leds[40] = CRGB (0, 0, 0); //veilleuse oFF(
- leds[5] = CRGB (0, 0, 0);
- leds[14] = CRGB (0, 0, 0);
- leds[24] = CRGB (0, 0, 0);
- FastLED.show();
- break;
- case 'H': tone(6, 700, 1000); break;
- case 'h': noTone(6); break;
- case 'I': leds[0<44] = CRGB (255, 255, 255); break;//allume tout en blanc
- case 'i': leds[0<44] = CRGB (0, 0, 0); break;
- case 'P': for (i=700; i<2000; i++) {
- tone(6, i);
- delay(1);
- }
- for (i=2000; i>700; i--) {
- tone(6, i);
- delay(1);
- }
- default : break;
- }
- Serial.println(data);
- }
- delay(30);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement