ENIB 2022 - groupe B : chaise volante
Sommaire
photo de l'équipe
Que fait ce projet ?
L'attraction chaise volante est une attraction de fête foraine qui consiste a faire tourner les chaises et elle s'élever grâce à la force centrifuge
Liste des composants
- arduino
- bois
- led
- moteur
- auto collant
- carton
- fils
circuit electrique
Code
#include <FastLED.h>
#define NUM_LEDS 20 /* The amount of pixels/leds you have */
#define DATA_PIN 2 /* The pin your data line is connected to */
#define LED_TYPE WS2812B /* I assume you have WS2812B leds, if not just change it to whatever you have */
#define BRIGHTNESS 255 /* Control the brightness of your leds */
#define SATURATION 255 /* Control the saturation of your leds */
#include <Servo.h>
Servo myservo; // création de l'objet myservo
int pin_servo = 0; // Pin 6 sur lequel est branché le servo sur l'Arduino si vous utilisez un ESP32 remplacez le 6 par 4 et si vous utilisez un ESP8266 remplacez le 6 par 2
int position = 40; // Position souhaitée
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<LED_TYPE, DATA_PIN>(leds, NUM_LEDS);
myservo.attach(pin_servo); // attache le servo au pin spécifié sur l'objet myservo
myservo.write(position);
}
void loop() {
for (int j = 0; j < 255; j++) {
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CHSV(i - (j * 2), SATURATION, BRIGHTNESS); /* The higher the value 4 the less fade there is and vice versa */
}
FastLED.show();
delay(10); /* Change this to your hearts desire, the lower the value the faster your colors move (and vice versa) */
}
}
