FABRICATION D’UNE DÉCO DE NOËL AVEC UNE VIELLE CARTE ÉLECTRONIQUE

La vidéo

Liste des composants

Arduino Nano – AMAZON

LEDs RGB à cathode commune –  AMAZON

Imprimante 3D – Gearbest

Fausse neige – AMAZON

Le Schéma

Le Code

const int RPinA = 3;
const int GPinA = 5;
const int BPinA = 6;
const int RPinB = 9;
const int GPinB = 10;
const int BPinB = 11;

int i, Ra, Ga, Ba, Rb, Gb, Bb;

void setup() {
  pinMode(RPinA, OUTPUT);
  pinMode(GPinA, OUTPUT);
  pinMode(BPinA, OUTPUT);
  pinMode(RPinB, OUTPUT);
  pinMode(GPinB, OUTPUT);
  pinMode(BPinB, OUTPUT);
}
void loop() {
  i = 0;
  Ra = 255;
  Ga = 0;
  Ba = 0;
  Rb = 0;
  Gb = 255;
  Bb = 0;
  while (i<255){
    setColorA(Ra, Ga, Ba);
    setColorB(Rb, Gb, Bb);
    delay(20);
    i = i+2;
    Ra = Ra-2;
    Ga = Ga+2;

    Gb = Gb-2;
    Bb = Bb+2;
  }
  i = 0;
  Ra = 0;
  Ga = 255;
  Ba = 0;
  
  Rb = 0;
  Gb = 0;
  Bb = 255;
  while (i<255){
    setColorA(Ra, Ga, Ba);
    setColorB(Rb, Gb, Bb);
    delay(20);
    i = i+2;
    Ga = Ga-2;
    Ba = Ba+2;

    Bb = Bb-2;
    Rb = Rb+2;
  }
  i = 0;
  Ra = 0;
  Ga = 0;
  Ba = 255;
  
  Rb = 255;
  Gb = 0;
  Bb = 0;
  while (i<255){
    setColorA(Ra, Ga, Ba);
    setColorB(Rb, Gb, Bb);
    delay(20);
    i = i+2;
    Ba = Ba-2;
    Ra = Ra+2;

    Rb = Rb-2;
    Gb = Gb+2;
  }
  }
void setColorA(int RValueA, int GValueA, int BValueA) {
  analogWrite(RPinA, RValueA);
  analogWrite(GPinA, GValueA);
  analogWrite(BPinA, BValueA);
}
void setColorB(int RValueB, int GValueB, int BValueB) {
  analogWrite(RPinB, RValueB);
  analogWrite(GPinB, GValueB);
  analogWrite(BPinB, BValueB);
}