Interfacing The PICAXE To A 4×3 Matrix Keypad Revisited

In a previous post, I described how to interface a 4×3 keypad that I purchased from those reliable folks at Tech Supplies in the U.K. During the course of developing our alarm system we happened to purchase a second 4×3 keypad from Conrad Electronics in Germany. What we discovered is that although these keypads look similar, they have very different pin-outs. The first keypad from Tech Supplies has the pin-outs (reading left to right and looking at the keys): (1) Not Connected (2) Column 2 (3) Row 1 (4) Column 1 (5) Row 4 (6) Column 3 (7) Row 3 (8) Row 2 (9) Not Connected. The keypad from Conrad on the other hand has the pin-outs (reading left to right and looking at the keys): (1) Column 1 (2) Column 2 (3) Column 3 (4) Row 1 (5) Row 2 (6) Row 3 (7) Row 4.

Two Similar Looking But Different 4x3 Keypads

As the pin-outs are different for the two keypads one needs to connect the keypad to, for example, a PICAXE 20M differently. The schematic for the NC-C2-R1-C1-R4-C3-R3-R2-NC 4×3 keypad can be found in my previous post. The schematic for the C1-C2-C3-R1-R2-R3-R4 4×3 keypad can be seen below:

Interfacing a 4x3 Keypad to a PICAXE20M

The TinyCAD file for this schematic can be downloaded from here. The code to scan the keypad using a PICAXE 20M remains the same:

