Stargate effect on Arduino + SK6812

Hello!

I would like to share with you my project on Arduino 2560 in which i controll Magic LED strip (SK6812) via SPI protocol!

Here is the code:

#include <SPI.h>

typedef struct {
  uint8_t g;
  uint8_t r;
  uint8_t b;
} TRGB ;

TRGB mbuf[24];

int ir=0, ig=8, ib=16;

void setup() {
  SPI.begin();
  SPI.setClockDivider( SPI_CLOCK_DIV32 );
}

void draw_stargate() {

  memset( mbuf, 0, sizeof(mbuf) );
  
  mbuf[ir].r = 5;
  mbuf[ig].g = 5;
  mbuf[ib].r = 5; mbuf[ib].g = 3;

  if( ++ir == 24 ) ir = 0;
  if( --ig < 0 ) ig = 23;
  if( ++ib == 24 ) ib = 0;

  mbuf[3].b = 10;
  mbuf[9].b = 10;
  mbuf[15].b = 10;
  mbuf[21].b = 10;

  cli();
  SPI.transfer( mbuf, sizeof(mbuf) );
  sei();
}

void loop() {
  draw_stargate();
  delay(50);
}

Have you ever heard about controlling digital LED strips via SPI?

I created short video with simple connections and overall program in Arduino IDE - check this out:

If you’re wondering how I skipped the Assembler struggle to program the NZR protocol and used a simple SPI - I used the Magic Hercules module.

I recently created project on kickstarter with that MH module - if you want to know how it works and what is exactly - check the link below:
https://www.kickstarter.com/projects/2066504440/magic-hercules-driver-for-digital-leds?ref=3qyqog

If you're wondering how I skipped the Assembler struggle to program the NZR protocol and used a simple SPI - I used the Magic Hercules module.

Most people use FASTLED or NeoPixel libraries. The authors of those libraries did the struggling so the rest of us don't have to. Those libraries are free. What is the advantage of your module that justifies the cost?

The very fact of using the SPI protocol, which is probably one of the first known by beginners. It is simple and well known.

The MH module is another of the possibilities of programming digital LEDs. When it's time to change the microcontroller family, the magic hercules module will always be there to help you program the magic LEDs via SPI protocol.

It allows you to use several interrupts when sending data to a bar with 1024 LEDs.

It enables the connection of microcontrollers supplied with the voltage of +3.3 V without the need to add a voltage translation module.

It acts as a digital LED tester without the need for programming, we can check whether the tape is functional or the sequence of colors in the diode.

Thanks to the use of SPI, we can easily transfer our own effects to other families of microcontrollers.

The Magic Hercules module is an alternative to existing solutions. Everyone can decide for themselves what solution is best for them :slight_smile:

Everyone can decide for themselves what solution is best for them :slight_smile:

Agreed. But I would advise against putting down the deposit on that Tesla just yet :wink: