Blinking LEDs the hard way

Somewhere buried here are a couple of boards:Basically, what we have going on is this chip being controlled by an I2C bus:This is the PCA9505 from NXP which is nothing more than a 40-pin IO expander.I could have blinked the LED from the Arduino itself, but since I needed a whole lot more IOs for the USB charger I needed to have a play around with one of these.Which brings us to the board you're seeing there.The pins on that chip are 0.5mm on centers.  :-)  Hand soldered. For scale you can see the pin headers on the top-left. Those pins are all 0.1" spacing.I soldered this up on a SchmartBoard which alleges you can solder things easier by "pushing" the solder along each trace which is slightly routed out.I had better luck just simply drag soldering these things.The back side is where I dealt with the power and ground connections...The really cool thing is looking at the scope and seeing the result of code that's running on the Arduino controlling the show.And here's the code... too simple.

#include <Wire.h>void setup() {Wire.begin();Wire.beginTransmission(0x20);Wire.write(0x18);Wire.write(0x00);Wire.endTransmission();}void loop() {Wire.beginTransmission(0x20);Wire.write(0x08);Wire.write(0xff);Wire.endTransmission();delay(20);Wire.beginTransmission(0x20);Wire.write(0x08);Wire.write(0x00);Wire.endTransmission();delay(20);}

The part you're seeing on the scope is the first bit of the loop() up there. It's turning on pin 1 which, in turn, turns on the LED. The yellow and blue traces are the I2C bus doing its thing and the purple is the LED turning on in response to it.Register 0x18 is setting the IO config register for port 0 to all outputs. Writing to register 0x08 is just setting the outputs for that bank of (now configured) outputs. Essentially I'm toggling the entire bank because I'm being lazy and couldn't be bothered to see what is the LSB. (Yes, it seems that 0x01 is IO0_0 -- pin 3 -- on the data sheet)Fun stuff.  :-D

Previous
Previous

Sports Anemia

Next
Next

Sometime better lucky than good