symbol row = b1
symbol key = b2
init:
pause 500
main:
key = 0
for row = 0 to 3
high row
gosub keyscan
low row
if key > 0 then gosub displayKey
next row
goto main
keyscan:
if pin0 = 1 then
key = row * 3 + 1
do loop while pin0 = 1
elseif pin1 = 1 then
key = row * 3 + 2
do loop while pin1 = 1
elseif pin2 = 1 then
key = row * 3 + 3
do loop while pin2 = 1
endif
return
displayKey:
serout 7, N2400, (254,1,#key)
return
end
Advertisements

Amazon Kindle DX 2.5.3

Just 4 days with 2.5.2 and my Kindle DX has been updated again – this time to 2.5.3. I can’t see any difference in the functionality and the browser still works. Maybe this will be the final release.

Kindle DX Update 2.5.3

Amazon Kindle DX 2.5.2 Update

It’s a bit of a mixed bag. I have to admit being disappointed by some of the updates and very surprised by some others. Let’s start with the biggest disappointment – PDF zooming and panning. I find the implementation to be clunky with the zoom options limited to 150%, 200%, 300% and actual size.

Kindle 2.5.2 PDF Zoom Options

While it is an improvement, I had hoped for something which fits to the screen and allows for smaller increments so that one can get rid of useless borders while retaining the larger zoom options if needed. On the Kindle DX, the “fit to screen” zoom level is about 50% – moving to 150% is a big jump – come on guys! In the image below, you can see the 150% selection box when zooming into a PDF fitted to the Kindle DX screen size. Panning, once zoomed in, can also be excruciatingly slow in some PDF documents, so the feature is of limited use. I still recommend trimming your PDFs before downloading them to the Kindle as described in one of my previous posts.

PDF Zoom Selection Box at 150%

The next feature I had been wanting is collections and thankfully this feature delivers – and given it’s simplicity, so it should. In the home screen, one can press the menu button and then select “Create New Collection” to basically create a folder. After creating the collection, simply move onto the document you want to place into the collection, move the joystick to the right and select “Add to Collection…” which gives you a list of your collections into which the document can be placed. Pretty simple. Additional features include sorting your home screen “By Collections” as well as the ability to rename and delete collections. Below is a screen shot of my much tidier home screen via the use of collections.

Documents Sorted into Collections

Here is a screen shot of the Kindle in my electronics collection.

Kindle 2.5.2 Collections

As expected, the “social networking” options do not work in Germany and presumably all owners of the Kindle outside of the US will have the same issue. The really big surprise, and I don’t know if this is a mistake which will be patched later, is the ability to use the built-in browser. In the previous version of the firmware, this was impossible for international users – now it works just fine. If you are an international user of the Kindle and have the 2.5.2 update, press the menu button in the home screen, select the option “Experimental” and the launch the browser. Happy surfing, but please be aware that you may be charged for it’s use. I haven’t been able to find any official comments on this topic yet.

Browser on International Kindle DX

Update: My Kindle DX is now running on 2.5.3.

Interfacing The PICAXE M-Series Microcontroller With A 4×3 Matrix Keyboard

After my son discovered that disclosing your PIN for a hard coded alarm is not such a great idea, we have embarked on moving our alarm system to a micro-controller which can then be programmed to allow the user to change the PIN at run-time. Our microcontroller of choice is the PICAXE which is available here. For this project, I chose the PICAXE 20M, but this was a bad idea as the memory on this device is much too small for this kind of project as I will show later. In addition to the 20M, I also ordered the AXE029 breadboard adapter, the AXE033 Serial LCD module and a 4×3 matrix keypad for data entry. I also should mention that the service from tech supplied in the U.K. is very good – I live in Germany and the package was dispatched the same day and arrived two days later.

 

4x3 Matrix Keypad

 

Our first job in this project was to interface the keypad and LCD module to the microcontroller. In this post I will describe how the keypad can be interfaced to the 20M and in a later post I will describe the LCD module and post the code for the first version of the alarm. The pins on the keypad are arranged as follows (reading left to right and looking at the keys): (1) Not Connected (2) Column 2 (3) Row 1 (4) Column 1 (5) Row 4 (6) Column 3 (7) Row 3 (8) Row 2 (9) Not Connected. The row pins (R1 – R4) should be connected to output pins of the 20M as follows: (1) Output0 -> R1 (2) Output1 -> R2 (3) Output2 -> R3 (4) Output3 -> R4. The column pins of the keypad (C1 – C3) should be connected to the input pins of the 20M as follows:  (1) C1 -> input0 (2) C2 -> input1 (3) C3 -> input2. Don’t forget that the input pins 0 – 2 on the PICAXE have to be pulled down to 0v using 10k resistors so that the pins aren’s floating when no input is present from the keypad. The circuit described above can be seen in the following schematic.

 

PICAXE 20M Keypad Interface Schematic

 

The next step is to program the microcontroller so that it scans the key pad. To do this, simply loop through the rows one at a time (output0 – output3) and test which column is set. Below is the code I developed to do this. In a nutshell, the main routine loops across all of the row pins and sets them high one by one. The keyscan routine is called for each row scan and it checks if a column pin is high – if true, it calculates the key number using the simple calculation row * 3 + column and waits until the key is released. The displayKey routine displays the number on an LCD module.

symbol row = b1
symbol key = b2
init:
pause 500
main:
key = 0
for row = 0 to 3
high row
gosub keyscan
low row
if key > 0 then gosub displayKey
next row
goto main
keyscan:
if pin0 = 1 then
key = row * 3 + 1
do loop while pin0 = 1
elseif pin1 = 1 then
key = row * 3 + 2
do loop while pin1 = 1
elseif pin2 = 1 then
key = row * 3 + 3
do loop while pin2 = 1
endif
return
displayKey:
serout 7, N2400, (254,1,#key)
return
end

Update: This post described how to interface an alternative 4×3 Keypad with a different pin-out configuration.

Cool Firefox Extensions

One of the great things about Firefox is XUL and the ability to write extensions with a relatively small amount of effort – this is not the case with Microsoft’s IE. Anyway, two really cool extensions that I just found are: IE tab, which allows you to switch browser engines from within Firefox and Notefish (an extension is also available for IE). Notefish is a tool which I’ve been wanting for a long time and now it here – try it and use it! For more extensions, checkout the Mozilla site. If you don’t have Firefox – get a copy here.