Hello all,
I've been wrestling with a problem for a few weeks now and have come to a point where I don't know what to try next.
Long story short, I'm trying to smoothly control an WS2812 RGB LED through an ATTiny85 with an HC-06 bluetooth module using the Bluetooth Color Picker Android app.
The data output from the app is in the format "#:R,G,B"
Example:
0:200,0,0
0:199,0,0
0:198,0,0
etc
When inputting these commands manually in a terminal, they work fine, but the bluetooth color picker app sends the commands much faster and they don't register...maybe?
The problem I'm having is that I can't reliably detect the end of line character on the ATTiny85 using Software Serial, but the same code (using hardware serial instead) works perfectly fine on my Arduino MEGA.
#include <Adafruit_NeoPixel.h>
#define PIN 2
#define NUMPIXELS 2
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(4,3); // (RX,TX) Sets physical pin 2 as TX and physical pin 4 as RX
void setup() {
Serial.begin(9600);
Serial.println("Software Serial On");
pixels.begin(); //Initializes NeoPixel library
}
void loop() {
//if some data is sent
while(Serial.available() > 0){
//Parse serial data into integers, separated by non-digit characters
int pixel = Serial.parseInt();
int red = Serial.parseInt();
int green = Serial.parseInt();
int blue = Serial.parseInt();
//WORKS on MEGA but not ATTiny85. Software Serial vs Serial?
if (Serial.read() == '\n'){ //if end of line seen (doesn't work all the time)
pixels.setPixelColor(pixel, pixels.Color(red,green,blue)); // Should change color with app control
pixels.show(); // This sends the updated pixel color to the hardware.
}
}
}
This code works perfectly on my MEGA, but changing everything to SoftwareSerial and trying it on my ATTiny85 does not work.
Any advice here would be GREATLY appreciated as I really have no idea what to try next.
Edit: I'm running the ATTiny85 at 8MHz, which I believe is necessary for SoftwareSerial.
Thank you,
Mike