Arduino Mega 2560
The Arduino Mega 2560 is based on the Atmel ATmega2560 processor running at 16 MHz, which provides 256 Kbytes of program memory, 8 Kbytes of RAM, and 4 Kbytes of EEPROM. I've tested uLisp with an official Arduino Mega 2560 board:
Also with a Chinese equivalent :
The Arduino Mega 2560 has an orange LED connected to the digital pin 13 which you can flash with the following program:
(defun blink (&optional x) (pinmode :led-builtin :output) (digitalwrite :led-builtin x)
(delay 1000) (blink (not x)))
Run it by typing:
On the Arduino Mega 2560 pin 13 can also be used as an analogue pin, so you can pulsate the orange LED slowly on and off with the program:
(defun pulse () (let (down) (loop (dotimes (x 256) (delay 5) (analogwrite :led-builtin (if down (- 255 x) x)))
(setq down (not down)))))
Run it by typing:
Exit from either program by entering ~.
The Arduino Mega 2560 has 16 analogue inputs which you can access on digital pins 0 (A0) to 15 (A15). They have 10-bit precision.
You can use analogreference to set the reference voltage for the analogue inputs:
|:default||Default internal reference of 5 volts|
|:internal||Internal reference of 1.1 volts|
|:external||Voltage applied to the AREF pin (0 to 5V only)|
You can generate an analogue output using PWM on any of the digital pins 2 to 13 or 44 to 46. The precision is 8 bits.
You can use the note function to play tunes on pins 9 or 10. For example, the following function scale plays the scale of C on the specified pin:
(defun scale (pin) (mapc (lambda (n) (note pin n 4) (delay 500)) '(0 2 4 5 7 9 11 12)) (note))
For example, connect a piezo speaker between digital pin 10 and GND, and evaluate:
The Arduino Mega 2560 has four serial ports:
|Port 0 (RX, TX)||Port 1 (RX, TX)||Port 2 (RX, TX)||Port 3 (RX, TX)|
|0, 1||19, 18||17, 16||15, 14|
By default the baud rate is 9600.
The Arduino Mega 2560 has one SPI port on pin numbers 50 (MISO), 51 (MOSI), and 52 (SCK). The clock can be between 125 kHz and 8 MHz.
The Arduino Mega 2560 has one I2C port on pin numbers 20 (SDA) and 21 (SCL).
Crius All in One Pro
Another interesting Arduino-compatible ATmega2560-based board is the Crius All In One Pro, intended for use as a multicopter controller. It's an ideal platform for running uLisp, and could form the basis for uLisp robot and control projects:
It fits on a board just 2" (5cm) square, and is available from many sites at about £25 or $35. I bought mine from Aliexpress , but it is also available on Banggood  and eBay.
The board includes USB, I2C, SPI, and serial interfaces, all of which are brought to connectors at the edge of the board. Most suppliers include a set of cables to allow you to connect to each interface.
It is supplied with a bootloader already installed, and you can program it via the USB port by setting the Board option to Arduino/Genuino Mega or Mega 2560 in the Arduino IDE.
The board includes several interesting sensors, including an MPU-6050 accelerometer and gyro, a HMC5883L 3-axis digital magnetometer, a MS5611-01BA01 high precision altimeter, and an SPI serial memory which could be used for data logging.
The Crius board has red, blue, and green LEDs labelled A, B, and C connected to the digital pins 13 , 31, and 30 respectively which you can flash in sequence with the following program:
(defun blink () (let ((x 0) (pins '(13 31 30))) (mapc pinmode pins '(:output :output :output)) (loop (digitalwrite (nth x pins) :low) (setq x (mod (1+ x) 3)) (digitalwrite (nth x pins) :high) (delay 1000))))
Run it by typing:
- ^ Mega 2560 R3 on Banggood.
- ^ Crius All In One Pro v2.0 AIOP RC Multi-Copter Flight Control Board on Aliexpress.
- ^ Crius All In One Pro v2.0 Multi-Copter Flight Control Board on Banggood.