Hi Ming,<div><br></div><div>The << operator is a <b>logical shift left</b>.  See the wiki article here: <a href="http://en.wikipedia.org/wiki/Logical_shift">http://en.wikipedia.org/wiki/Logical_shift</a></div><div><br>

</div><div>According to the MCP23017 datasheet, the I2C registers 0x12 and 0x13 control the outputs.  There are 8 bits per register, so each bit controls a single output: if the bit is high (1), the output is also high, and the LED is on.</div>

<div><br></div><div>What the example code does is loop through the range 0 to 7, and toggle one bit on at a time (to turn each output on in sequence).</div><div><br></div><div>If you take a look at the wiki article for logical shifting, can you work out what happens when (for example), you set I2C address 0x12 to (1 << 5)?</div>

<div><br></div><div>Best,</div><div>Jon</div><div><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Nov 15, 2012 at 3:38 PM, Ming kuo <span dir="ltr"><<a href="mailto:mingtkuo@gmail.com" target="_blank">mingtkuo@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><font face="verdana,sans-serif">Thank you Tom, Jon, and Greg,</font><div><font face="verdana,sans-serif"><br></font></div>

<div><font face="verdana,sans-serif">I am grateful for all the help while I go through this challenge.</font></div>

<div><font face="verdana,sans-serif"><br></font></div><div><font face="verdana, sans-serif">Tom, I have previously responded to Jon and Greg privately trying to avoid too many emails to the group.  </font></div><div><font face="verdana, sans-serif"><br>



</font></div><div><font face="verdana, sans-serif">But yes, your tracking of my progress of the project is right, I basically have proof of concept with hardware, circuits and now it is just the software programming..</font></div>



<div><font face="verdana, sans-serif"><br></font></div><div><font face="verdana, sans-serif">Following the code in the previously mentioned example, I am trying to adapt it to working with the Bar LED..</font></div><div>


<font face="verdana, sans-serif"><br>
</font></div><div><font face="verdana, sans-serif">I have isolated the critical piece of code is </font></div><div><font face="verdana, sans-serif"><br></font></div><div><pre style="white-space:pre-wrap;word-wrap:break-word">


   for x in range(0,8):
     a = 1 << x
     set_led(a,0)
     time.sleep(delay)
   set_led(0,0)</pre><pre style="white-space:pre-wrap;word-wrap:break-word"><br></pre><pre style="white-space:pre-wrap;word-wrap:break-word">in code :  set_led(x,y) x is the data and y is the bank.</pre>

<pre style="white-space:pre-wrap;word-wrap:break-word">so I am confused on x or data piece of the parameter..</pre><pre style="white-space:pre-wrap;word-wrap:break-word"><br></pre><pre style="white-space:pre-wrap;word-wrap:break-word">


in the above code set_led(a,0) </pre><pre style="white-space:pre-wrap;word-wrap:break-word"><b><font size="4">a= 1 << x what does this statement do?</font></b></pre><pre style="white-space:pre-wrap;word-wrap:break-word">


<b><font size="4">and I tried just setting a to various numbers 1,2,3,4,5,6,7,8,9 and the led seem to light up in no understandable pattern, sometimes individually and sometimes multiple LEDs go on.. </font></b></pre><pre style="white-space:pre-wrap;word-wrap:break-word">


<br></pre><pre style="white-space:pre-wrap;word-wrap:break-word">So basically, once I get to know how to control the leds on the bar graph, then I can start deciphering the code for letters and words</pre>

<pre style="white-space:pre-wrap;word-wrap:break-word"><br></pre><pre style="white-space:pre-wrap;word-wrap:break-word">Thanks to the group</pre><span class="HOEnZb"><font color="#888888"><pre style="white-space:pre-wrap;word-wrap:break-word">


<br></pre><pre style="white-space:pre-wrap;word-wrap:break-word">Ming</pre></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Nov 15, 2012 at 2:36 PM, Tom Metro <span dir="ltr"><<a href="mailto:tmetro+hhacking@gmail.com" target="_blank">tmetro+hhacking@gmail.com</a>></span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>Ming kuo wrote:<br>
> Hi Guys, I was recently introduced to this group, so here is my first post.<br>
<br>
</div>Welcome to the group.<br>
<div><br>
<br>
> I figured out the wiring to get the bar to light up using the same codes<br>
> as above.<br>
<br>
</div>Sounds like you've got the hard part done. If you've gotten that much to<br>
work, then you've proven the hardware works, and the basic software<br>
works. Now you just need to tweak the behavior.<br>
<div><br>
<br>
> I am stuck...on the python code to control the I2C.<br>
</div><div>> This is my immediate challenge to figure out how to program the<br>
</div>> I2C for the LED bar...<br>
<br>
Can you clarify?<br>
<br>
You said above that you succeeded in getting the bar to light up using<br>
the same setup as the article you referenced. That implies you have a<br>
working I2C driver and some Python code using it.<br>
<br>
<br>
> ...I need to program a python code to POV display the messages which<br>
<div>> i can imaging that it get pretty challenging given how to form a<br>
> character with LED while timing the rotation.<br>
<br>
</div>So POV is persistence of vision? You're looking to build something like:<br>
<a href="http://www.youtube.com/watch?v=fJBYOU-Y-ZU" target="_blank">http://www.youtube.com/watch?v=fJBYOU-Y-ZU</a><br>
<br>
How do you plan to move the display?<br>
<br>
To build on what Jon Evans said in his reply, it sounds like what you<br>
have left to do is less hardware hacking and more basic Python coding.<br>
Looking at the sample code:<br>
<a href="http://www.skpang.co.uk/blog/wp-content/uploads/2012/06/ledchaser.py" target="_blank">http://www.skpang.co.uk/blog/wp-content/uploads/2012/06/ledchaser.py</a><br>
<br>
they provide a set_led() function, so you'll need to remove the two<br>
chunks of code used to strobe the LEDs ("# Move led left " and "# Move<br>
led right") and replace them with your character generating code.<br>
<br>
Not trivial but given that POV displays seem to be popular, likely you<br>
can find some existing code for the character generator. If not, you'll<br>
need to dig up a library or lookup table that maps characters to dot<br>
patterns. Basically a dot matrix font. Then build a function that when<br>
given a character, translates that into the equivalent array of dots.<br>
<br>
I'd be inclined to use an architecture where rows of dots are pushed<br>
onto a stack, and then some background process is responsible for<br>
pulling a row from the stack and lighting up the LEDs on a steady clock<br>
rate. (I'm not sure if that's easy to accomplish in Python.)<br>
<br>
I'm guessing that with most of these POV displays, there isn't any real<br>
synchronization between the display motion and the strobing. The builder<br>
simply tunes the strobe rate until it works most of the time for<br>
whatever RPM their display ends up running at.<br>
<div><br>
<br>
> So any help through email or in person would be greatly appreciated.<br>
<br>
</div>Post some follow up questions as you get stuck and we'll see what we can do.<br>
<span><font color="#888888"><br>
 -Tom<br>
</font></span></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
Hardwarehacking mailing list<br>
<a href="mailto:Hardwarehacking@blu.org">Hardwarehacking@blu.org</a><br>
<a href="http://lists.blu.org/mailman/listinfo/hardwarehacking" target="_blank">http://lists.blu.org/mailman/listinfo/hardwarehacking</a><br>
<br></blockquote></div><br></div>