Guiye Perez Bongiovanni
Published © GPL3+

Desktop Christmas CyberTree 2023 Arduino Nano

Desktop Christmas tree, small dimensions, portable, built with recycled elements, high luminosity color LEDs, an RGB LED and Arduino Nano.

IntermediateShowcase (no instructions)5 hours48
Desktop Christmas CyberTree 2023 Arduino Nano

Things used in this project

Hardware components

Arduino Nano V3.0 ATMEGA328P
×1
High Brightness LED, Color
×8
Aluminum dissipator
×2
Hard disk reading head
×1
Glass Ball
×2
Female/Female Jumper Wires
Female/Female Jumper Wires
×1
Mini Breadboard for Arduino Nano (generic)
×1
5V Power Bank
×1
Resina epoxi
×1

Software apps and online services

Arduino IDE
Arduino IDE
https://chat.openai.com

Story

Read more

Schematics

Schematic

Code

CyberTree 2023

Arduino
// Definicin de pines para los LEDs
const int blanco1Pin = 12;
const int rojo1Pin = 8;
const int naranja1Pin = 7;
const int azul1Pin = 6;
const int blanco2Pin = 5;
const int azul2Pin = 4;
const int naranja2Pin = 3;
const int rojo2Pin = 2;

const int rojoRGBPin = 9;
const int verdeRGBPin = 10;
const int azulRGBPin = 11;

// Definir los pines para el LED RGB
int rgbLedPins[] = {9, 10, 11};

// Definir los pines para los LEDs de alto brillo
int whiteLedPins[] = {12, 5};
int redLedPins[] = {8, 2};
int blueLedPins[] = {6, 4};
int orangeLedPins[] = {7, 3};

// Secuencia de colores RGB
int colores[][3] = {
  {143, 0, 255},
  {75, 0, 130},
  {0, 0, 255},
  {0, 255, 0},
  {255, 127, 0},
  {255, 0, 0}
};

// Colores especficos para SECUENCIA 2
int blancoRGB[] = {255, 255, 255};
int rojoRGB[] = {255, 0, 0};
int azulRGB[] = {0, 0, 255};
int naranjaRGB[] = {255, 150, 0};

void setup() {
  // Configurar pines como salidas
  for (int i = 2; i <= 12; i++) {
    pinMode(i, OUTPUT);
  }

  pinMode(azulRGBPin, OUTPUT);
  pinMode(verdeRGBPin, OUTPUT);
  pinMode(rojoRGBPin, OUTPUT);
}

void loop() {
  // SECUENCIA 1: Escala cromtica en el LED RGB durante 1 segundo
  secuenciaRGB();

  // SECUENCIA 2: Encender LEDs de alto brillo segn la secuencia
  secuenciaLedsAltoBrillo();

  // SECUENCIA 3: Encender LEDs azules y el LED RGB azul durante 2 segundos
  secuenciaAzul();

  // SECUENCIA 4: Encender LEDs blancos y el LED RGB blanco durante 2 segundos
  secuenciaBlanco();

  // SECUENCIA 5: Encender LEDs naranjas y el LED RGB naranja durante 2 segundos
  secuenciaNaranja();

  // SECUENCIA 6: Encender LEDs rojos y el LED RGB rojo durante 2 segundos
  secuenciaRojo();
}

void secuenciaRGB() {
  // Duracin del ciclo del LED RGB (en segundos)
  int durationSecondsRGB = 1;

  // Transicin gradual entre los colores
  for (int j = 0; j < 6; j++) {
    int r1 = colores[j][0];
    int g1 = colores[j][1];
    int b1 = colores[j][2];

    int r2 = colores[(j + 1) % 6][0];
    int g2 = colores[(j + 1) % 6][1];
    int b2 = colores[(j + 1) % 6][2];

    // Realizar la transicin entre los colores
    for (int i = 0; i <= 255; i++) {
      int r = map(i, 0, 255, r1, r2);
      int g = map(i, 0, 255, g1, g2);
      int b = map(i, 0, 255, b1, b2);

      analogWrite(rgbLedPins[0], r);
      analogWrite(rgbLedPins[1], g);
      analogWrite(rgbLedPins[2], b);
      
      delay(durationSecondsRGB * 300 / 256);  // Tiempo dividido en 256 pasos
    }
  }

  // Apagar el LED RGB al final del ciclo
  apagarLedsRGB();
}

void secuenciaLedsAltoBrillo() {
  secuenciaDeArribaAbajo();
  secuenciaDeAbajoArriba();
  secuenciaDeArribaAbajo();
  secuenciaDeAbajoArriba();
  secuenciaDeArribaAbajoConParpadeo();
  secuenciaDeArribaAbajoConParpadeo();
  secuenciaDeArribaAbajoConParpadeo();
  banderaArgentina();
  secuenciaTodosLEDs();
}

void secuenciaDeArribaAbajo() {
  for (int i = 2; i <= 12; i++) {
    encenderLED(i);
    delay(50);
  }
  // Apaga todos los LEDs al final de la secuencia
  apagarTodosLEDs();
}

void secuenciaDeAbajoArriba() {
  for (int i = 12; i >= 2; i--) {
    encenderLED(i);
    delay(40);
  }
  // Apaga todos los LEDs al final de la secuencia
  apagarTodosLEDs();
}

