BlinkM + Kinoma Create Code Examples?

I had one of these little BlinkM LEDs lying around so I plugged it into the front pins and powered it up. I see that the Kinoma kernel has a driver for it:

https://github.com/Kinoma/acorn_kernel/blob/3c01bb0b9dd28e3c86c9b90843eae5c105ec50a0/drivers/leds/leds-blinkm.c

Do you have any code examples showing how you'd access something like this?

Answers

  • Yea, i'm pretty much lost. This was a lot easier with Arduino and Raspberry Pi. ;-(

  • Greetings!

    I'm quite familiar with BlinkM, but not with exactly what product you have. Can you send me a link to the model you want to get up and running?

    Basically, you'll want to follow the instructions in the Pins Module tutorial to get your sensor going. If it's just a digital LED, that's very easy. If it has an i2c interface, there's a tiny bit more to.

    — Andy

  • Thanks Andy. It's the standard ThingM BlinkM, spec sheet here: http://thingm.com/fileadmin/thingm/downloads/BlinkM_datasheet.pdf

    It's an I2C device. I figured this would be something simple I could use to learn with, since there are only a couple of pins and you can plug it right into the front of the Kinoma. I can get it to light up and do the default demo sequence, so it's getting power. I used the front pin app to set up ground, power, i2c data and clock.

  • Great, you're off to the right start then. Now to do the more complicated interactions with it, you'll just need to send the appropriate i2c commands.

    As a next step, I might suggest visiting our list of Sample Code and looking at the many i2c samples we have available. If you have questions while looking at them, you'll likely find your answers in the Programming with Hardware Pins documentation or the aforementioned Pins Module tutorial.

    And, of course, keep letting us know how we can help here. I don't have a BlinkM here (that I can find, at least), but I'm sure we could help you work through the details.

    Cheers!

    — Andy

  • Thanks, appreciate the help. Maybe I'll buy a temperature sensor to get started with since there's a tutorial for that.

    One last question - is it best to use the standard I2C commands (via Pins module) or would it be better to somehow access this kernel driver? It looks like it has all the standard BlinkM commands built in:

    https://github.com/Kinoma/acorn_kernel/blob/3c01bb0b9dd28e3c86c9b90843eae5c105ec50a0/drivers/leds/leds-blinkm.c

  • Answer ✓

    The kernel driver strikes me as overkill. What you need to do is easy enough to just do in script, and would be good practice at implementing hardware interfaces in JavaScript. Notably, we almost certainly don't build that driver into our kernel, so you'd have to do a custom kernel build to use it.

    — Andy

  • Great, this is helpful. I'll get cracking on the tutorials and post questions when I have them.

  • Ok, I'm taking another stab at this today. I tried to make a BLL, and to write a simple block of bytes to the blinkm. I have two files, blinkm.js and main.js. When I attempt to run it I get an error message.

    Code and error message are here in this gist:

    https://gist.github.com/scarolan/e8986f12466401f72f7aca793d6e6cce

    Can anyone tell me what I'm doing wrong?

  • Here is a second attempt, trying to model my code after the tutorial. With this code it can't seem to find the BLL.

    https://gist.github.com/scarolan/a8c291e1e61cd8c21a6b0f7550b7144c

  • I modified the i2c-example code posted here: http://forum.kinoma.com/discussion/641/i2c-examples#latest

    and managed to get a bit further. I am able to provide power and configure the front pins, but as soon as I try to use i2c.writeByte (or any of the other functions I tried) I get "Failed with error kFskErrUnknown"

    https://gist.github.com/scarolan/b16f82496e20815a1ab9170cd56903a2

    I know the BlinkM is working because I just plugged it into an Arduino and tested it. I'm able to change colors and run scripts just fine. Help?

  • Ah, i finally got this working with my Kinoma Element. I think there's something wrong with the way the Create interacts with the I2C bus, because my code worked fine right out of the box with the Element.

    How can I help track down the issue with the Create?

  • Glad to hear you got it working on Kinoma Element!

    Regarding the Kinoma Create issue--if you got it working with the Front Pins app, the interaction with the I2C bus should be fine since that app is written in KinomaJS with the same API calls detailed in the documentation.

    The error you're getting suggests that the sensor isn't responding when being written to. This may be obvious, but double check that your sensor is plugged into the pins that match the numbers in your main.js. You may also want to try plugging it into the back and see if you get the same result. The I2C bus on the front is a soft I2C bus, whereas the one on the back is a real CPU I2C bus so it may behave differently.

    Let us know if using the back pins fixes the problem. We're going to try to order a few of the same sensor to see if we can recreate the issue as well.

  • Thanks, Lizzie. Maybe I'll give the BlinkM another go once you've had a chance to certify it on the Kinoma. I have a feeling something is going wrong with those front side pins because I'm at least able to send one command to the device from my Element.

  • One last post - I did confirm that the back pins on the Create seem to work. Is this expected? Are the front pins appropriate for other kinds of prototyping? Wondering if you've seen similar erratic behavior with digital, serial, PWM, etc.

    If you do end up getting a BlinkM working let me know. The only I2C command I could get it to respond to was "Go to this RGB color now", or 0x6e. Other commands like 0x70 (run script) do not work. I suspect Kinoma's I2C implementation may not be functioning correctly, because I can send I2C commands at the device via an Arduino and it responds as expected.

Sign In or Register to comment.