mrburnette
Senior Member
Note: Please do not make religious/fanboy arguments about either product. This post is informational ONLY and is based on the first 4 Arduino BASIC examples sketches. Where possible, I selected PICAXE examples from Manual 1 and then I took poetic license to edit as I saw fit to align the intention with the descriptions in the Arduino sketch.
Overview:
The reader should not take too much away from this light discussion of the two uC programming environments. I am not presenting any information that will suggest that one is better or more appropriate than the other. I do suggest (opinion) that after one has utilized the powerful Arduino environment that one may have a deeper appreciation of the PICAXE and its general ease-of-use. However, the reader is cautioned to understand that the PICAXE is running an interpreted BASIC language and that all of the statements supporting that language are in the PICAXE firmware. The Arduino environment was defined as a Arduino Uno (latest) using the core libraries provided under version 1.0.
Additionally, the user is cautioned to understand that there are no firmware libraries in a naked Arduino ATmel processor. The bootloader is simply that, a bootloader that allows for serial programming. The Arduino does allows for programming the ATmel processor without a bootloader but requires additional hardware in the form of an In-Service-Programmer (can be another Arduino as a sketch is provided to support this use.)
Now, with the fine print behind us, I only wish to concentrate on a few examples. I hope you find these intellectually stimulating comparisons.
#1 - Blank program
Picaxe:
Arduino:
#2 - Read EEPROM and display to serial console
Picaxe:
Arduino:
#3 - Read and display ADC value to a serial monitor
Picaxe:
Arduino:
#4 - Blink a LED on a digital pin for 1 second on and 1 second off, repeat
Picaxe:
Arduino:
# 5 - Read and display on a serial console the Hi (1) and Lo (0) state of a PIN
Picaxe:
Arduino:
I have worked for some time with the PICAXE chips (08M2, 18M2, 20X2) all on breadboards supported with USB-Bub interfaces and with the ATmel Tiny85, ATmega 168 and the ATmega UNO/ATmega328 supported with the UNO interface either natively or with the ArduinoISP sketch supporting breadboard activities.
As I was playing around with sorting similar programs to put into this thread, I reflected a moment on the PICAXE firmware and the great efficiency that was put into that code. As one notices the very simple BASIC code and the small source size, one must keep in mind that the machine-code library that support all of the PICAXE commands is already loaded into the PICAXE as firmware. In the past, I have argued that this approach is wasteful since much of the firmware goes unused for simple BASIC programs. However, in all fairness to RevEd, this approach never offers any OMG surprises as the Arduino does since adding one instruction in that environment can pull in an external support library that causes a significant jump in uC program storage requirements.
The reader is left to ponder this: I am certain that ATmel and PIC folks will remain in their respective encampments. But from a hobby programming perspective, both are equally interesting and capable. While the Arduino is often stated as more expensive for projects, this is actually not the case (opinion) since with some effort, the programmer can avoid the use of the bootloader and can avoid the use of the external crystal. The PICAXE is often described as a beginners environment, but I (opinion) disagree since many complex projects can be easily supported by these chips.
- Ray
Overview:
The reader should not take too much away from this light discussion of the two uC programming environments. I am not presenting any information that will suggest that one is better or more appropriate than the other. I do suggest (opinion) that after one has utilized the powerful Arduino environment that one may have a deeper appreciation of the PICAXE and its general ease-of-use. However, the reader is cautioned to understand that the PICAXE is running an interpreted BASIC language and that all of the statements supporting that language are in the PICAXE firmware. The Arduino environment was defined as a Arduino Uno (latest) using the core libraries provided under version 1.0.
Additionally, the user is cautioned to understand that there are no firmware libraries in a naked Arduino ATmel processor. The bootloader is simply that, a bootloader that allows for serial programming. The Arduino does allows for programming the ATmel processor without a bootloader but requires additional hardware in the form of an In-Service-Programmer (can be another Arduino as a sketch is provided to support this use.)
Now, with the fine print behind us, I only wish to concentrate on a few examples. I hope you find these intellectually stimulating comparisons.
#1 - Blank program
Picaxe:
Code:
# REM 08M2+ minimum program is a blank!
# Storage space required = 3 Bytes
Code:
// Arduino bare minimum = 466 Bytes
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
#2 - Read EEPROM and display to serial console
Picaxe:
Code:
REM PICAXE progrma to read 256 eeprom values and display
REM Memory used = 35 bytes
;
Do while b0 < 256
read b0, b1
sertxd (#b0, " ", #b1,CR,LF)
INC b0
loop
end
Code:
// Arduino sketch to read 256 eeprom values and display
// Binary sketch size: 2458 bytes
#include <EEPROM.h>
void setup()
{
Serial.begin(9600);
}
void loop()
{
int a;
int value = EEPROM.read(a);
Serial.print(a);
Serial.print("\t");
Serial.print(value);
Serial.println();
a = a + 1;
if (a == 512)
exit;
}
Picaxe:
Code:
REM PICAXE read and display ADC value
REM Memory used = 12 bytes
;
main:
readadc C.1,b0 ; read ADC1 into variable b0
sertxd (#b0, CR, LF)
goto main
Code:
// Arduino sketch to read and display analog value
// Binary sketch size: 2464 bytes
/*
AnalogReadSerial
Reads an analog input on pin 0, prints the result to the serial monitor
*/
void setup() {
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(A0);
Serial.println(sensorValue);
}
#4 - Blink a LED on a digital pin for 1 second on and 1 second off, repeat
Picaxe:
Code:
REM PICAXE Blink a LED: one second on, off, repeat
REM Memory used = 14 bytes
;
symbol LED = B.4 ; rename output4 ‘LED’
Do
high LED ; LED on
pause 1000
low LED
pause 1000
Loop
Code:
// Arduino sketch to blink a LED
// Binary sketch size: 1026 bytes
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
*/
void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(13, LOW); // set the LED off
delay(1000); // wait for a second
}
# 5 - Read and display on a serial console the Hi (1) and Lo (0) state of a PIN
Picaxe:
Code:
REM PICAXE read a physical pin and report state to serial console
REM Memory used = 10 bytes
;
Do
sertxd (#pinC.3,CR,LF)
Loop
Code:
// Android sketch to read a pin and display to console
// Binary sketch size: 2734 bytes
/*
DigitalReadSerial
Reads a digital input on pin 2, prints the result to the serial monitor
This example code is in the public domain.
*/
void setup() {
Serial.begin(9600);
pinMode(2, INPUT);
}
void loop() {
int sensorValue = digitalRead(2);
Serial.println(sensorValue);
}
I have worked for some time with the PICAXE chips (08M2, 18M2, 20X2) all on breadboards supported with USB-Bub interfaces and with the ATmel Tiny85, ATmega 168 and the ATmega UNO/ATmega328 supported with the UNO interface either natively or with the ArduinoISP sketch supporting breadboard activities.
Both environments are productive
Both environments are easily interfaced
Both environments support USB easily
As I was playing around with sorting similar programs to put into this thread, I reflected a moment on the PICAXE firmware and the great efficiency that was put into that code. As one notices the very simple BASIC code and the small source size, one must keep in mind that the machine-code library that support all of the PICAXE commands is already loaded into the PICAXE as firmware. In the past, I have argued that this approach is wasteful since much of the firmware goes unused for simple BASIC programs. However, in all fairness to RevEd, this approach never offers any OMG surprises as the Arduino does since adding one instruction in that environment can pull in an external support library that causes a significant jump in uC program storage requirements.
The reader is left to ponder this: I am certain that ATmel and PIC folks will remain in their respective encampments. But from a hobby programming perspective, both are equally interesting and capable. While the Arduino is often stated as more expensive for projects, this is actually not the case (opinion) since with some effort, the programmer can avoid the use of the bootloader and can avoid the use of the external crystal. The PICAXE is often described as a beginners environment, but I (opinion) disagree since many complex projects can be easily supported by these chips.
- Ray