Teensy 3.1 and blinkM

Status
Not open for further replies.
Hello all!
I am new to programming and coding, and have bought a few items to start me off with a project in mind.
I have a teensy 3.1 and some blinkM LED's
I thought I would start off by loading the teensy with the blinkM communicator script which would let me run the blinkM software and control it from my computer, but it does not compile. Any ideas on how to make this teensy compatible? Or is that possible?
I get these errors:

BlinkMCommunicator.ino: In function 'void loop()':
BlinkMCommunicator.ino:144:13: warning: unused variable 'rc' [-Wunused-variable]
In file included from BlinkMCommunicator.ino:36:0:
/var/folders/j6/r5315c9n5l7bvcl9j643n6lr0000gn/T/build1105936832829713415.tmp/BlinkM_funcs.h: At global scope:
/var/folders/j6/r5315c9n5l7bvcl9j643n6lr0000gn/T/build1105936832829713415.tmp/BlinkM_funcs.h:113:13: warning: 'void BlinkM_startPower()' defined but not used [-Wunused-function]
static void BlinkM_startPower()
^
/var/folders/j6/r5315c9n5l7bvcl9j643n6lr0000gn/T/build1105936832829713415.tmp/BlinkM_funcs.h:119:13: warning: 'void BlinkM_stopPower()' defined but not used [-Wunused-function]
static void BlinkM_stopPower()
^
/var/folders/j6/r5315c9n5l7bvcl9j643n6lr0000gn/T/build1105936832829713415.tmp/BlinkM_funcs.h:195:12: warning: 'int BlinkM_getVersion(byte)' defined but not used [-Wunused-function]
static int BlinkM_getVersion(byte addr)
^
/var/folders/j6/r5315c9n5l7bvcl9j643n6lr0000gn/T/build1105936832829713415.tmp/BlinkM_funcs.h:213:12: warning: 'int BlinkM_checkAddress(byte)' defined but not used [-Wunused-function]
static int BlinkM_checkAddress(byte addr)
^
/var/folders/j6/r5315c9n5l7bvcl9j643n6lr0000gn/T/build1105936832829713415.tmp/BlinkM_funcs.h:242:13: warning: 'void BlinkM_setTimeAdj(byte, byte)' defined but not used [-Wunused-function]
static void BlinkM_setTimeAdj(byte addr, byte timeadj)
^
/var/folders/j6/r5315c9n5l7bvcl9j643n6lr0000gn/T/build1105936832829713415.tmp/BlinkM_funcs.h:251:13: warning: 'void BlinkM_fadeToRGB(byte, byte, byte, byte)' defined but not used [-Wunused-function]
static void BlinkM_fadeToRGB(byte addr, byte red, byte grn, byte blu)
^
/var/folders/j6/r5315c9n5l7bvcl9j643n6lr0000gn/T/build1105936832829713415.tmp/BlinkM_funcs.h:262:13: warning: 'void BlinkM_fadeToHSB(byte, byte, byte, byte)' defined but not used [-Wunused-function]
static void BlinkM_fadeToHSB(byte addr, byte hue, byte saturation, byte brightness)
^
/var/folders/j6/r5315c9n5l7bvcl9j643n6lr0000gn/T/build1105936832829713415.tmp/BlinkM_funcs.h:284:13: warning: 'void BlinkM_fadeToRandomRGB(byte, byte, byte, byte)' defined but not used [-Wunused-function]
static void BlinkM_fadeToRandomRGB(byte addr, byte rrnd, byte grnd, byte brnd)
^
/var/folders/j6/r5315c9n5l7bvcl9j643n6lr0000gn/T/build1105936832829713415.tmp/BlinkM_funcs.h:294:13: warning: 'void BlinkM_fadeToRandomHSB(byte, byte, byte, byte)' defined but not used [-Wunused-function]
static void BlinkM_fadeToRandomHSB(byte addr, byte hrnd, byte srnd, byte brnd)
^
/var/folders/j6/r5315c9n5l7bvcl9j643n6lr0000gn/T/build1105936832829713415.tmp/BlinkM_funcs.h:305:13: warning: 'void BlinkM_getRGBColor(byte, byte*, byte*, byte*)' defined but not used [-Wunused-function]
static void BlinkM_getRGBColor(byte addr, byte* r, byte* g, byte* b)
^
/var/folders/j6/r5315c9n5l7bvcl9j643n6lr0000gn/T/build1105936832829713415.tmp/BlinkM_funcs.h:319:13: warning: 'void BlinkM_playScript(byte, byte, byte, byte)' defined but not used [-Wunused-function]
static void BlinkM_playScript(byte addr, byte script_id, byte reps, byte pos)
^
/var/folders/j6/r5315c9n5l7bvcl9j643n6lr0000gn/T/build1105936832829713415.tmp/BlinkM_funcs.h:337:13: warning: 'void BlinkM_off(uint8_t)' defined but not used [-Wunused-function]
static void BlinkM_off(uint8_t addr)
^
/var/folders/j6/r5315c9n5l7bvcl9j643n6lr0000gn/T/build1105936832829713415.tmp/BlinkM_funcs.h:358:13: warning: 'void BlinkM_readScriptLine(byte, byte, byte, blinkm_script_line*)' defined but not used [-Wunused-function]
static void BlinkM_readScriptLine(byte addr, byte script_id,
^
/var/folders/j6/r5315c9n5l7bvcl9j643n6lr0000gn/T/build1105936832829713415.tmp/BlinkM_funcs.h:438:12: warning: 'int BlinkM_getInputsO(byte)' defined but not used [-Wunused-function]
static int BlinkM_getInputsO(byte addr)
^
/var/folders/j6/r5315c9n5l7bvcl9j643n6lr0000gn/T/build1105936832829713415.tmp/BlinkM_funcs.h:454:12: warning: 'int BlinkM_getInputs(byte, byte*)' defined but not used [-Wunused-function]
static int BlinkM_getInputs(byte addr, byte inputs[])
^
/var/folders/j6/r5315c9n5l7bvcl9j643n6lr0000gn/T/build1105936832829713415.tmp/BlinkM_funcs.h:471:12: warning: 'int BlinkM_doFactoryReset()' defined but not used [-Wunused-function]
static int BlinkM_doFactoryReset()
^
/var/folders/j6/r5315c9n5l7bvcl9j643n6lr0000gn/T/build1105936832829713415.tmp/BlinkM_funcs.h:511:13: warning: 'void BlinkMmk2_setLED(byte, byte)' defined but not used [-Wunused-function]
static void BlinkMmk2_setLED(byte addr, byte ledn)
^
/var/folders/j6/r5315c9n5l7bvcl9j643n6lr0000gn/T/build1105936832829713415.tmp/BlinkM_funcs.h:519:13: warning: 'void BlinkMmk2_rotateLEDs(byte, byte)' defined but not used [-Wunused-function]
static void BlinkMmk2_rotateLEDs(byte addr, byte rot)
^
/var/folders/j6/r5315c9n5l7bvcl9j643n6lr0000gn/T/build1105936832829713415.tmp/BlinkMCommunicator.cpp.o: In function `BlinkM_findFirstI2CDevice':
/var/folders/j6/r5315c9n5l7bvcl9j643n6lr0000gn/T/build1105936832829713415.tmp/BlinkM_funcs.h:83: undefined reference to `twi_writeTo'
/var/folders/j6/r5315c9n5l7bvcl9j643n6lr0000gn/T/build1105936832829713415.tmp/BlinkMCommunicator.cpp.o: In function `BlinkM_scanI2CBus':
/var/folders/j6/r5315c9n5l7bvcl9j643n6lr0000gn/T/build1105936832829713415.tmp/BlinkM_funcs.h:71: undefined reference to `twi_writeTo'
collect2: error: ld returned 1 exit status
Error compiling.

Link to the code: It's called the blinkMCommunicator
http://thingm.com/products/blinkm/blinkm-quick-start-guide/

I use a teensy 3.1 on my pixhawk quadcopter to convert Mavlink messages to frsky using this code:
https://github.com/lvale/MavLink_FrSkySPort

This is based on:
http://diydrones.com/forum/topics/amp-to-frsky-x8r-sport-converter

I am probably biting off more than I can chew but my goal is to be able to add to their code and use the blinkM as navigation/status lights and respond to the mode changes of the copter - change colour/flash etc.

Cheers,

Sandy
 
I suggest you start, as a noob, with the LED blinky demo for the Teensy. Just set the LED pin number to the pin on the Teensy 3.1 for the LED.
Then graduate to more complete Teensy-specific demos.
With that background you can tackle this thingm - which is Arduino specific and likely needs a change or two for the Teensy 3.1.
 
There's bad news and good news ;-)

The Bad news:
The BlinkMComunicator.ino calls functions from the BlinkM_funcs.h that call functions from /utilities/twi.h
These functions are only used for AVR micro controllers. If you had a Teensy 2 you'd be fine, but the Teensy 3.x are ARM micro controllers.
I have a Teensy 2 as well can it compiled fine.

The good News:
The BlinkM spec sheet provides good details with Arduino code snippets how to talk directly to the BlinkM without the use of the BlinkM_funcs.h. Even if you want to use BlinkM_funcs.h you then out comment the offending I2C scan functions as those are not needed.

I agree with stevech that before attempting to play with an I2C device to complete a few Arduino tutorials first.
 
Last edited:
Thanks for the advice guys,

I took the issue to blinkM and they came back with a fix!

There were some issues with the BlinkMCommunicator Arduino sketch that prevented it from working on the fancier Arduino variants like the Teensy. I just fixed that so if you go to this page:
https://github.com/todbot/BlinkM-Examples
and click on “Download zip” in the lower right, you’ll get an updated set of examples. In that zip is a folder called “arduino” which contains the updated "BlinkMCommunciator" sketch. You should be able to upload that one to the Teensy.

For physically wiring up a BlinkM to a Teensy 3.1, you will need pull-up resistors on the “d" and “c" pins (aka SDA and SCL). If you’ve never heard of this term, it’s something you often need to do for I2C connections. It means adding two 4.7k resistors on the I2C pins. One resistor goes across the BlinkM’s “d” and “+” pins, the other goes across The BlinkM’s “c” and “+” pins. These resistors “pull up” the voltage on the “d” & “c” lines since the Teensy doesn’t do it for you. A diagram showing this is in Figure 5.1 of the BlinkM datasheet:
http://thingm.com/fileadmin/thingm/downloads/BlinkM_datasheet.pdf


This is fantastic news! I do have some electrical awareness so I understand how to do the pull up with resistors and have just read a tutorial online as to why this is important; to give the signal pin a base reference, in this case a High state.

Cheers,

Sandy
 
Hmmm, it seems that there is still something not quite right with the code, as the light on the teensy has stopped flashing - which I assume means the upload has removed the flashing light teensy sketch and loaded the communicator sketch, but I cannot see the teensy as a "port" in the BlinkM Sequencer program...
Also the errors kept rolling during the upload so... more questions for the man at BlinkM!
 
If you want to get your Teensy back to the original way it was (for testing, to make sure things are ok), in Arduino use File > Examples > 01.Basics > Blink to open the blink code. Then just upload to your Teensy. The LED should blink again.

You definitely do need those two pullup resistors on the SDA and SCL pins to make the communication work. You might find info on other websites saying they're optional. On many Arduino boards they are optional (but the built-in resistors are very weak). That advice doesn't apply to Teensy. On Teensy 3.1, real resistors are required.
 
I got it working - I loaded the communicator sketch onto an arduino UNO, then I could see a port in the sequencer to connect through, I then plugged the teensy in, and I could use the same port in the sequencer to talk to the blinkM's. Win!
Now to do some of the code examples in the blinkM data sheet and try to adapt for teensy! :)
 
Status
Not open for further replies.
Back
Top