Saturday, May 5, 2007

Pong game!

這禮拜咱們<被網路連結的物件們>(英譯: Networked Objects)課程assignment狠過癮! 要來玩弄電玩史上經典之一的Pong game! (聽起來好像porn game, 對不起發音太差)
I've never seen a so crowded classroom! The ethernet cables are insanely crawling throughout the table. I barely squeeze into the crowd and share the tiny space with Greg. Crazy but fun!

Tom老吩咐到時候班上會分兩組, 屆時就了無新意但也最快速地 "左半邊 versus 右半邊", 玩法是一個緊接一個的pk制, 某人輸了之後, 他那組的下一位選手就立刻連上server為隊友報仇!

基本上大家都用一樣的code, 小改當中幾行analog in/digital in(聽了去年修課的Josh兄建議, 決定採取比較不會出槌的digital switch), 然後花了好大部分時間處理莫名其妙的蠢網路問題
serial monitor都看的到Arduino的訊息, 但Terminal就是看不到, 後來發現似乎是犯了極為愚蠢的失誤(RX,TX接錯地方,碼的賀!) ... 總之也終於算成功, 沒有喇賽!

physical interface沒有花太多時間包裝, 只是用了簡單的(地上撿到的垃圾)小木塊, 挖洞, switch擠進去, wires拉出來, hook up到breadboard上, 大功告成! 操控方法如下:
(1) 狠焦慮地拿木塊不斷敲桌面, 敲左面-->paddle往左跑, 敲右面-->paddle往右跑
(2): 把小木塊輕巧地拿起置於鼻樑, 下巴中間, 利用左右兩手食指靈巧地壓左右兩面switch, 如同發呆雙手脫住下巴的無聊小gesture舉動, 然後, 輕鬆獲勝(一切都是幻想)!

Basically we are using the same code from Tom. The only thing we have to deal with is a small change of analog/digital input. I chose the digital instead of analog input due to some suggestion form Josh who took this class in the last semester. From his saying, digital input could get more stable and continuous move of your pong paddle than analog (Actually it depends on how you write your code). Though getting a big help from Josh, I still struggled with the never-expectable hardware part. At the beginning, the signal only appeared on the serial monitor but terimanl. It took me a while to figure out that I shouldn't have hooked up the Xport's RX and TX to FT232R's TX and RX. Instead, they should go to arduino's TX and RX since FT232R in my circuit only did a job of providing 3.3V power and did nothing about transferrinf/receiving data. What a silly mistake!

Here is the circuit i got:

The physical interface: a small block with 2 switches locate seperately inlayed into its right and left surfaces.

Playing with the block:

This video shows all steps of logging in/out the pong game server. Instead of really receiving/transferring data from/to the server, I fake it by typing comments in Terminal for a rehearsal test. 'C' means that the server sends a connection signal through Xport to arduino (in real playing, the connection is automatically made once i plug the Ethernet cable into Xport), and then I press a connect button on my breadboard to start the game. Several lines of 'C128.122.151.128/8080' instantly jumps up. Next step is to simulate the control of pong paddle. Pressing right button (R side of the block facing down) appears 'r' on Terminal screen while left button shows 'l'. Once I press the connection button again, I lose the connection and 'x' jumps out, which means sending a signal to ask the server to quit. DONE!

See more pictures of presentation at Guy's flickr and Mike's flickr.

Saturday, April 21, 2007

Better Bin presentation!

Here is the content of our final presentation:

Recycling bins are important!
1 ton of recycled paper = 17 saved trees
117 lbs recycled paper = 1 saved tree

How can we encourage the use of recycling bins?
Give the user feedback and Make it more fun
- Show them their current contribution
- Display total trees saved by using this bin

Hence... the Better Bin
Lets users know they are REALLY making a difference

The hardware:
Platform (made out of wood. lol!)
(show pictures of platform)

4 FSR sensors
Arduino + Xport

The Pseudo Code:
Code runs every 30 seconds:(actually it's 10 seconds while in presentation's demo)
Arduino gets latest value (weight) inserted into DB
If current weight in bin is > latest value, update db with new value and timestamp
This is our daily scratchpad
At the end of the day, this latest bin value is inserted into a new table called DAYS
Similarly, at the end of the month, all values from last month are entered into a separate monthly table as well.
So at anytime we can reference the LATEST, DAILY, MONTHLY or TOTAL recycled weight.

The Visualization:
Flash & Actionscript
This is our elegant, visual compensation for good recycling habits.
(show picture and explain how visualization works)

Thank you!

Sunday, April 15, 2007

Recycle bin saves trees?!

Greg and Guy are working on a great, meaningful and so environmental issue project! (Wow, it's so not my style) Basically the idea is to weigh the recycle bin on the floor by couple sensors and send the data onto a database.