Ceci est une ancienne révision du document !
This month, it’s time to combine two chunks of code into one, but this time with a broader view. These two parts will form a larger beast in the coming months. I mentioned the 16×2 LCD screen in a previous Arduino section in FCM, but I haven’t mentioned the 3×4 keypad that I have. It’s a bog standard, no name, 3×4 keypad, with holes in its board for wires. I’ve soldered in some wires of various colours and it’s ready to be bolted onto the LCD screen. I already have my LCD screen wired up to the breadboard and have the basic ‘hello world’ sketch running on it, so I know for sure my LCD part is right. I’ve previously tinkered with the keypad and monitored the output in the serial window (code shown below) but now it’s time to bypass the serial window and go right to the LCD screen.
So, I have the keypad wired into the remaining digital pins and need to merge the two lots of code. Note that I’ve missed out digital pin 1. For some reason when I used pin 1, I would end up with a row of keys that wouldn’t output. I’m not entirely sure why. I have to assume it’s to do with pin 1 being the TX, or transmit, pin. Getting it working was pretty simple. I pasted in the include and keypad setup stuff at the start followed by editing the keypad pin numbers accordingly. In the original LCD code it printed ‘hello world’ in the top line then, below that, the time it’d been running in milliseconds. I replaced the ‘hello world’ text with ‘Enter code:’ and replaced the milliseconds with the key char. That was basically it. My code is at: http://pastebin.com/YndLneqm Next month, we’ll add more to the code, possibly more to the circuit too. Although, I’m quickly running out of pins! I have only the analog pins left.