Servo Motor as Input Device

12 02 2008

Servo motor is very useful in robotic. I used servo motors to create few robots in the past. But I never think of using servo motor as input device, and mahto did it. Making servo motor as input device, you can now record the position of the servo motor and play it back the sequence of actions afterward.

Idea Of: Mahto.

Working with AVR-gcc, tiny13, STK500 on a Mac.

11 02 2008

First, install the packages (avr-gcc, binutils etc) for compiling/linking AVR programs in Mac OS X. I followed the instruction here: Programming an AVR microcontroller

Afterward, it is time to start my first led program in C.

I decide to use PB0 as led output, I connect the PB0 to Led0 on STk500 to start this testing program quickly.

#include <avr/io.h>
#define F_CPU 120000
#include <util/delay.h>
int main (void)

// set PB.0 as output pin

DDRB  = 0x01;

// set PB.0 to output high

PORTB = 0x01;

while (1) {

PORTB ^= 0x01;




Compile the program:

avr-gcc led_blink.c -o led.elf -mmcu=attiny13

Convert the elf format to hex format for flashing to the Tiny13:

avr-objcopy -O ihex led.elf led.rom

Prepare avrdude for Mac to flash program and find out the serial port device name on your Mac OS X. I am using usb2serial adapter, the serial port device is /dev/cu.usbserial and connected to stk500 RS232 CTRL port with the serial cable provided in stk500 kit.

avrdude -p t13 -c stk500v2 -P /dev/cu.usbserial -e -U flash:w:led.rom

If it programs successfully, you will see the LED0 is flashing on STk500 board.

Programming AVR ATtiny13 with STK500

11 02 2008

The STK500 comes with a manual with all the instructions for programming the AVR processors. The only problem is that I want to use it to program the AVR tiny13 which is not yet ready when the time the manual was printed. After searching on the web, I found out that the instructions are ready on the help page of the latest AVR Studio for Windows. Finally, I can program my AVR tiny13 with STK500. I am using my Mac to program the AVR tiny13, so I better write it down here. Hope it may help you also.


Step 1 – Place the ATtiny13 (DIP) to the SCKT3400D1.


Step 2 – Connect the ISP6PIN socket to SROG1 with the 6-pin cable provided.


Step 3 – Connect the PORTE/RST to PORTB/PB5 and also PORTE/XT1 to PORTB/PB3. I used the 2 pin cables provided, it is a bit lossy.

Atmel STK500 + AVR Dragon Promotion.

10 02 2008

I bought the STk500 at once when I saw the promotion from Atmel in the year 2007. It was only $49, only the cost of AVR dragon but together with the STK500! It is really a good beginner kit, I want to start with Atmel AVR and particularly the ATtiny processor series, the STK500 is very helpful indeed. It comes with one Atmel 8bit processor(ATMEGA8515L), serial cable, ISP cable (6-pin), and few 2-pin cables for fast prototyping. It can be used to program wide range of the Atmel 8-bit processors, together with Leds, switches for testing your programs on the STK500 board. The only drawback is that you have to use a serial port for programming which is mostly not present in modern computer or notebook, but a usb2serial adapter may help to resolve this problem even on my Mac. The AVR dragon is cool, but for a lazy guy like me that don’t want to construct a socket and also involving many soldering works, I rather stick on the STK500 for my home projects.

STk500/AVR dragon unbox photos


#1 – Arrived.

I ordered from DIGI-key, and this combo kit is marked as out of stock at that time. I back-order the kit and it came faster than I expected.


#2 – STk500 + AVR Dragon


#3 – Close look of AVR Dragon

The Che Kung Temple.

10 02 2008

In Chinese lunar new year, we visit parent, relatives and friends to celebrate the new year. This new year visiting period will start from the 1st day of the new year and continue around 1-2 weeks. There is one day not suitable for visiting, it is the 3rd day of the new year. In tradition, this special day will likely or higher probability to have arguments with the others when you go out. In Hong Kong, many people go to the Che Kung Temple to worship the God “Che Kung” and wish that he gives them good luck in this year. I visited the temple today and it was really crowed. I bought two pinwheels there afterward. Why pinwheel ? it has a special meaning in Chinese too. The pinwheel spins smoothly in the wind, in our word, your life in this year will work smoothly without obstacles, sounds great! ha.


#1 –
You can see many shops selling pinwheel. It is very attractive.
It is one of the tourist attraction in HK too.


#2 – A small one for K.


#3 – A big one for family.

2008 : Year of Rat.

10 02 2008

2008 is the year of rat in Chinese lunar new year. So rat is the theme of all kinds of new year products and also decorations in the shopping mall.  In Addition, red is the theme color as it is the sign of good luck and happiness in Chinese tradition.

Copy 2 photos taken in the shopping mall:



Happy Lunar New Year.

7 02 2008

ice-cream car in Hong Kong.

28 01 2008

When you visit Hong Kong, you may see this car on the street selling ice-cream.
In old days, there were not so many places selling ice-cream, the people in my age should understand how happy to see it on the street and successfully asked your mum or dad to buy you an ice-cream. The ice-cream is vanilla favor as I remember. I think nowadays there should be more favors available. This company is the only approved and the last one by Hong Kong government for selling/making ice-cream in car. If this company is coming to the end, you will not see any ice-cream on the street, so you should take a photo with them now 🙂

Salyu – VALON-1

27 01 2008

Just finished watching the film “All About Lily Chou Chou”, Lily chou chou is the singer in the film, so I did few searches on the internet to find out who is she.

She is Salyu, with very good voice, talented singer.

Here is one of my favourite song from her:


Stray cats in Hong Kong.

27 01 2008

When I encountered the stray cats in the park or the street, I will take some shots of them.
With the my new Canon lens f/2.8L 70-200mm, I can easily get them in range. I saw many other stray cats photographs from Japaneses flickr, they all look healthy, not like the one in Hong Kong. May be the stray cats in japan are well treated?

#1 – one of the eye is blind and get wet in cold weather. He is tough.

#2 – this cat is smart, he tries to find a “human” body to get warm.

#3 – this cat is very fat, may be he is the leader here and so get most of the foods.

All photos taken by 400D+2.8L 70-200mm, and only adjusted contrast in photoshop as it is cloudy.

Thanks for watching. Best wishes for the stray cats:)