Showing posts from February, 2020

An I2C keypad for the micro:bit - part 2

A working prototype I've now got a home-brew Arduino clone reading the keyboard and sending key-presses to a micro:bit using I2C. Preparing the Arduino clone was trickier than usual. As I mentioned in yesterday's post , the Arduino needs to run at 3.3 volts. That's the working voltage (V cc ) for the micro:bit, the Pi and the Jetson Nano. Connecting I2C lines from a 5v device would damage them, so 3.3 v operation is essential. I have a good stock of ATmega328P chips left over from the days when I was running Shrimping workshops. The ATmega328P  works well at 3.3 volts, so long as the clock frequency is no more than 8 MHz . Most Arduinos run at 5v with a clock speed of 16 MHz, so there's work to do.   8 MHz clock issues If I2C is to work reliably at 8 MHz the Arduino needs to be configured for an 8 MHz clock, and it needs a bootloader that works at that clock rate. My first step was to wire up a working clone on a breadboard with an 8 MHz crystal and i

An I2C keypad for the micro:bit - part 1

I love the micro:bit. It's affordable, it runs micropython, and it's instantly engaging. These days it's supported by a huge range of add-ons that extend its capabilities, but there's always room for more. A lot of the add-ons that I buy or build use are based on the I2C protocol. I2C is a  widely-supported way of connecting and controlling add-on boards to single board computers like the micro:bit, Arduino and Raspberry Pi. There's lots of sample I2C code for the Arduino and the Pi, but not so much for the micro:bit. A few days ago I posted about an experiment connecting a micro:bit to a numeric keypad using I2C . That worked well, and the code is on GitHub . As you can see, the program needed quite a bit of code, and space on the micro:bit is at a premium. Since I wanted to add an LCD display I started looking for a more compact approach. Help from Arduino I decided to try out a design that used a home-brew Arduino clone to scan the keypad and make key

Adding a DS1307 Real Time Clock to Raspberry Pi

Grove RTC The DS1307 RTC (Real Time Clock) is widely available, but adding one to a Raspberry Pi turned out to be a bit of a Yak shave. I'm gradually adding code and wiring instructions to my babelboard hardware and software projects, and I thought it was time to cover an RTC. I had a Grove RTC board from years ago and decided I'd document connecting that to a Raspberry Pi. The need for Battery Power First Yak Shave moment: RTCs normally use a coin battery to maintain power so they can keep time when their host is off, and the battery in my Grove board was way past its use-by date. This happened on Sunday evening, and the local supermarkets were shut, but the local convenience store was open. No CR1220, though, so I had to wait until the next day to get started. While I was waiting I read the data sheet for the DS1307 chip and realised I had another problem. Don't connect this chip directly to your Pi! Seeed Studios describe the DS1307 breakout as P

I2C and SPI on the micro:bit; additions to the babelboard range

micro:bit Keypad using I2C+ MC23008 For some reason there's not a lot on the web about using I2C and SPI with the BBC micro:bit. The I2C and SPI protocols allow single board computers like the micro:bit, the Raspberry Pi and Jetson Nano to drive hundreds of different types of useful peripheral chips. There are lots of widely available drivers for the Raspberry Pi, the Arduino and  Adafruit boards. I've seen fewer for the micro:bit, and I have started writing some more as part of my babelboard project . I am also building a babelboard for the micro:bit. The babelboard project Babelboards allow you to connect a range of I2C and SPI devices to several popular single board computers. The image on the right shows an mcp23S08 reading a hex keypad driven by a micro:bit using SPI. The micro:bit babelboard allows you to connect Grove I2C devices and the Quick2Wire port expander and analog boards. You can get adapters that connect Grove to Qwiik , so you can also con

The bistable flip-flop 60 years on

flip-flop from 'Electronic Computers'  - T.E. Ivall About 60 years ago I started to teach myself about how digital computers worked. I'd already written some simple programs and I wanted to build a computer of my own. In 1960 that was a bit ambitious, but I did manage to build a few simple digital circuits including a flop-flop . (A few years later I hand-wired a core store, but that's another story). The flip-flop lies at the heart of digital electronics.The thing that makes digital computers so powerful is memory. Memory  can store the data that programs work on, and it can also store the the programs themselves. Early computers used a variety of techniques for storage but almost all of them used flip-flops to some extent. The bistable flip-flop is a very simple circuit. It can store a single binary digit (bit) of information.  The flip-flop was not new in 1960. The original patent was granted to the inventors (Eccles and Jordan) in 1918. That was long befo

Adafruit Clue - love at first sight

My Adafruit Clue has just arrived, and I am delighted with it. The Clue is a small single board computer that has the same format and connectors as the BBC micro:bit . It's more expensive than the micro:bit but it's a much, much more capable device. micro:bit Pros and Cons  I still love the micro:bit. It invites you to interact with it as soon as you power it on and it's introduced a huge audience to the pleasures of programming. There are a range of programming options for the micro:bit, including micropython, and it's easy to program using the free mu editor.  However, it has some frustrating limitations. The micro:bit's 5x5 LED display is cute, but scarcely high-resolution. There are a few on-board sensors - an accelerometer and a magnetometer - and you can coax the processor chip into telling you how hot it is. It has a couple of buttons, and it supports radio communication with other micro:bits. But that's all. It also has quite limi