{"id":54,"date":"2011-08-16T14:24:11","date_gmt":"2011-08-16T18:24:11","guid":{"rendered":"http:\/\/www.jetmore.org\/john\/blog\/?p=54"},"modified":"2011-08-16T14:24:11","modified_gmt":"2011-08-16T18:24:11","slug":"hardware-is-hard-lets-go-shopping","status":"publish","type":"post","link":"https:\/\/www.jetmore.org\/john\/blog\/2011\/08\/hardware-is-hard-lets-go-shopping\/","title":{"rendered":"Hardware is hard, let&#8217;s go shopping&#8230;"},"content":{"rendered":"<p>After a brief diversion into soldering I was back to playing with the Arduino last night, working through samples in the <a href=\"http:\/\/www.adafruit.com\/products\/170\">Arduino Experimentation Kit<\/a>\u00a0I bought a while back from Adafruit. \u00a0I&#8217;m only up to experiment 4 because I&#8217;ve spent a lot of time trying to understand the underlying electronics theory (why can&#8217;t you drive a motor directly from an arduino pin? \u00a0I mean, mathematically? \u00a0What the heck does a transistor actually do?). \u00a0The experimentation kit seems geared more towards getting people comfortable with the programming than the electronics, so wikipedia and I have been spending a lot of time together.<\/p>\n<p>Last night&#8217;s experiment was working with a shift register to drive 8 LEDs. \u00a0There was a previous 8 LED project, but those were driven directly from Arduino pins, this project was designed to drive the same 8 LEDs, but only using 3 pins. \u00a0Wiring it was a snap (more or less, still trying to get a grip on the best order in which to place components) and the software was easy to load. \u00a0Just needed to give it a cursory run to prove it works so I could move on to what I really wanted to do, which was to see if I could figure out how to load a potentiometer into the circuit and use the LEDs as an indicator of the pot&#8217;s position.<\/p>\n<p>Compile, load, and&#8230; Well, ok, the light&#8217;s were blinking, but not in the order I expected. \u00a0Changed the code to increase the delay between cycles, and the blinks were definitely not what I expected. \u00a0Rereading the project details, I notice it never actually says what the lights will do, but it seems really clear from the code that it will be a 0-255 binary counter. \u00a0But that&#8217;s not what it&#8217;s doing. \u00a0I spent an hour reviewing my code (which means I would have found a bug in the kit&#8217;s sample code, which seemed unlikely), removing the loop, trying to drive just one led for the whole app&#8230; \u00a0Nothing. \u00a0The pattern of the lights would change everytime I made a change, but not in any manner I could predict.<\/p>\n<p>It was late so I decided to hang it up for the night and try again later. \u00a0I put everything away, and was standing up when I happened to glance at the wiring diagram. \u00a0I instantly noticed I had reversed the CLOCK and LATCH pins on the shift register. \u00a0The Arduino still had the last sketch I loaded on it (which simply sent &#8220;8&#8221; to the shift register), so I plugged in the 9v battery and voila &#8211; LED #3 lit up. \u00a0Arggg!<\/p>\n<p>It seems likely that it will take me a while to get used to the rhythms of electronics\/microcontroller debugging. \u00a095% of the time I know where to look for a bug in a piece of software I&#8217;m writing instantly, but because the lights did <strong>something<\/strong>, I assumed the circuit was right and the code was wrong. \u00a0Bzzt. \u00a0That would be like a junior developer telling me his code wasn&#8217;t working, and he was pretty sure it was a bug in the library. \u00a0Nope.<\/p>\n<p>On the plus side, now I&#8217;m ready to play with the pot tonight! \u00a0Whee!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>After a brief diversion into soldering I was back to playing with the Arduino last night, working through samples in the Arduino Experimentation Kit\u00a0I bought a while back from Adafruit. \u00a0I&#8217;m only up to experiment 4 because I&#8217;ve spent a &hellip; <a href=\"https:\/\/www.jetmore.org\/john\/blog\/2011\/08\/hardware-is-hard-lets-go-shopping\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/www.jetmore.org\/john\/blog\/wp-json\/wp\/v2\/posts\/54"}],"collection":[{"href":"https:\/\/www.jetmore.org\/john\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jetmore.org\/john\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jetmore.org\/john\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jetmore.org\/john\/blog\/wp-json\/wp\/v2\/comments?post=54"}],"version-history":[{"count":0,"href":"https:\/\/www.jetmore.org\/john\/blog\/wp-json\/wp\/v2\/posts\/54\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.jetmore.org\/john\/blog\/wp-json\/wp\/v2\/media?parent=54"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jetmore.org\/john\/blog\/wp-json\/wp\/v2\/categories?post=54"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jetmore.org\/john\/blog\/wp-json\/wp\/v2\/tags?post=54"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}