Arduino
Osamu Tamura @ Recursion Co., Ltd.
1. Abstract
"Arduino" is a small AVR system with developing environment widely accepted in the world. I implemented the ForCy embedded language processor into it. There are some changes for adjusting to ATmega168 and its 16MHz clock.
Write ForCyAVR.hex into AVR using ISP. Fuse bits are the same (ex:H:L = FA-DD-FF). Auto-start and boot-loading modes are omitted. Set your terminal program to 4800bps-8N1.
2. Circuit
A bar graph LED is added to demonstrate some programs. Transistor is for controlling brightness using PWM.
3. Program
This program flashes a bar graph LED with any patterns.
/* Demo for Arduino LED Flasher */ /* port definition */ 0x23 :PINB 0x24 :DDRB 0x25 :PORTB 0x29 :PIND 0x2a :DDRD 0x2b :PORTD 0xb0 :TCCR2A 0xb1 :TCCR2B 0xb3 :OCR2A 0xb4 :OCR2B /* flash pattern */ "\x00\x10\x08\x04\x02\x01\x01\x00\x00\x00\x00\x00" :ptb "\x00\x00\x00\x00\x00\x80\x80\x40\x20\x10\x04\x00" :ptd "\xff\x28\x24\x20\x18\x14\x14\x18\x20\x24\x28\xff" :wtm "\x00\x04\x10\x40\x80\xff\xff\x80\x40\x10\x04\x00" :vol /* apply next pattern */ ;wait ;limit ;i wait ++ =wait wait limit < nip { return } if 0 =wait i 12 >= { 23 swap - } if dup wtm @s =limit dup vol @s OCR2B =sfr dup ptb @s PORTB =sfr ptd @s 0x08 | PORTD =sfr i ++ 24 >= { . 0 } if =i :intclk /* blink LED on board */ 0x20 PINB =sfr :intsec /* port initialize */ 0x3f DDRB =sfr 0xfc DDRD =sfr 0xff PORTB =sfr 0xff PORTD =sfr 0x21 TCCR2A =sfr 0x01 TCCR2B =sfr 0 OCR2A =sfr 0 =wait 0 =limit 0 =i { intclk intsec } interrupt @c . :mainList 1. Program of the Knight Rider
forcy-arduino.zip ( source, binary, sample 420KB )
17 Jun. 2008