void secuenciaDeArribaAbajoConParpadeo() {
  for (int i = 2; i <= 12; i++) {
    parpadeoLED(i);
    delay(20);
  }
  // Apaga todos los LEDs al final de la secuencia
  apagarTodosLEDs();
}

void banderaArgentina() {
  encenderLED(azul1Pin);
  encenderLED(blanco2Pin);
  encenderLED(azul2Pin);
  
  // Activa los componentes rojo y verde para obtener amarillo
  analogWrite(rojoRGBPin, 255);
  analogWrite(verdeRGBPin, 255);
  analogWrite(azulRGBPin, 0);

  delay(500);  // Mantn el color amarillo durante 1 segundo

  // Apaga todos los componentes para apagar el LED
  analogWrite(rojoRGBPin, 0);
  analogWrite(verdeRGBPin, 0);
  analogWrite(azulRGBPin, 0);

  delay(300);  // Espera 1 segundo antes de repetir

  apagarTodosLEDs();
}

void secuenciaTodosLEDs() {
  for (int j = 0; j < 5; j++) {
    encenderTodosLEDs();
    delay(30);
    apagarTodosLEDs();
    delay(80);
  }
}

void secuenciaAzul() {
  // Duracin del ciclo de azul (en segundos)
  int durationSecondsAzul = 2;

  // Enciende los LEDs azules y el LED RGB en azul
  for (int i = 0; i < 2; i++) {
    digitalWrite(blueLedPins[i], HIGH);
  }

  analogWrite(rgbLedPins[0], azulRGB[0]);
  analogWrite(rgbLedPins[1], azulRGB[1]);
  analogWrite(rgbLedPins[2], azulRGB[2]);

  delay(durationSecondsAzul * 300);

  // Apaga los LEDs azules y el LED RGB al final de la secuencia
  for (int i = 0; i < 2; i++) {
    digitalWrite(blueLedPins[i], LOW);
  }

  apagarLedsRGB();
}

void secuenciaBlanco() {
  // Duracin del ciclo de blanco (en segundos)
  int durationSecondsBlanco = 2;

  // Enciende los LEDs blancos y el LED RGB en blanco
  for (int i = 0; i < 2; i++) {
    digitalWrite(whiteLedPins[i], HIGH);
  }

  analogWrite(rgbLedPins[0], blancoRGB[0]);
  analogWrite(rgbLedPins[1], blancoRGB[1]);
  analogWrite(rgbLedPins[2], blancoRGB[2]);

  delay(durationSecondsBlanco * 300);

  // Apaga los LEDs blancos y el LED RGB al final de la secuencia
  for (int i = 0; i < 2; i++) {
    digitalWrite(whiteLedPins[i], LOW);
  }

  apagarLedsRGB();
}

void secuenciaNaranja() {
  // Duracin del ciclo de naranja (en segundos)
  int durationSecondsNaranja = 2;

  // Enciende los LEDs naranjas y el LED RGB en naranja
  for (int i = 0; i < 2; i++) {
    digitalWrite(orangeLedPins[i], HIGH);
  }

  analogWrite(rgbLedPins[0], naranjaRGB[0]);
  analogWrite(rgbLedPins[1], naranjaRGB[1]);
  analogWrite(rgbLedPins[2], naranjaRGB[2]);

  delay(durationSecondsNaranja * 300);

  // Apaga los LEDs naranjas y el LED RGB al final de la secuencia
  for (int i = 0; i < 2; i++) {
    digitalWrite(orangeLedPins[i], LOW);
  }

  apagarLedsRGB();
}

void secuenciaRojo() {
  // Duracin del ciclo de rojo (en segundos)
  int durationSecondsRojo = 2;

  // Enciende los LEDs rojos y el LED RGB en rojo
  for (int i = 0; i < 2; i++) {
    digitalWrite(redLedPins[i], HIGH);
  }

  analogWrite(rgbLedPins[0], rojoRGB[0]);
  analogWrite(rgbLedPins[1], rojoRGB[1]);
  analogWrite(rgbLedPins[2], rojoRGB[2]);

  delay(durationSecondsRojo * 300);

  // Apaga los LEDs rojos y el LED RGB al final de la secuencia
  for (int i = 0; i < 2; i++) {
    digitalWrite(redLedPins[i], LOW);
  }

  apagarLedsRGB();
}

void encenderTodosLEDs() {
  for (int i = 2; i <= 12; i++) {
    digitalWrite(i, HIGH);
  }
}

void encenderLED(int pinLED) {
  digitalWrite(pinLED, HIGH);
}

void parpadeoLED(int pinLED) {
  digitalWrite(pinLED, HIGH);
  delay(20);  // Duracin del parpadeo
  digitalWrite(pinLED, LOW);
}

void apagarTodosLEDs() {
  for (int i = 2; i <= 12; i++) {
    digitalWrite(i, LOW);
  }
}

void apagarLedsRGB() {
  analogWrite(rgbLedPins[0], 0);
  analogWrite(rgbLedPins[1], 0);
  analogWrite(rgbLedPins[2], 0);
}

Credits

Guiye Perez Bongiovanni
12 projects • 22 followers
Artist / Maker
Contact

Comments

Please log in or sign up to comment.