Today I wanted to modify the firmware in a PICAXE microcontroller. Downloading the IDE and compiling the code was easy enough, but you have to have a special AXE027 USB to serial converter to get the code onto the microcontroller. Any USB to TTL level serial converter will do if only it inverts the usual TTL serial levels, i.e. the AXE027 uses 0V for logic 1 and 5V for logic 0.
Once I understood the problem, the solution was easy. Program an Arduino (of which I have many on hand) to treat its own serial pins as digital I/O pins whose logical sense can be inverted and pipe the I/O through to/from another pair of pins.
void setup() {
// set up my serial pins as digital I/O
pinMode(0, INPUT);
pinMode(1, OUTPUT);
// set up two other pins for interfacing with the PICAXE
pinMode(2, OUTPUT);
pinMode(3, INPUT);
}
void loop() {
// act as a man in the middle inverting signals
digitalWrite(2, !digitalRead(0));
digitalWrite(1, !digitalRead(3));
}
That’s it. Now Arduino pin 2 goes to Serial In on the PICAXE and Arduino pin 3 goes to Serial Out.
You also have to connect Arduino ground to PICAXE ground and the PICAXE can use the Arduino’s 5V if it doesn’t have its own.