OctoWS2811 Teensy 3.0 and Bluetooth

I have been working on using bluetooth to control scrolling text. I made a top hat that has scrolling text, but so far this has been pre loaded text triggered by a button.

Using the btinterface app for android (I have no connection with this app), I can now control the text being displayed on the hat via a terminal on the android phone.

You can get the free app at the google play store, and there is a good forum for discussing any issues and getting support.

https://play.google.com/store/apps/details?id=com.btinterface.trial.beta&hl=en_GB

But, I guess that you can use any bluetooth terminal app. I chose this one as it also has an extra screen that has a set of button and a slider that you can configure in the arduino sketch. This way I can have a set of presets that are triggered, as well as going into the terminal and sending text to be diplayed. I use the presets to show various patterns on the hat.

The app works by sending a specified set of characters when a particular button is pressed, or when a specified set of characters are typed into the terminal of the app. The characters are sent to the arduino (Teensy in this instance) via the bluetooth module as a serial message, and the arduino sketch looks for these given characters and determines if they are a command. For example, if button one is pressed, “B1″ is sent over serial and arduino code says that if B1 is received, go an do something.

The code below uses the Scrolling text code on the previous page. There need to be a couple of changes to initialise an array:
char charBuf[20];
and to start a Serial port. The line:
Serial1.begin(9600); needs to be added into the setup method.

and I have changed the name of the method from text test to textscroll to identify the change.

What we do here, is to use the hardware serial available in Teensy 3.0 to talk to the bluetooth module. We start the serial port in setup, and it then listens to the Tx Rx pins for serial 1 (which for this hardware serial are pins zero and one).

The bluetooth module is JY-MCU 07 bought one for less than £10.
JY-MCU07 bluetooth module
JY-MCU07 bluetooth module

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
void loop() {
   if (Serial.available()) Serial1.write(Serial.read());
  while(Serial1.available() > 0) { // While there is more to be read, keep reading.
    command += (char)Serial1.read();
    delay(10);  
  }
 
  if(command != "") Serial.println(command);
   if(command == "btinterface"){  
         // the first thing that happens upon connect is that BTInterface sends the string 'btinterface' to let the device know its connected.
        //  Serial1.println("screen1");  // sending  'screen1' will cause BTInterface to show screen1
          delay(100); // wait a second to give it a chance to get all the characters.
          Serial1.println("Sbshow sbs;hb Text controller;b1 button1;b3 A button;b2 Title;b4 Button;s1t Text controller;");
   delay(10);      
   }
 
    if (command.startsWith("qq")) {while(Serial1.available() < 1){
          command.replace("qq","");
            command.toCharArray(charBuf, command.length()+1);
              {textscroll(charBuf);}  }
            }
   command = "";
 
}  //-----END of Void LOOP----//

mortonkopf