Go Down

Topic: I'd like to add control of an additional light to my sketch... (Read 1 time) previous topic - next topic


The if statements and the switch cases work individually but not as one whole program

Every time you call the read() method, the data is pulled out of the buffer. So when you call this

Code: [Select]
switch (BTSerial.read())

uncondintionally, you're never going to build up the buffer enough for available() to be greater than 3.


Thanks for the tip, didnt realize that. I replaced Serial.read() with Serial.peek() and I have all 3 lights working now. XD Kinda. I can turn on the white led, but I cant turn it off. Some progress though. better than nothing. Any suggestions?


Well I added Serial.read(); after digitalWrite() High or Low and it seems to have fixed it. Yeah! Feels good when things actually work. Now I just have to fix this buggy RGB led. This line is the problem:
Code: [Select]
      if (byte(BTSerial.read() == 'A'));{

it works kinda but its extremely buggy. The purpose for the 'A' is to distinguish between RGB led #1 and RGB led #2. Im supposed to be able to hit the button on my app and whatever color is on RGB led #1 will then transfer to RGB led #2. But it needs cleaning up. This may be an all nighter


By any chance could it be this?
if (byte(BTSerial.read() == 'A'));{
My GitHub:

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131