Asked — Edited

Revisiting Blinkm

I had posted about a year ago, about trying to script the blinkM to bend to my will. I have need to get ahold of this little guy but running into the exact same trouble as before. The BlinkM come preloaded with about 18 scripts. The default script plays as soon as it receives power. Now if I start the blinkm controller located in the i2c folder the interface comes up. The only way to control the blinkM is to hit the stop script., which it does and glows whatever color it was on at the time of hitting that button. With the sliders i can control the color of the LED. Now I open up a script and use the i2cwrite, to tell it to goto a color, i.e I2CWrite(0, 0x09, 178,102,255). I can see the script being sent on the blue led on the ezb3, so I know its sending, but the blink, just remains the same color as when I pressed the stop script button on the blinkm control board. Now why not just use the control panel? Because I want to be able to changes the colors over time by calling scripts etc.

Any help to sort this out would be appreciated. If need be I can upload a video of the set up and my issue.

BTW the manual still has the Sendi2c as the command, instead of "write" and needs to be updated.


ARC Pro

Upgrade to ARC Pro

Subscribe to ARC Pro, and your robot will become a canvas for your imagination, limited only by your creativity.

United Kingdom
#2  

I haven't tried these in any recent update but this is the code I have been using which worked...


# BlinkM Examples
# Use I2CWrite
# Default address 0x09

# Change the address to 0x0a
I2CWrite(0,0x09,A,0x0a)
# Address now 0x0a

# Change the address back to 0x09
I2CWrite(0,0x0a,A,0x09)
# Address now 0x09

# White light
I2CWrite(0,0x09,n,0xff,0xff,0xff)

# Red light
I2CWrite(0,0x09,n,0xff,0x00,0x00)

# Green light
I2CWrite(0,0x09,n,0x00,0xff,0x00)

# Blue light
I2CWrite(0,0x09,n,0x00,0x00,0xff)

# Fade to yellow light
I2CWrite(0,0x09,c,0xff,0xff,0x00)

# Fade to black (off)
I2CWrite(0,0x09,c,0x00,0x00,0x00)

#End

Pushed for time right now but hope that's of some use to you. I'll revisit this when I get chance if you need more help.

Note: The above is old syntax, put the A, n, c etc. in quotes to meet new syntax. i.e. I2CWrite(0,0x09,"n",0x00,0x00,0xff) or I2CWrite(0,0x09,"c",0x00,0x00,0xff)

Looking a bit closer, it is likely to be your I2CWrite commands which are the issue. If you want me to check it out feel free to post it (or email it if you want to keep it private)

PRO
USA
#3  

Thanks Rich. I will give it a spin tonight and see what i can get to work.

PRO
USA
#4  

Rich, your awesome. Because I want to learn, not just copy and paste, I'd like to ask you a few questions on your code. What did changing the address do? What do "A,c,n" do in the code? Everything else I got. Also do you have a good source for RGB to hex conversion? I'd like to find the perfect color and then use the blinkm console to derive the color RGB , ie 255,0,121 as an example, then convert that in the code to hex.

United Kingdom
#5  

Changing the address is so you can use more than one BlinkM and control each individually. If you used two without changing the address then all commands would control both BlinkMs (which may be ideal for some applications but some may require different patterns or colours for each).

The BlinkM Datasheet is really well laid out and should explain everything a bit better than I can (see page 17) but the basics are;

n = Go to RGB colour now c = fade to RGB colour h = fade to HSB colour C = fade to random RGB colour H = fade to random HSB colour p = play light script o = stop script f = set fade speed t = set time adjust g = get RGB current colour W = write script line R = read script line L = set script length and repeats A = set address a = get address Z = get firmware version B = set startup parameters Note: These are Case Sensitive

So, for instance, to fade to red, to green then to blue the code would be something like this,


# fade to red
I2CWrite(0,0x09,"c",0xff,0x00,0x00)

Sleep(100)

# fade to green
I2CWrite(0,0x09,"c",0x00,0xff,0x00)

Sleep(100)

# fade to blue
I2CWrite(0,0x09,"c",0x00,0x00,0xff)

Or to flash red/blue like police lights the code would be something like;


:loop

# change to red now
I2CWrite(0,0x09,"n",0xff,0x00,0x00)

Sleep(500)

# change to blue now
I2CWrite(0,0x09,"n",0x00,0x00,0xff)

Sleep(500)

Goto(loop)

The main commands are c (fade to) and n (go to now) followed by the hex for the shade of red, hex for the shade of green then hex for the shade of blue.

Since scripting in ARC is pretty simple I've not needed to use the built in script functions of the BlinkM, I just have a bunch of scripts which run the I2CWrite commands for the patterns.

As for dec to hex conversion, windows calculator can do that. I do it mentally (I have been using hex for nearly 20 years now) but set Windows calculator to programmer mode (Alt & 2 or view programmer), make sure it's on dec, type in the number i.e. 138, hit the hex radio button and it will give you the hex code (8A in this case).

Or google dec to hex and I expect millions of online calculators will pop up.

PRO
USA
#6  

Brilliant and thanks so much for pointing me in the right direction!

#7  

That worked for mine. I like the police lights. That will be good for a patrol mode. Can you give me a script to make the lights turn blue solid and have a random blink like eyelids blinking? I'm only good as the code I can steal/borrow. I got a startup script that points the head and radar forward and right now makes the eyes flash like the police. I just want them to randomly blink like eyelids to give a more human-like appearance.

Thanks,

CMC

#8  

I got this working by messing around with the timing and figuring out how to turn them off. I have a few more things to try and get it more life like and random. Then I will post my code.

CMC