Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

Lighting+Effects

Título: Lighting+Effects: Creating Stunning Light Effects with Arduino

Introduction: Lighting effects play a crucial role in various applications, such as stage performances, home automation, and decorative lighting. This article aims to explore the importance and utility of lighting effects and provide practical examples using Arduino.

Project: For this example project, we will create an LED strip that produces mesmerizing lighting effects. The objective is to showcase the versatility and creativity that can be achieved with Arduino and lighting effects. The project will include functionalities like color fading, rainbow effects, and synchronized patterns.

List of Components: To complete this project, you will need the following components:

Examples: Example 1: Color Fading

#include <Adafruit_NeoPixel.h>

#define LED_PIN 6
#define NUM_LEDS 60

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  strip.begin();
  strip.show();
}

void loop() {
  for (int i = 0; i < NUM_LEDS; i++) {
    strip.setPixelColor(i, strip.Color(255, 0, 0));
    strip.show();
    delay(50);
  }
  for (int i = 0; i < NUM_LEDS; i++) {
    strip.setPixelColor(i, strip.Color(0, 255, 0));
    strip.show();
    delay(50);
  }
  for (int i = 0; i < NUM_LEDS; i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 255));
    strip.show();
    delay(50);
  }
}

This code demonstrates a simple color fading effect where the LED strip smoothly transitions between red, green, and blue colors.

Example 2: Rainbow Effect

#include <Adafruit_NeoPixel.h>

#define LED_PIN 6
#define NUM_LEDS 60

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  strip.begin();
  strip.show();
}

void loop() {
  rainbowCycle(20);
}

void rainbowCycle(uint8_t wait) {
  uint16_t i, j;

  for (j = 0; j < 256 * 5; j++) {
    for (i = 0; i < NUM_LEDS; i++) {
      strip.setPixelColor(i, Wheel(((i * 256 / NUM_LEDS) + j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if (WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if (WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}

This code creates a mesmerizing rainbow effect on the LED strip by cycling through different colors smoothly.

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.