Kiwamu Okabe and Hongwei Xi. Arduino programing of ML-style in ATS. ML workshop, 2015.
Show greeting message on LCD display that is available at LinkSprite. The source code is found at demo/lcd_greeting/DATS/main.dats.
This project includes ATS code for Book "Getting Started with Arduino".
The ATS code is found at following.
- Example 01: Blinking LED
- Example 02: Turn on LED while the button is pressed
- Example 03C: Turn on LED when the button is pressed
- Example 04: Fade an LED in and out like on a sleeping Apple computer
- Example 05: Turn on LED when the button is pressed. Brightness changes
- Example 06A: Blink LED at a rate specified by the value of the analogue input
- Example 06B: Set the brightness of LED to a brightness specified by the value of the analogue input
- Example 07: Send to the computer the values read from analogue input 0
Hardware: Arduino Uno
- CPU: ATmega328 (Atmel AVR 8-bit)
- Flash ROM: 32 kB
- SRAM: 2 kB
Also you could get compatible boards
Install some packages.
$ sudo vi /etc/apt/preferences.d/avr
Package: avrdude
Pin: version 6.1*
Pin-Priority: 1001
$ sudo apt-get install binutils-avr gcc-avr avr-libc avrdude libgmp-dev
Install gmp package.
$ brew install gmp
Install AVR toolchain http://www.obdev.at/products/crosspack/index.html, and set PATH env.
$ export PATH=$PATH:/usr/local/CrossPack-AVR/bin
$ which avr-gcc
/usr/local/CrossPack-AVR/bin/avr-gcc
Install following package on cygwin.
- git
- gcc-core
- libgc-devel
- libgmp-devel
- make
Install AVR toolchain http://winavr.sourceforge.net/.
T.B.D.
Install ATS2 http://www.ats-lang.org/.
$ tar xf ATS2-Postiats-X.Y.Z.tgz
$ export PATSHOME=`pwd`/ATS2-Postiats-X.Y.Z
$ export PATH=${PATSHOME}/bin:${PATH}
$ tar xf ATS2-Postiats-contrib-X.Y.Z.tgz
$ export PATSHOMERELOC=`pwd`/ATS2-Postiats-contrib-X.Y.Z
$ cd ${PATSHOME}
$ ./configure
$ make
Compile the ATS source code for Arduino.
$ cd arduino-ats/01_blink
$ make
$ file main.elf main.hex
main.elf: ELF 32-bit LSB executable, Atmel AVR 8-bit, version 1 (SYSV), statically linked, not stripped
main.hex: ASCII text, with CRLF line terminators
Connect Arduino board to your PC using USB cable. And run following commands.
$ ls -l /dev/ttyACM0
crw-rw---- 1 root dialout 166, 0 May 8 15:59 /dev/ttyACM0
$ cd arduino-ats/blink_ats
$ make write
avrdude -c stk500v2 -p atmega2560 -b 115200 -P /dev/ttyACM0 -U flash:w:main.hex
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
--snip--
avrdude: verifying ...
avrdude: 2850 bytes of flash verified
avrdude: safemode: Fuses OK (E:00, H:00, L:00)
avrdude done. Thank you.
T.B.D.