Mostly about programming
-
POV source code – part 2
Clock interrupt The STC89C52 has three timer/counters (most of the 8051 chips have the first two, and the third one is pretty common). One of the modes for timer 1 is to count clock pulses in an 8-bit register and when FF is reached, reload the count register from a separate 8-bit register. Each time…
-
POV source code – part 1
These posts relate to the previous few concerning the Banggood kit: Cross LED Dot Matrix Display Circuit Board Rotating Electronic Kit It uses an STC89C52RC microcontroller which is a (fairly) modern Chinese version in the 8051 family. You can program it in assembler, but I chose to use the C language for this project. The…
-
Cheap POV (persistence of vision) clock kit
These kits are available on Banggood.com for about $11 shipping included. Tricky soldering, and they don’t come with any instructions. There are instructions available on the website – but not unless you read Chinese. The pictures on the website help though. Anyway, I recommend the kit. Even if you can’t get it working properly, it’s…
-
ISP programmer for the STC89C51 and STC89C52
I couldn’t find an ISP (programmer) for the STC89C52RC that worked with modern versions of Windows. I found several programmers that work with other chips in the STC range. I did find one that worked on Windows XP, and with some hacking got it to work with Windows 7; however I had no luck with…
-
Fast, small, and simple Arduino SPI RAM chip routines.
The 8-pin chip, 23LC1024, is a good candidate for adding extra RAM to simple Arduinos such as the Uno, Nano, Mini. It provides 128K of RAM (the ATmega328 chip that these Arduinos use only has 2K of internal RAM). The chip works at 5V (anything from 2.5V to 5.5V) and uses SPI so it only…
-
Untangle, Planarity.
I’ve been writing some code (in Java) to solve this fun puzzle. I’ve played the puzzle for many years – it’s part of the excellent and free Simon Tatham’s Portable Puzzle Collection which has been available on many platforms for ages and has recently been ported to Android too. Untangle was inspired by Planarity, written…
-
ATmega328P-PU 12MHz bootloader
It took me an embarrassingly long time to get a 328 with a 12MHz crystal working so that it would allow a normal (serial / FTDI) upload from the Arduino IDE. There are a few older guides around but I didn’t find one that used the newer optiboot bootloader. If you don’t want to compile…
-
Controlling the Raspberry Pi camera from C
I wanted to be able to stop and start the camera driven by events instead of just calling raspivid to record for a preset time. My code is really just a simple wrapper around raspivid using the SIGUSR1 option to stop the video under program control rather than after a preset time. The example main()…
-
Decoding 6 servo channel inputs with an Arduino UNO
Standard radio control receivers drive their connected servos by outputting a train of pulses. The pulses usually repeat at a 50 Hz rate but the pulse width is the important thing – the standard is a 1.5 ms pulse width for a servo at its center position varying from about 1.0 ms up to 2.0…
-
Flash Rubik Cube Simulator
Above is a snapshot image. Here’s the real thing. It works for any size of cube from 2 x 2 x 2 up to 11 x 11 x 11. Actually, 11 is an arbitrary limit – the same code would work for any size of cube. Use the little + and – buttons up in the top…
Got any book recommendations?