25
Harder way to Arduino with Python 17 March 2013 Homin Lee

Harder way to arduino

Embed Size (px)

Citation preview

Page 1: Harder way to arduino

Harder way to Arduinowith Python17 March 2013

Homin Lee

Page 2: Harder way to arduino

About me

주로 C/C++을 쓰며 Python을 서브로 사용해 왔습니다.

취미로 아두이노를 사용한 전자공작을 합니다.

Page 3: Harder way to arduino

Me about Arduino

한글시계, HUMA, 점자프린터, etc...

손에잡히는 아두이노, 인사이트 역자

Page 4: Harder way to arduino

Will talk about...

Arduino

Python and pyserial

Scons

Arduino + scons = arscons

Page 5: Harder way to arduino

Arduino

Page 6: Harder way to arduino

arduino.cc

Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's intended for artists, designers, hobbyists, and anyoneinterested in creating interactive objects or environments.

Page 7: Harder way to arduino

Hello physical world!

반짝 반짝 작은~ LED~

#define PIN_LED 13

void setup(void){ pinMode(PIN_LED, OUTPUT);}

void loop(void){ digitalWrite(PIN_LED, HIGH); delay(1000); digitalWrite(PIN_LED, LOW); delay(1000);}

Page 8: Harder way to arduino

What happed?

스케치를 C++ 코드로 변환

컴파일 avr-gcc

업로드 avrdude

Page 9: Harder way to arduino

Want more?

File -> Examples

Page 10: Harder way to arduino

Serial

Page 11: Harder way to arduino

Serial monitor

포트와 속도를 설정하고 시리얼 모니터를 여세요.

Page 12: Harder way to arduino

pyserial

#!/usr/bin/python

import osimport sysimport serial

try: serPort = sys.argv[1] serSpeed = sys.argv[2]except: print "Usage: %s port speed"%sys.argv[0] sys.exit(1)

ser = serial.Serial(serPort, serSpeed)for line in ser: print line.strip()

ser.close()

Page 13: Harder way to arduino

Scons

Page 14: Harder way to arduino

SConstruct

make : Makefile = scons : SConstruct

SConstruct:

Program("hello", "hello.cpp")

Build:

$ scons

Clean:

$ scons -c

Page 15: Harder way to arduino

arscons: Arduino + Scons

Page 16: Harder way to arduino

Why?

커맨드라인에서 아두이노 스케치를 빌드할 방법 필요

스케치 업로드 과정 수정 필요

아무도 안 하네?

Page 17: Harder way to arduino

After years... what happened then?

200여 줄 -> 400여 줄

Supprot Mac

Supprot Windows

Support Arduino v1.0

Support all? veriants

v1.0 release

Page 18: Harder way to arduino

Hello arscons

github.com/suapapa/arscons (https://github.com/suapapa/arscons)

다운로드:

$ git clone https://github.com/suapapa/arscons$ cd arscons$ tree.├── README.md├── SConstruct└── arscons.ino

빌드 & 업로드:

$ scons$ scons upload

Page 19: Harder way to arduino

Use it for your project, awesome

arscons를 clone 한 후 remote 를 변경:

$ git clone https://github.com/suapapa/arscons awesome$ cd $_$ git remote rename origin arscons

아두이노 스케치는 폴더 이름과 같아야 합니다:

$ git mv arscons.ino awesome.ino$ git commit -m "Initial commit of awesome"

지금까지 문제가 없는지 확인:

$ scons && scons upload

Page 20: Harder way to arduino

Project awesome continue. add third-party library

아두이노 라이브러리를 git submodule로 연결하면 편리합니다. 예;

$ git submodule add https://github.com/suapapa/arduino_library_tm1638 \ libs/tm1638

GH에 프로젝트를 열고, 지금까지의 작업을 push 합니다:

$ git remote add origin https://github.com/you/awesome$ git push origin -u master

편집기로 awesome.ino를 열어 awesome을 구현하세요.

Page 21: Harder way to arduino

Project awesome continue. build & upload

라이브러리 디렉터리를 지정해 빌드합니다.

$ EXTRA_LIB=libs scons upload

현재까지의 작업으로 다음과 같은 디렉터리구조가 생겼습니다.

$ tree -d.├── build│ ├── core│ └── lib_01│ └── tm1638└── libs └── tm1638

Page 22: Harder way to arduino

Demo

Play LKM1638 module with Arscons

LKM1638, dx.com (http://dx.com/p/8x-digital-tube-8x-key-8x-double-color-led-module-81873)

tm1638-library (https://code.google.com/p/tm1638-library/)

Page 23: Harder way to arduino

References

Arduino (http://arduino.cc)

SCons (http://www.scons.org)

pySerial (http://pyserial.sourceforge.net/pyserial.html)

Page 24: Harder way to arduino

More links and books (kor)

MAKE:Korea (http://www.make.co.kr/)

Making Insight (http://www.insightbook.co.kr/books/making-insight)

Make Magazine (kor) (http://www.make.co.kr/?page_id=1487)

Page 25: Harder way to arduino

Thank you

Homin Lee@suapapa (http://twitter.com/suapapa)