Quantcast
Channel: Tweaking4All.com » All Posts
Viewing all articles
Browse latest Browse all 142

Reply To: Fastled ws2812b synch with audio DFplayer mini

$
0
0

Hi Hans.

Help improve on this code so that the led animation runs smoothly, maybe with use of millis.

Below is the video of how its running. notice the red and green lighting have to move first before the other blue circles the ring. I want them to move seamlessly.

Thanks

#include <Adafruit_NeoPixel.h>
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#define PIN_A 3
#define PIN_B 4
//#define PIN 7
//#define PIN 8
#define BRIGHTNESS 30
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS_A 8
#define NUMPIXELS_B 12



//////////////////////////////////////////////Define variables for LCD1602//////////////////////////////////////////

#define I2C_ADDR 0x27 //Define I2C Address where the PCF8574A is
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7

////////////////////////////////////////////////////Initialize the LCD1602///////////////////////////////////////////
LiquidCrystal_I2C lcd(I2C_ADDR, En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
// BS E D4 D5 D6 D7
//LiquidCrystal_I2C lcd(7, 8, 9, 10, 11, 12);
void printDetail(uint32_t type, int value);

Adafruit_NeoPixel pixels_A = Adafruit_NeoPixel(NUMPIXELS_A, PIN_A, NEO_GRBW + NEO_KHZ800);
Adafruit_NeoPixel pixels_B = Adafruit_NeoPixel(NUMPIXELS_B, PIN_B, NEO_GRBW + NEO_KHZ800);

void setup()
{
//Serial.begin(115200);

// Serial.println();
pixels_A.setBrightness(BRIGHTNESS);
pixels_A.begin(); // This initializes the NeoPixel library.
pixels_B.setBrightness(BRIGHTNESS);
pixels_B.begin(); // This initializes the NeoPixel library.
lcd.begin (16,2); //Define the LCD as 16 column by 2 rows
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE); //Switch on the backlight
lcd.setBacklight(HIGH);

}

void loop()
{

unsigned int i,j;
lcd.setCursor(2,0);
lcd.print("Lithium Atom");
lcd.setCursor(1,1);
lcd.print("P=3 N=4 MU=?");


for (unsigned int i=0; i<4; i++) for (unsigned int j=0; j<12; j++)
{

pixels_A.setPixelColor(i, pixels_A.Color(255,0,0));
pixels_A.setPixelColor(4+i,pixels_A.Color(0,255,0));
pixels_A.show(); // This sends the updated pixel color to the hardware.
delay(50);
pixels_A.clear();
pixels_B.setPixelColor(j, pixels_B.Color(0,0,255));
pixels_B.show(); // This sends the updated pixel color to the hardware.
delay(100);
pixels_B.clear();
}

}


Viewing all articles
Browse latest Browse all 142

Trending Articles