Blinker使用求助
求助Blinker使用,我按照官网的相关指南配置,写好代码后,蓝牙显示已连接,但是按下按键后无反应,RGB色盘转动也无反应,求助手机是IOS,附上配置图及代码,蓝牙模块是就直接插上就用了,没有配置过。
蓝牙模块是JDT-18,板子是Arduino Uno.接线没有问题,代码部分除了Blinker相关的也实验过没有问题。
#define BLINKER_PRINT Serial
#define BLINKER_BLE
#include <Blinker.h>
#include <FastLED.h>
#define RGB_1 "RGBKey"
BlinkerRGB RGB1(RGB_1);
#define BUTTON_1 "ButtonKey"
BlinkerButton Button1(BUTTON_1);
//The amount of LEDs in the setup
#define NUM_LEDS 64
//The pin that controls the LEDs
#define LED_PIN 6
//The pin that we read volume sensor values from
#define ANALOG_READ 0
//Led array
CRGB leds;
// LED Mode1/Music LED--LED Mode2/Color LED
int LED_MODE = 1;
// LED TYPE
#define LED_TYPE WS2812
// RGB TYPE
#define COLOR_ORDER GRB
// when you use the MusicLED as a Color LED
CRGB LEDColor(0,0,0);
uint8_t Bright = 255;
//LED LINE
int LEDLINE{
{0,1,2,3,4,5,6,7},
{15,14,13,12,11,10,9,8},
{16,17,18,19,20,21,22,23},
{31,30,29,28,27,26,25,24},
{32,33,34,35,36,37,38,39},
{47,46,45,44,43,42,41,40},
{48,49,50,51,52,53,54,55},
{63,62,61,60,59,58,57,56}
};
// A counter when using LEDLINE
int counter=0;
//color plate
int ledc{
{0,0,255},{17,0,238},{34,0,221},{51,0,204},{68,0,187},
{85,0,170},{102,0,153},{119,0,136},{136,0,119},{153,0,102},
{170,0,85},{187,0,68},{204,0,51},{221,0,34},{238,0,17},
{255,0,0},{238,17,0},{221,34,0},{204,0,51},{187,0,68},
{170,85,0},{153,102,0},{136,119,0},{119,136,0},{102,153,0},
{85,170,0},{68,187,0},{51,204,0},{34,221,0},{17,238,0},
{0,255,0},{0,238,17},{0,221,34},{0,204,51},{0,187,68},
{0,170,85},{0,153,102},{0,136,119},{0,119,136},{0,102,153},
{0,85,170},{0,68,187},{0,51,204},{0,34,221},{0,17,238}
};
//color plate counter
int plate=0;
void LOWMODE();
void MIDMODE();
void HIGHMODE();
void visualize_music( int VOLUME );
// rgb1_callback
void rgb1_callback(uint8_t r_value, uint8_t g_value, uint8_t b_value, uint8_t bright_value)
{
// change the color of strip by your set on Blinker
LEDColor.r = r_value;
LEDColor.g = g_value;
LEDColor.b = b_value;
Bright = bright_value;
fill_solid(leds,NUM_LEDS,LEDColor);
FastLED.show();
}
void button1_callback(const String & state) {
if(LED_MODE == 1)
{
LEDColor.r = 255;
LEDColor.g = 255;
LEDColor.b = 255;
Bright = 0;
fill_solid(leds,NUM_LEDS,LEDColor);
BLINKER_LOG("MUSIC LED: ","OFF");
LED_MODE = 2;
}
else if(LED_MODE == 2)
{
LED_MODE = 1;
}
FastLED.show();
}
void setup() {
//Set all lights to make sure all are working as expected
Blinker.begin();
Serial.begin(9600);
LEDS.addLeds<LED_TYPE,LED_PIN,GRB>(leds,NUM_LEDS);
int i;
for( i=0;i<64;i++){
leds=CRGB(0,127,128);
}
FastLED.setBrightness(100);
FastLED.show();
delay(1000);
//Initial values
//Blinker.begin();
//attach the RGB1 SlidersRGB
RGB1.attach(rgb1_callback);
Button1.attach(button1_callback);
}
void loop() {
Blinker.run();
if(LED_MODE == 1){
visualize_music(analogRead(0));
}
delay(1); // delay in between reads for stability
}
void LOWMODE(){
FastLED.clear();
for(int m=0;m<1;m++){
for(int j=0;j<8;j++){
leds] = CRGB (ledc,ledc,ledc);
}
}
leds[(1+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(1+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(1+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(2+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(2+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(3+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(4+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(4+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(4+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(6+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(6+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(7+counter)%8]] = CRGB (ledc,ledc,ledc);
FastLED.show();
delay(150);
counter++;
if(counter>=8){
counter-=8;
}
plate++;
if(plate>=45){
plate-=45;
}
}
void MIDMODE(){
FastLED.clear();
for(int m=0;m<3;m++){
for(int j=0;j<8;j++){
leds] = CRGB (ledc,ledc,ledc);
}
}
leds[(1+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(1+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(1+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(2+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(2+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(3+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(4+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(4+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(4+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(6+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(6+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(7+counter)%8]] = CRGB (ledc,ledc,ledc);
FastLED.show();
delay(150);
counter++;
if(counter>=8){
counter-=8;
}
plate++;
if(plate>=45){
plate-=45;
}
}
void HIGHMODE(){
FastLED.clear();
for(int m=0;m<5;m++){
for(int j=0;j<8;j++){
leds] = CRGB (ledc,ledc,ledc);
}
}
leds[(1+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(1+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(1+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(2+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(2+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(3+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(4+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(4+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(4+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(6+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(6+counter)%8]] = CRGB (ledc,ledc,ledc);
leds[(7+counter)%8]] = CRGB (ledc,ledc,ledc);
FastLED.show();
delay(150);
counter++;
if(counter>=8){
counter-=8;
}
plate++;
if(plate>=45){
plate-=45;
}
}
void visualize_music(int VOLUME){
if(VOLUME<=80){
LOWMODE();
}
else if(VOLUME>80&&VOLUME<=230){
MIDMODE();
}
else if(VOLUME>230){
HIGHMODE();
}
}
更正一下,蓝牙模块是JDY-18 串口调试,看是否正常收到数据:1.如果正常接收数据,但不是你预计的效果,说明你程序有问题;
2.如果没有收到,那测试例程,看是否正常,如果正常,则说明是你程序问题。
3.如果使用例程,仍然无法正常收发数据,那检查硬件连接
coloz 发表于 2019-8-19 23:18
串口调试,看是否正常收到数据:1.如果正常接收数据,但不是你预计的效果,说明你程序有问题;
2.如果没有 ...
使用例程的时候,串口监视器还是没有反应,请问硬件的连接有什么问题吗?
我使用了拓展板,蓝牙模块用的3.3V输入,TXD连2,RXD连3,没有反应,手机能连接上,但是好像收发不了数据是什么原因呢?
EdwinYu 发表于 2019-8-20 11:12
使用例程的时候,串口监视器还是没有反应,请问硬件的连接有什么问题吗?
我使用了拓展板,蓝牙模块用的3 ...
确定连线是否正确,包括VCC、GND是否正确,确定是3.3V供电还是5V供电,确定程序中引脚和波特率是否正确,打开串口监视器,看是否正常收发数据。
页:
[1]