PICAXE and Arduino: How to combine them for amazing microcontroller projects
Introduction
If you are interested in microcontroller projects, you may have heard of Arduino and Picaxe. Arduino is an open-source platform that consists of hardware boards based on AVR or ARM microcontrollers, and software tools that allow you to program them in C/C++. Picaxe is a family of PIC microcontrollers that have a pre-installed boot-loader that allows you to program them in BASIC, Blockly, or flowcharts using dedicated software tools.
Download free Program A Picaxe With Arduino software
Both Arduino and Picaxe have their advantages and disadvantages. Arduino offers more power, flexibility, and compatibility, but also requires more complex programming skills and hardware setup. Picaxe offers more simplicity, affordability, and accessibility, but also has more limitations in terms of memory, speed, and functionality.
But what if you could combine the best of both worlds? What if you could program a Picaxe with Arduino software? This way, you could enjoy the ease of use and low cost of Picaxe, while also taking advantage of the rich features and libraries of Arduino. Sounds interesting, right?
In this article, we will show you how to do just that. We will guide you through the steps of setting up the hardware, installing and configuring the software, writing and uploading the code, running and testing the program, and troubleshooting any issues. By the end of this article, you will be able to program a Picaxe with Arduino software like a pro.
Ready? Let's get started!
Setting up the hardware
The first thing you need to do is to prepare the hardware components and tools for programming a Picaxe with Arduino software. Here is what you will need:
A Picaxe chip. You can choose any size or model of Picaxe chip, depending on your project needs. For this tutorial, we will use a Picaxe-08M2, which is one of the most popular and versatile chips. It has 512 bytes of program memory, 14 bytes of variable RAM, 5 outputs/4 inputs, and can run a single servo.
An Arduino board. You can use any type or model of Arduino board that has a serial port or an ICSP header. For this tutorial, we will use an Arduino Uno, which is one of the most common and widely used boards. It has an ATmega328P microcontroller, 32 KB of flash memory, 2 KB of SRAM, 14 digital I/O pins, 6 analog inputs, and a USB port.
A breadboard and some jumper wires. You will need these to connect the Picaxe chip to the Arduino board and to other components. A breadboard is a plastic board with holes that allow you to insert wires and components without soldering. Jumper wires are short wires with metal pins at both ends that can fit into the breadboard holes.
A USB cable. You will need this to connect the Arduino board to your computer and to power the circuit. Make sure the cable matches the type of USB port on your Arduino board.
A battery holder and a battery. You will need these to power the Picaxe chip separately from the Arduino board. The battery holder should have two wires that can be inserted into the breadboard. The battery should match the voltage required by your Picaxe chip. For example, a Picaxe-08M2 can run on 3V to 5V, so you can use a CR2032 coin cell battery or two AA batteries.
A 10K ohm resistor. You will need this to connect the serial output of the Picaxe chip to the serial input of the Arduino board. A resistor is a component that limits the flow of electric current in a circuit. The value of a resistor is measured in ohms and is usually indicated by colored bands on its body.
A LED, a servo, or a sensor. These are optional components that you can use to test your program and see how it works. An LED is a light-emitting diode that can turn on and off when current flows through it. A servo is a motor that can rotate to a specific angle when controlled by a signal. A sensor is a device that can measure physical quantities such as temperature, light, or sound.
Once you have gathered all the components and tools, you can proceed to wire up a simple circuit for connecting a Picaxe to an Arduino board. Here is how you do it:
Insert the Picaxe chip into the breadboard, making sure that each pin goes into a separate row of holes. The Picaxe chip has a notch or a dot on one end that indicates where pin 1 is located. Pin 1 should be on the left side when you face the notch or the dot.
Connect one wire of the battery holder to pin 1 of the Picaxe chip, and the other wire to pin 8. This will provide power to the Picaxe chip.
Connect one end of the 10K ohm resistor to pin 7 of the Picaxe chip, and the other end to pin 0 (RX) of the Arduino board. This will connect the serial output of the Picaxe chip to the serial input of the Arduino board.
Connect one jumper wire from pin 6 (GND) of the Arduino board to any empty row on the breadboard. This will create a common ground for both devices.
Connect another jumper wire from pin 4 (GND) of the Picaxe chip to the same row as the previous wire. This will complete the ground connection for both devices.
Connect one end of the USB cable to the USB port of the Arduino board, and the other end to your computer. This will provide power to the Arduino board and allow you to communicate with it using your computer.
If you want to test your program with an LED, connect one leg of the LED (the longer one) to pin 2 of the Picaxe chip, and the other leg (the shorter one) to another empty row on the breadboard. Then connect another jumper wire from that row to pin 4 (GND) of the Picaxe chip. This will create a simple LED circuit that you can control with your program.
If you want to test your program with a servo, connect one wire of the servo (the red one) to pin 1 (+V) of the Picaxe chip, another wire (the black one) to pin 4 (GND) of the Picaxe chip, and the third wire (the yellow or white one) to pin 3 of the Picaxe chip. This will create a simple servo circuit that you can control with your program.
If you want to test your program with a sensor, connect one wire of the sensor (the red one) to pin 1 (+V) of the Picaxe chip, another wire (the black one) to pin 4 (GND) of the Picaxe chip, and the third wire (the yellow or white one) to pin 5 of the Picaxe chip. This will create a simple sensor circuit that you can read from with your program.
Here is a diagram of the circuit that we have built:
You can use a multimeter or a voltmeter to test the voltage and current in your circuit and make sure everything is connected correctly. You can also use an LED or a buzzer to test the output pins of your Picaxe chip and make sure they are working properly.
If you encounter any issues with your circuit, such as no power, no communication, or no response, you can try the following steps to troubleshoot them:
Check the polarity and voltage of your battery and make sure it is not dead or low.
Check the wiring and connections and make sure they are not loose or broken.
Check the orientation and placement of your Picaxe chip and make sure it is not inserted backwards or in the wrong row.
Check the value and placement of your resistor and make sure it is not too high or too low or in the wrong row.
Check the type and model of your Arduino board and make sure it matches the one you selected in the software settings.
Check the type and model of your Picaxe chip and make sure it matches the one you selected in the software settings.
Once you have verified that your circuit is working correctly, you can move on to the next step: installing and configuring the software.
Installing and configuring the software
The next thing you need to do is to install and configure the software tools for programming a Picaxe with Arduino software. There are two main options for this: using the Picaxe Programming Editor or the AxePad Editor for writing and uploading code to the Picaxe chip, and using the Arduino IDE or Blockly for Picaxe for writing code for the Arduino board. You can choose either option depending on your preference and availability. We will explain both options in this section.
Option 1: Using Picaxe Programming Editor or AxePad Editor
The Picaxe Programming Editor and AxePad Editor are free software tools developed by Revolution Education, the company behind Picaxe. They allow you to write code for any Picaxe chip in BASIC, Blockly, or flowchart mode, and upload it to the chip using a serial port or an ICSP header. They also provide features such as syntax highlighting, auto-completion, code verification, debugging, simulation, and documentation.
To download and install either of these tools, follow these steps:
Go to https://picaxe.com/software/ and choose either Picaxe Programming Editor or AxePad Editor depending on your operating system. The Picaxe Programming Editor is available for Windows only, while AxePad Editor is available for Windows, Mac OS X, Linux, Chrome OS, Android, and iOS.
Click on the download link and follow the instructions to download and install the tool on your computer. You may need administrator privileges to do this.
Launch the tool and agree to the terms and conditions. You may need to register an account or enter a license key if prompted.
Select your language from the menu bar if you want to change it from English.
To configure either of these tools for programming a Picaxe with Arduino software, follow these steps:
Select Options from the menu bar and then select Mode. Choose either BASIC mode, Blockly mode, or Flowchart mode depending on how you want to write code for your Picaxe chip. BASIC mode allows you to write code in text format using BASIC commands. Blockly mode allows you to write code in graphical format using blocks that represent commands. Flowchart mode allows you to write code in graphical format using symbols that represent commands.
Select Options from the menu bar and then select Hardware Options. Choose your Picaxe chip model from the drop-down list. For example, if you are using a Picaxe-08M2, choose 08M2 from the list. This will set the correct memory size and pin configuration for your chip.
Select Options from the menu bar and then select Serial Port. Choose the serial port that corresponds to your Arduino board from the drop-down list. For example, if you are using an Arduino Uno connected to your computer via USB, choose COM3 or COM4 or whatever port is assigned to your board. You can check this in the Device Manager on Windows or the System Information on Mac OS X. This will set the correct communication channel for uploading code to your Picaxe chip.
Select Options from the menu bar and then select Download Options. Choose either Serial or ICSP depending on how you want to upload code to your Picaxe chip. Serial mode uses the serial port of your Arduino board and requires a 10K ohm resistor between the Picaxe output and the Arduino input. ICSP mode uses the ICSP header of your Arduino board and requires a direct connection between the Picaxe output and the Arduino input. This will set the correct upload method for your circuit.
Now you are ready to write and upload code to your Picaxe chip using either Picaxe Programming Editor or AxePad Editor.
Option 2: Using Arduino IDE or Blockly for Picaxe
The Arduino IDE and Blockly for Picaxe are alternative software tools that allow you to write code for any Picaxe chip in C/C++ or Blockly, and upload it to the chip using a serial port or an ICSP header. They also provide features such as syntax highlighting, auto-completion, code verification, debugging, simulation, and documentation.
To download and install either of these tools, follow these steps:
Go to https://www.arduino.cc/en/software and choose either Arduino IDE or Blockly for Picaxe depending on your operating system and preference. The Arduino IDE is available for Windows, Mac OS X, Linux, and Web Editor, while Blockly for Picaxe is available for Windows only.
Click on the download link and follow the instructions to download and install the tool on your computer. You may need administrator privileges to do this.
Launch the tool and agree to the terms and conditions. You may need to register an account or enter a license key if prompted.
Select your language from the menu bar if you want to change it from English.
To configure either of these tools for programming a Picaxe with Arduino software, follow these steps:
Select Tools from the menu bar and then select Board. Choose your Arduino board model from the drop-down list. For example, if you are using an Arduino Uno, choose Arduino Uno from the list. This will set the correct microcontroller type and configuration for your board.
Select Tools from the menu bar and then select Port. Choose the serial port that corresponds to your Arduino board from the drop-down list. For example, if you are using an Arduino Uno connected to your computer via USB, choose COM3 or COM4 or whatever port is assigned to your board. You can check this in the Device Manager on Windows or the System Information on Mac OS X. This will set the correct communication channel for uploading code to your Picaxe chip.
Select Tools from the menu bar and then select Programmer. Choose either AVRISP mkII or Arduino as ISP depending on how you want to upload code to your Picaxe chip. AVRISP mkII mode uses the serial port of your Arduino board and requires a 10K ohm resistor between the Picaxe output and the Arduino input. Arduino as ISP mode uses the ICSP header of your Arduino board and requires a direct connection between the Picaxe output and the Arduino input. This will set the correct upload method for your circuit.
Now you are ready to write and upload code to your Picaxe chip using either Arduino IDE or Blockly for Picaxe.
Writing and uploading the code
The next thing you need to do is to write and upload the code for programming a Picaxe with Arduino software. There are two parts of the code: one for the Picaxe chip and one for the Arduino board. You can write the code in different languages and modes depending on the software tool you are using. We will explain both parts of the code in this section.
Code for the Picaxe chip
The code for the Picaxe chip is the part that tells the chip what to do and how to communicate with the Arduino board. You can write this code in BASIC, Blockly, or flowchart mode using either Picaxe Programming Editor, AxePad Editor, or Blockly for Picaxe. You can also write this code in C/C++ using Arduino IDE, but you will need to use some special commands and libraries that are compatible with Picaxe.
For this tutorial, we will use BASIC mode and Picaxe Programming Editor as an example. Here is how you write a basic program for a Picaxe chip in BASIC mode:
Open Picaxe Programming Editor and create a new file or open an existing one.
Start your program with a comment that describes what it does and what chip model it is for. A comment is a line of text that is ignored by the compiler and is used for documentation purposes. You can write a comment by starting a line with an apostrophe ('), or by enclosing a block of text between /* and */ symbols.
Write a directive that sets the frequency of your Picaxe chip. A directive is a command that tells the compiler how to compile your program. You can write a directive by starting a line with a hash (#) symbol. The frequency directive sets the speed of your chip in megahertz (MHz). For example, if you are using a Picaxe-08M2, you can write #picaxe 08m2 to set the frequency to 4 MHz, or #picaxe 08m2, 8 to set it to 8 MHz.
Write a directive that sets the serial baud rate of your Picaxe chip. The serial baud rate is the speed of data transmission between your chip and your Arduino board in bits per second (bps). You can use the baud directive to set the serial baud rate to one of the predefined values: 2400, 4800, 9600, 19200, or 38400. For example, you can write #baud 9600 to set the serial baud rate to 9600 bps.
Write a directive that sets the serial pin of your Picaxe chip. The serial pin is the output pin of your chip that is connected to the input pin of your Arduino board via a resistor or a direct connection. You can use the serout directive to set the serial pin to one of the available pins on your chip. For example, if you are using a Picaxe-08M2 and have connected pin 7 to pin 0 (RX) of your Arduino board via a 10K ohm resistor, you can write #serout B.2, N2400_4 (Baudmode) to set pin 7 as Here is how you write a basic program for an Arduino board in C/C++ mode:
Open Arduino IDE or Blockly for Picaxe and create a new file or open an existing one.
Start your program with a comment that describes what it does and what board model it is for. A comment is a line of text that is ignored by the compiler and is used for documentation purposes. You can write a comment by starting a line with two slashes (//), or by enclosing a block of text between /* and */ symbols.
Write two functions that define the structure of your program: setup() and loop(). A function is a block of code that performs a specific task and can be reused throughout your program. The setup() function runs once when the board is powered on or reset, and is used to initialize variables, pin modes, and libraries. The loop() function runs repeatedly after the setup() function, and is used to control the main logic of your program. You can write a function by starting a line with the function name followed by parentheses () and curly braces . For example:
// This program blinks an LED connected to pin 13 // It is for Arduino Uno board void setup() // put your setup code here, to run once: pinMode(13, OUTPUT); // set pin 13 as output void loop() // put your main code here, to run repeatedly: digitalWrite(13, HIGH); // turn on LED delay(1000); // wait for 1 second digitalWrite(13, LOW); // turn off LED delay(1000); // wait for 1 second
Write any additional functions or variables that you need for your program. A variable is a name that represents a value that can change during the execution of your program. You can write a variable by starting a line with the data type followed by the variable name and optionally an initial value. For example:
int counter = 0; // declare an integer variable named counter and initialize it to 0
You can also use constants, which are values that do not change during the execution of your program. You can write a constant by using the #define directive followed by the constant name and value. For example:
#define LED_PIN 13 // define a constant named LED_PIN with value 13
You can also use predefined constants such as HIGH, LOW, INPUT, OUTPUT, etc. that are part of the Arduino API.
Write any statements that control the flow of your program. A statement is a line of code that instructs the board to do something, such as reading or writing a pin, calling a function, or performing a calculation. You can write a statement by using operators, values, variables, constants