Pages: 1 [2]   Go Down
Author Topic: I'd like to add control of an additional light to my sketch...  (Read 1267 times)
0 Members and 1 Guest are viewing this topic.
California
Offline Offline
Faraday Member
**
Karma: 88
Posts: 3382
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
switch (BTSerial.read())

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

Offline Offline
Jr. Member
**
Karma: 0
Posts: 54
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Jr. Member
**
Karma: 0
Posts: 54
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
      if (byte(BTSerial.read() == 'A'));{
       
      redvalue2=BTSerial.read();
      greenvalue2=BTSerial.read();
      bluevalue2=BTSerial.read();
    }

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
Logged

Queens, New York
Offline Offline
Faraday Member
**
Karma: 99
Posts: 3632
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

Pages: 1 [2]   Go Up
Jump to: