I have a problem with flickering neopixel leds. I'm using a setup of 6 strips of 8xWS2812 5050 leds. I've connected these to a 5v power supply (USB charger) and an Arduino Uno running the Neopixel simple example code:
// NeoPixel Ring simple sketch (c) 2013 Shae Erisson
// released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN 6
#define NUMPIXELS 48
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
int delayval = 50; // delay for half a second
void setup() {
// This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
#if defined (__AVR_ATtiny85__)
if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
// End of trinket special code
pixels.begin(); // This initializes the NeoPixel library.
}
void loop() {
for(int i=0;i<NUMPIXELS;i++){
pixels.setPixelColor(i, pixels.Color(200,200,200)); // Moderately bright green color.
pixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds).
}
}
I've connected a 500uf 10v capacitor between the 5v and the gnd. And a 470 ohm resister between the arduino and the datapin.
I've noticed that the leds also flicker when the leds are on and the datapin is disconnected. The flickering is subtle, but annoying.
I've also tried an alternative power supply. For this I used a adjustable lab power supply. But the same problem persists.
I have to use these leds for a project that I need to finish tomorrow. (I know i should have done this earlier) Is there anyone who could offer me some help? I could really use some.
EDIT: The flickering had to do with the quality of the leds. These weren't real neopixels, instead I received some bad fake ones.
Related
I purchased a 5 meter strip of WS2812B LEDs to be used in conjunction with a motion detector (WS2812B 5 Pins RGBW RGBWW 4 IN 1 LED Strip Light Non-Waterproof DC5V).
The strips are hooked up to a 5V power supply (USB powerbank) and GND/5V/signal on pin 6 on an arduino UNO.
I should note that I so far have not cut the LED strip, so all 5 meters are intact.
I've tried getting the LEDs to emit simple colors using the FASTLED library using the code below. The Blue/blue/blue combination results in the colors Blue/Red/Green on LEDs 0-2
Changing to Red/Red/Red produces Yellow-ish/blue/off
Changing to Green/Green/Green produces the colors Red/lightgreen-ish/off
I've tried shifting from RGB to RBG color scheme to no avail
I don't have much information on the LED strip apart from what I have already provided you with
Can you give me any ideas on how to proceed?
#include "FastLED.h"
#define NUM_LEDS 5
#define DATA_PIN 6
// Define the array of leds
CRGB leds[NUM_LEDS];
void setup()
{
//FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS); // for GRB LEDs
}
void loop()
{
leds[0] = CRGB::Blue;
leds[1] = CRGB::Blue;
leds[2] = CRGB::Blue;
FastLED.show();
delay(500);
This might not be the exact answer you are looking for, but I’d suggest using the Adafruit_Neopixel.h library for your LED’s. Just did a Projekt with that library and the exact LED strip you are using and it is working great so far.
#include "Adafruit_NeoPixel.h"`
#define LED_PIN 6
#define LED_COUNT 60
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
int red = 100;
int green = 0;
int blue = 0;
void setup() {
strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
strip.show(); // Turn OFF all pixels ASAP}
}
void loop() {
for (i=0; i<LED_COUNT; i++){
strip.setPixelColor(i, strip.Color(Red, Green, Blue));
strip.show();
}
}
This should make 60 LED’s red. I’ve also got an LED Project on my GitHub page if you want to look that up. If the code above still doesn’t work I assume your wiring is wrong. I power my chip and LEDs off a power supple and also use the ground of the power supply.
I am using Arduino Nano with HX711 scales module and cc2541 Bluetooth module(Bluetooth 4.0) to send data to Android device.
#define RX 11
#define TX 10
#include "HX711.h"
HX711 scale(A1, A0);
float scale_calibration = -13.5;
float mass,massround;
float units;
int out;
#include <SoftwareSerial.h>
SoftwareSerial bluetooth(TX, RX);
void setup()
{
bluetooth.begin(9600);
scale.set_scale();
scale.tare();
scale.set_scale(scale_calibration);
}
void loop()
{
for(int i = 0;i < 10; i ++) units =+ scale.get_units(), 1;
units / 10;
mass = units * 0.035274;
massround=mass;
out = round(massround);
out = abs(out);
if(out<0)
{
out=0;
scale.tare();
}
bluetooth.println(out);
}
If I run Arduino using USB coonected to my PC, the scales work perfect and give right results via Bluetooth. However, when I run Arduino using battery (not connected to PC), I get 0-3 grams value, while there is nothing on the scales. So because of that all measurements are incorrect. How can I fix this problem?
When your Arduino is powered from USB, it and the HX711 probably have both VCC and VDD at +5 volts, making the 'reference' voltage (VDD) 5 volts.
When running off battery, the hardware is receiving ~3 volts, and if VCC and VDD are shorted together on the HX711, it might 'kinda work' but would give spurious results.
There's probably jumpers or bridges to set VCC and VDD on both the arduino and the load cell. CAUTION! I'm just guessing here, and be sure to read the tech docs before changing the voltage settings, it's easy to cook these little circuits with a minor change in voltages.
This might be better asked in a hardware or electrical engineering channel.
I've got an Arduino with a WS2812 hooked up to it, powered by the USB on my computer and I am trying to run the following code:
#include <FastLED.h>
#define NUM_LEDS 144
#define DATA_PIN 6
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
FastLED.show();
}
void loop() {
for(int dot = 0; dot < NUM_LEDS; dot++) {
fill_solid(leds, NUM_LEDS, CRGB::Red);
leds[dot] = CRGB::Black;
leds[dot] = CRGB::Blue;
FastLED.show();
leds[dot] = CRGB::Red;
delay(30);
}
}
void setAll() {
FastLED.show();
}
What this does is sets all the LEDs to red, then goes through each one turning it off, then to blue and then back to red.
For some reason, it gets X number of LEDs along and then crashes. By crashes I mean the Arduino disconnects itself from the computer, but the Arduino stays on with the LED strip still powered up.
Any ideas? This is a genuine Uno.
Also. If I plug the LED into the 3.3v pin, the animations works just fine, but the LED flashes black and doesn't complete the Blue part.
I never used the NeoPixels, so I'm not really sure about this, but I'm pretty confident these will solve your problem.
First of all, your program. I don't think it is doing what you think it should do. Try with this loop, instead:
void loop()
{
fill_solid(leds, NUM_LEDS, CRGB::Red);
FastLED.show();
delay(100);
for(int dot = 0; dot < NUM_LEDS; dot++)
{
leds[dot] = CRGB::Black;
FastLED.show();
delay(100);
leds[dot] = CRGB::Blue;
FastLED.show();
delay(100);
leds[dot] = CRGB::Red;
FastLED.show();
delay(100);
}
}
and remove the SetAll function, since it is useless.
Try this code with NUM_LEDS set to 5, and it should work.
Now the main problem: are you really using 144 leds powered by the USB? I suggest you to read this link about powering the neopixels. Particularly the part stating that at full brightness each neopixel draws 60mA. Doing the math, 144 neopixels draw at most 8.64A, so you need a 5V 10A power supply to power them all! a USB with 5V 0.5A will just shut itself down when you try to turn them on, thus giving you strange behaviors.
So lower the number of leds you are using (7 at most), or use an external power supply. And by external I do not mean use the barrel jack on the arduino, but connect a 5V 10A (or more amps) to the neopixel strip, then the ground and data wire to the arduino (not the +5v) and power the arduino through the usb port: it should work.
UPDATE:
According to the chat with the author, the problem was indeed the power supply
The datasheet from adafruit https://cdn-shop.adafruit.com/datasheets/WS2812.pdf says that you need a power supply between 6v and 7v but USB cannot provide more than 5v, I am guessing the arduino crashes because it cannot find enough power.
Can you try using an external power supply?
I'm having a strange problem that I hope someone can help with. My sketch works perfectly when uploaded to my UNO, but when I unplug it and plug it back in, it doesn't work correctly. If I re-upload it, it works again until power is cycled.
Once uploaded, the LCD reads:
Ferm:73.4 73/75
Room:75.1 75/75
After cycling power:
Ferm:73.45 73/18
Room:74.83 75/18
So after cycling power, I now get 2 decimal places and the "high" temp is stuck at "18".
/*
The circuit:
* 5V to Arduino 5V pin
* GND to Arduino GND pin
* CLK to Analog #5
* DAT to Analog #4
*/
// include the library code:
#include "Wire.h"
#include "Adafruit_LiquidCrystal.h"
#include <OneWire.h>
#include <DallasTemperature.h>
//variables for temp readings
float fermTemp;
float fermTempL=100;
float fermTempH=5;
float roomTemp;
float roomTempL=100;
float roomTempH=5;
// set OneWire bus to digital PIN 4 on the Arduino
#define ONE_WIRE_BUS 4
// Setup OneWire instance
OneWire oneWire(ONE_WIRE_BUS);
// Pass oneWire reference to Dallas Temp
DallasTemperature sensors(&oneWire);
// Connect via i2c, default address #0 (A0-A2 not jumpered)
Adafruit_LiquidCrystal lcd(0);
void setup()
{
// set up the LCD's number of rows and columns:
lcd.begin(16, 2);
// turn on backlight
lcd.setBacklight(HIGH);
}
void loop() {
readtemp();
LCDPrint();
}
void readtemp()
{
// get data from sensors
sensors.requestTemperatures();
fermTemp = (sensors.getTempFByIndex(0));
roomTemp = (sensors.getTempFByIndex(1));
// check/set High and Low temp
if (fermTemp<fermTempL) {
fermTempL=fermTemp;
}
if (fermTemp>fermTempH) {
fermTempH=fermTemp;
}
if (roomTemp<roomTempL) {
roomTempL=roomTemp;
}
if (roomTemp>roomTempH) {
roomTempH=roomTemp;
}
}
void LCDPrint()
{
lcd.setCursor(0,0);
lcd.print("Ferm:");
lcd.print(fermTemp,1);
lcd.setCursor(11,0);
lcd.print(fermTempL,0);
lcd.print("/");
lcd.print(fermTempH,0);
lcd.setCursor(0,1);
lcd.print("Room:");
lcd.print(roomTemp,1);
lcd.setCursor(11,1);
lcd.print(roomTempL,0);
lcd.print("/");
lcd.print(roomTempH,0);
}
I counted your characters, 16 per line. If you have a 16X2 display, there might be characters printed beyond the screen. I suspect it was not really 18, but something larger, say 180 or 1800. That could have been a result of failed first attempt to read temperature. This reading is stuck with you as temp High. In your code, you should define a reasonable high temperature, such as 125. Don't update temp High if it is above the reasonable temperature.
To confirm it, print temp High to serial port and inspect the value.
I am trying to attach a servo on an Arduino (branded) Robot but not sure whhich pin to use for the bellow code.
Most people seem to recommend to use pin 9 and 10 to control the servo for arduino Unos.
However, I can't use Pin 9 because that is already used as the Slave Select pin for the LCD.
I have tried attaching it to pins TKD0-TKD3 by calling them pins 19-22 in myservo.attach(). The code runs but the servo doesn't rotate and only gets hot and/or twitches.
Could the problem be something other than incorrect pin connection?
Thanks,
-M
I have been referencing these for the Control board pin mapping:
http://arduino.cc/en/Main/Robot)
http://fabcirablog.weebly.com/blog/grappling-with-the-arduino-robot-control-board
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int pos = 0;
void setup()
{
myservo.attach(19); // attaches the servo on pin 9 to the servo object
}
void loop()
{
for(pos = 0; pos < 60; pos += 1)
{
myservo.write(pos);
delay(15);
}
for(pos = 60; pos>=1; pos-=1)
{
myservo.write(pos);
delay(15);
}
}
You have this robot, right?
Arduino Robot
And you are using a classic servo (3 pins, yellow red and black cable)? If so.... Watch out. According to the schematic, the pinout of the connector on the board (e.g. TKD0) is
+5V
AD1
GND
While usually servos have
DATA
+5V
GND
So.. you have to make a short cable to invert the pins.
If that's not the problem.. Are you sure that 19 is the right number for the pin? I can't find references, but i suggest you to call it TKD0 (which is probably a macro defining the right pin), as arduino designers suggest you.