Let's Make Robots!

Picaxes Latches, Clocked Serial and I need an Enabler

I am working with a ShiftBrite RGB led and I have it working nicely with an Arduino. The curse of course, is the fact that Arduinos have libraries and a lot of the "work" has been done for you. Now I want to get this guy working with a Picaxe and I am looking for a crash course on clocked serial, latching, enableing (sic) etc.

Learn me in my head with stuff you know good.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

It looks like SPI communications in there.  Picaxe's shiftout (spiout) commands (or hardware equivalents) should do the job if I'm correct. Those ShiftBrites seems to work like shift registers (hence the name?). Just keep on writing bits to Data In until SB "gets full". Most significant bit goes first (31, then 30, 29 so on). Then hit the latch pin up for a while and those bits are "applied" as new led values. If you have multiple SB's in series like in this then write the bits of the last SB (furthest away from Picaxe) first, then second to last and so on. The first SB in line gets its value last. After writing all those value hit the latch pin.

That enable is just like enable in L293D except it has "reverse" logic. Set it low and leds are lit. Set it high and leds are off.

This is how I understood those ShitfBrites but I could also be totally wrong :-)


Yup, the mighty picaxe does this, I guess.

Through full trial-and-error, I have figured out the system. --I am still looking for a lesson on bits... I had to sit for a while with the windows calculator switching from dec to bin and back to figure out what bits, made of which bytes, in which order, did what.

Guess what? The ShiftBrite LED advertises 1024 "levels of brightness" for each LED color --that would be 1023 choices, and your friend, the 0. I figure this is a big deal because when you go from 1023 to 1024, a whole entire bit gets added. On the shift brite, 11 bits fucks everything and 10 bits works.

The bottom line is that I got it to work, but alas, I wish I knew WHY it is working! --I also got this working with an Arduino, but again, I don't know why as all the "make it go" was hidden in the library (which I never got around to opening and studying)

There has got to be some sorta youtube video or something out there that can teach me this. --How bits shift to the left and right, when they "drop off", what is significant and not (and why) etc. etc. Why can't I find this kinda tutorial or video?


Better yet: The Picaxe Simulator - fully interactive!

Try this code for fun.

# demonstrating the bit shift operators in X2 picaxes
# for use in simulator
# http://letsmakerobots.com/node/22525
# by rik
symbol p = 300

b0 = 1
for b9 = 0 to 9
   b0 = b0 << 1
   pause p
next b9
for b9 = 0 to 9
   b0 = b0 >> 1
   pause p
next b9

pause p
w1 = 5
for b9 = 0 to 14
   w1 = w1 << 1
   pause p
next b9
for b9 = 0 to 14
   w1 = w1 >> 1
   pause p
next b9

I got a bit carried away with this. Inspired by rik's Picaxe bit shifting demo I decided to write little bit shifting applet. You can try it here (if it works): http://personal.inet.fi/private/nuumio/bitapplet/BitApplet.html

Took me the whole day (and a good part of the night) but it was fun to make. Source is available too here. Be warned: looking at the source will not help you understand bit shifting. It will probably mess up your head for good.

Those tiny little bits live in a cruel world!


You could open the arduino library and see how it does it.

or read the datasheet. :-P