Hello,
first of all,
I’m new to blynk and arduino. I am constantly figuring new things out but not at the highest speed.
I want to make a system where I could toggle different presets in blynk using different buttons, change the brightness and use the zeRGBa to change colors. To begin, I tried to start with the basics, but that isn’t helping too much. I used the example generator and the example for neopixels (changing the hue with a slider) but when I move the slider, nothing happens. Blynk says the device is online, but whenever I do anything, the neopixels just stay off. Any help would really be appreciated, thanks!
I haven’t used zegrba but I’m positive that those who have will ask to see the code you have to start troubleshooting.
there’s no zeRGBra yet, I’m just using the neopixel example:
#include <SoftwareSerial.h>
SoftwareSerial SwSerial(0, 1); // RX, TX
#include <BlynkSimpleSerialBLE.h>
#include <SoftwareSerial.h>
#include <Adafruit_NeoPixel.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "hidden from prying eyes";
SoftwareSerial SerialBLE(0, 1); // RX, TX
#define PIN 6
Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);
// 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);
}
}
BLYNK_WRITE(V1)
{
int shift = param.asInt();
for (int i = 0; i < strip.numPixels(); i++)
{
strip.setPixelColor(i, Wheel(shift & 255));
// OR: strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + shift) & 255));
}
strip.show();
}
void setup()
{
// Debug console
Serial.begin(9600);
SerialBLE.begin(9600);
Blynk.begin(SerialBLE, auth);
Serial.println("Waiting for connections...");
strip.begin();
strip.show();
}
void loop()
{
Blynk.run();
}```
You’ve set your software serial UART to use the same pins as the hardware serial UART.
Pete.
Thank you, how should I set it if my HC-05 is connected to 0 and 1?
The arduino Uno has one serial port (UART). This is connected to both the USB programming port and pins 0/1. This is referenced as ‘Serial’ and because the board has the built-in serial to USB interace on this serial port it’s generally used for debugging.
To do this you infl;ude lines like:
// Debug console
Serial.begin(9600);
Serial.println("Waiting for connections...");
When you’re using the in-built serial port in this way, you can’t use it for anything else.
As you also want another serial port, a second one is created using the SoftwareSerial library. This uses two different GPIO pins to act as a second serial port. It has some limitations, such as not being able to support high data flow rates (because it’s using the processor to simulate a serial port rather than having the dedicated hardware of a regular serial port), but it’s good for speeds of 9600 baud.
So, you need to choose two different pins and use these for your software serial port, and connect your HC05 to them.
Okay you’re thinking, what if I leave the HC05 connected to pins 0/1 and use the SoftwareSerial library to create a port that I use for debugging? Well. that’s possible, but to be able to connect these software serial pins to your PC you’d need a serial to USB adaptor, to allow the debug pins to plug into your USB port on the PC. These are available, and known as FTDI adaptors, but in reality it’s simpler to use the Uno’s built-in serial to USB circuitry and connect your servo to different hardware pins.
Pete.
Thank you, I’ll try that when I get home