hi guys
i have connected 2 bluetooth devices hc-05 to transmit data, while only reading the pot value it works clean, at the moment i put the code to do something with the neopixel stick the data i get is all over the place the current code is this ones
#include <SoftwareSerial.h>
#define BT_SERIAL_TX 4
#define BT_SERIAL_RX 3
SoftwareSerial BluetoothSerial(BT_SERIAL_TX, BT_SERIAL_RX);
int potpin = A0;
int val;
void setup()
{
Serial.begin(9600);
BluetoothSerial.begin(9600);
}
void loop()
{
val = analogRead(potpin);
val = map(val, 0, 1023, 10, 179);
Serial.println(val);
BluetoothSerial.write(val);
//BluetoothSerial.write(val);
//delay(100);
}
and the receiver code
///NANO WITH THE MASTER BLUETOOTH, READS THE SIGNAL OF THE SALVE ON THE UNO( POT DATA)
//////NEOPIXEL SETUP
#include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel stick1 = Adafruit_NeoPixel(8, 10, NEO_GRB + NEO_KHZ800); //12 neopixels on pin 10 (PIN , NUMBER OF LED, NEO_GRB + NEO_KHZ800)
#include <SoftwareSerial.h>
#define BT_SERIAL_TX 4
#define BT_SERIAL_RX 3
SoftwareSerial BluetoothSerial(BT_SERIAL_TX, BT_SERIAL_RX);
int val;
void setup()
{
///START THE PIXEL STICK
stick1.begin();
///
Serial.begin(9600);
BluetoothSerial.begin(9600);
}
void loop()
{
if (BluetoothSerial.available()>0)
{
val = BluetoothSerial.read();
Serial.println(val);
if (val <=20)
val = BluetoothSerial.read(),
Serial.println(val),
stick1.setPixelColor(0, stick1.Color(0,0,0)),
stick1.setPixelColor(1, stick1.Color(0,0,0)),
stick1.setPixelColor(2, stick1.Color(0,0,0)),
stick1.setPixelColor(3, stick1.Color(0,0,0)),
stick1.setPixelColor(4, stick1.Color(0,0,0)),
stick1.setPixelColor(5, stick1.Color(0,0,0)),
stick1.setPixelColor(6, stick1.Color(0,0,0)),
stick1.setPixelColor(7, stick1.Color(0,0,0)),
stick1.setPixelColor(8, stick1.Color(0,0,0)),
stick1.setPixelColor(9, stick1.Color(0,0,0)),
stick1.setPixelColor(10, stick1.Color(0,0,0)),
stick1.setPixelColor(11, stick1.Color(0,0,0)),
stick1.setPixelColor(12, stick1.Color(0,0,0)),
stick1.setPixelColor(13, stick1.Color(0,0,0)),
stick1.setPixelColor(14, stick1.Color(0,0,0)),
stick1.setPixelColor(15, stick1.Color(0,0,0)),
stick1.show();
if (val>=80)// and mapped < 2)
val = BluetoothSerial.read(),
Serial.println(val),
stick1.setPixelColor(0, stick1.Color(0,0,255)), //blue
stick1.setPixelColor(1, stick1.Color(0,0,0)),
stick1.setPixelColor(2, stick1.Color(0,0,0)),
stick1.setPixelColor(3, stick1.Color(0,0,0)),
stick1.setPixelColor(4, stick1.Color(0,0,0)),
stick1.setPixelColor(5, stick1.Color(0,0,0)),
stick1.setPixelColor(6, stick1.Color(0,0,0)),
stick1.setPixelColor(7, stick1.Color(0,0,0)),
stick1.setPixelColor(8, stick1.Color(0,0,0)),
stick1.setPixelColor(9, stick1.Color(0,0,0)),
stick1.setPixelColor(10, stick1.Color(0,0,0)),
stick1.setPixelColor(11, stick1.Color(0,0,0)),
stick1.setPixelColor(12, stick1.Color(0,0,0)),
stick1.setPixelColor(13, stick1.Color(0,0,0)),
stick1.setPixelColor(14, stick1.Color(0,0,0)),
stick1.setPixelColor(15, stick1.Color(0,0,255)),
stick1.show();
}
}
without the neopixel the data is fine
once i put in the neopixel config in the loop the data i get is totally over the place
how can i fix this? thanks