Award
Congratulations RobertL184, for answering the question and has received an EZ-Credit award! Share what you have learned and create a tutorial to help others by clicking here.

Help Connecting A Neopixel Ring

Assistance Requested

Help merne with their question and receive $10 of EZ-Credit to get more robots and parts from our store. The following information was provided about their previous efforts searching tutorials for a resolution.

merne claims to have checked these sources:
 
#21

I've been playing with a Neo Ring the last couple of days and have a script working thru the EZBv4. I have tried running the scripts above and get this error message for all 3 - what am I missing?

Arduino: 1.6.3 (Windows 8.1), Board: "Arduino Uno"

Neo_ring_from_forum.ino:1:1: error: 'Code' does not name a type

Neo_ring_from_forum.ino:36:1: error: 'Adafruit_NeoPixel' does not name a type

Neo_ring_from_forum.ino: In function 'void setup()':

Neo_ring_from_forum.ino:47:1: error: 'strip' was not declared in this scope

Neo_ring_from_forum.ino: In function 'void loop()':

Neo_ring_from_forum.ino:63:1: error: 'strip' was not declared in this scope

Neo_ring_from_forum.ino:73:1: error: 'strip' was not declared in this scope

Neo_ring_from_forum.ino:80:1: error: 'strip' was not declared in this scope

Neo_ring_from_forum.ino:86:1: error: 'strip' was not declared in this scope

Error compiling.

Thanks

#22

Remove the word Code: from the top of your arduino file and try to compile it again.

#23

If it still doesn't work, make sure that you have the Adafruit_NeoPixel library loaded into your user libraries.

#24

Ok, that worked, got it loaded, however when I enter C in the serial monitor nothing happens. Are there some color values that have to be added/changed?

#25

I don't have my arduino or neopixel yet. I think EZ-Builder would use something like this

SendSerial(d0, 9600, "C0,255,0,0" ) 

with the wire from the signal of D0 to the serial pin or rx pin on the arduino. I'm new at this part for sure as I don't even have one yet.

#26

The ring I think would be to pin 6 on the arduino for signal and provide power to the ring. I read something about the power should be from the same source as the arduino. This could come off of the arduino if you would like.

#27

Dave, has the code you posted been tested? I was sending the command thru the Arduino serial monitor, should work there. I will try and send it thru the EZB.

#28

Not at all. I dont even have an arduino yet. It should be here soon. The neopixel may be a week out or so. This was more of a conversation to get ideas in a topic that already existed. Read post #12.

#29

Robert, what do you think about this. The V4 could set an arduino pin to high which would then be caught in the loop and kick the arduino code to a function that is looking for a serial connection to get the new values. The trigger port would be set to low again by the V4 and the arduino would see this and start the loop again using those color settings.

#30

OK. Here's where I am at running a Neo Pixel Ring off of the EZBv4.
I have to say right up front that what I am going to post is the work of our friend Luis Vazquez who has guided me thru get the ring up and running.

Connection between the EZB and the Arduino

Digital Port 18 (TX) to RX on the Arduino
Digital Port 19 (RX) to TX on theArduino
These are used as UART2
Connect a ground wire between the EZB and the Arduino:

Note; You can't upload a script to the Arduino with EZB powered up.

Arduino script:

Code:


#include <Adafruit_NeoPixel.h>


#define PIN 6

// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);

// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel. Avoid connecting
// on a live circuit...if you must, connect GND first.

void setup() {
Serial.begin(9600);

strip.begin();
strip.show(); // Initialize all pixels to 'off'
}

void loop() {


if (Serial.available())
{


int ib = 0;
ib = Serial.read();


// Stop All display
if (ib == 33) {
strip.show(); // Initialize all pixels to 'off'
}



// ColorWipes
// Blue = "B" or 66
if (ib == 66) {
colorWipe(strip.Color(0, 0, 255), 5); // Blue

}
//Blue White = "P" or 80
if (ib == 80){
colorWipe(strip.Color(0, 0, 255), 20);
colorWipe(strip.Color(0, 0, 0), 30);
}
// Red = "R" or 82
if (ib == 82) {
colorWipe(strip.Color(255, 0, 0), 10); // Red

}
// Green = "G" or 71
if (ib == 71) {
colorWipe(strip.Color(0, 255, 0), 50); // Green
}
if (ib == 87){
colorWipe(strip.Color(0, 0, 0), 10);
}

// ChaseSetting
// White = "w" or 119
if (ib == 119) {
theaterChase(strip.Color(127, 127, 127), 50); // White
}
// Red = "r" or 114
if (ib == 114) {
theaterChase(strip.Color(127, 0, 0), 50); // Red

}

if (ib == 98)
{
theaterChase(strip.Color( 0, 0, 127), 50); // Blue
}

if (ib == 88)
{
rainbow(20);
}
if (ib == 89)
{
rainbowCycle(20);
}

if (ib == 90)
{
theaterChaseRainbow(50);
}


}






}

// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
for (uint16_t i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
delay(wait);
}
}

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

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

// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
uint16_t i, j;

for (j = 0; j < 256 * 5; j++) { // 5 cycles of all colors on wheel
for (i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}
strip.show();
delay(wait);
}
}

//Theatre-style crawling lights.
void theaterChase(uint32_t c, uint8_t wait) {
for (int j = 0; j < 10; j++) { //do 10 cycles of chasing
for (int q = 0; q < 3; q++) {
for (int i = 0; i < strip.numPixels(); i = i + 3) {
strip.setPixelColor(i + q, c); //turn every third pixel on
}
strip.show();

delay(wait);

for (int i = 0; i < strip.numPixels(); i = i + 3) {
strip.setPixelColor(i + q, 0); //turn every third pixel off
}
}
}
}

//Theatre-style crawling lights with rainbow effect
void theaterChaseRainbow(uint8_t wait) {
for (int j = 0; j < 256; j++) { // cycle all 256 colors in the wheel
for (int q = 0; q < 3; q++) {
for (int i = 0; i < strip.numPixels(); i = i + 3) {
strip.setPixelColor(i + q, Wheel( (i + j) % 255)); //turn every third pixel on
}
strip.show();

delay(wait);

for (int i = 0; i < strip.numPixels(); i = i + 3) {
strip.setPixelColor(i + q, 0); //turn every third pixel off
}
}
}
}

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
if (WheelPos < 85) {
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
} else if (WheelPos < 170) {
WheelPos -= 85;
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
} else {
WheelPos -= 170;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
}



Makes sure you have the library for it.

You should be able to send it commands thru the Arduino Serial Monitor by entering the (ASCII Character). For example in the code above enter "B" or 66 and the Blue colorwipe should run.

To send the commands via the EZB.

Create an initialization script and have it run when you connect to the EZB

Code:


UARTInit( 0,2,9600 )



Create a script to send the commands to the Arduino, for example, this will run the Blue colorswipe, once.

Code:


UARTWrite(0,2,"B")


To run it multiple times you can put it in a loop.

I have found the script hard to control, for example, running in a loop if you push stop it will still run for awhile.

What I am trying to achieve is a pulsing effect that can be changed to different colors, when needed. Kind of like a mood indicator.
If anyone can help out there help with a script for that, it would be great.
Once again thanks Luis for all your help.