On Wednesday, I went down to Maplin’s to get just a couple of really, really pratty push-buttons that with only minor tweaking can be made to fit into standard 0.1-inch Veroboard.

Armed with these, I hurried home, and because the session down The Plots was cancelled what with the awful weather and all, I popped the kettle on, and planned my next attack on this little i2c board.

And the next attack just had to be those inputs I mentioned last post.  I could hear the board, laughing at me, challenging me to solder up the two buttons and go for it.

Well, I can report good progress on Wednesday and Thursday afternoon/evening!

By last night, I had it so it not only showed the correct time, but when I pressed one, or both, of the buttons, the corresponding LED’s would light.  I’m not saying it was easy -it wasn’t, but I finally managed to get the i2C to read the values of the buttons into the main PIC processor.  The only ‘problem’ (…if you could call it that…) was that I was doing this by polling the input pins every few milliseconds, then displaying any changes as they happened.  So yes.  It worked, but not properly.

This morning, after the usual chores, I sat down again with a fresh cup of tea, deciding to do it the right way.

The right way, is to have the little input/output chip produce an interrupt when a button is pressed.  This interrupt then temporarily stops the processor from what it’s doing -namely displaying the clock.  In the interrupt service routine, the i2c chip is then read, the processor then does a little magic to get the numbers right, then whacks it back out on the i2c bus, this time writing to the chip to tell it to display on the LED’s.

Now, this all sounds terribly simple to do, but really, it isn’t.

Anyway, long, boring and tedious story shorter: It now FULLY works.  With interrupts!

Yes, you press a push-button, and the corresponding LED comes on, and yes, you could do that simply with a switch.

But that’s not the point!

The point is that I’ve managed to get the i2c reading and writing and interrupting the PIC when something happens.

(…mutter… …mutter… …mutter…)

Onwards and upwards!

What’s next?

Why, another cup of tea, of course!

Sunday and Monday, it’ll be that cute new LCD panel I bought the other day.  It’s sat in my drawers, laughing at me.

Ha!  I’ll have you, you little swine!