2015年5月6日 星期三

Arduino IDE -Sulime Text 2

除了Arduino原廠IDE以外,現在還有另外一個選擇Sulime Text 2
 

1.下載Sulime Text
Sulime Text 官方載點
Sulime Text 2
http://www.sublimetext.com/2
Sulime Text 3
http://www.sublimetext.com/3

2.安裝package control
Sulime Text 有相當多的package可以使用,而package control就可以方便的管理這些package。

https://packagecontrol.io/installation
開啟Sulime Text 後 使用 Ctrl+` 在下方命令列入

Sulime Text 2輸入下串
import urllib2,os,hashlib; h = 'eb2297e1a458f27d836c04bb0cbaf282' + 'd0e7a3098092775ccb37ca9d6b2e4b7d'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler()) ); by = urllib2.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); open( os.path.join( ipp, pf), 'wb' ).write(by) if dh == h else None; print('Error validating download (got %s instead of %s), please try manual install' % (dh, h) if dh != h else 'Please restart Sublime Text to finish installation') 

Sulime Text 3輸入下串 
import urllib.request,os,hashlib; h = 'eb2297e1a458f27d836c04bb0cbaf282' + 'd0e7a3098092775ccb37ca9d6b2e4b7d'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by) 

完成後 重新開啟Sulime Text 即完成安裝package control

3.安裝Arduino like-IDE
 a.開啟Sulime Text 按下組鍵Ctrl+Shift+P
 b.輸入install package 並稍做等待
 c.輸入Arduino like-IDE 並點選安裝


4.指定 Application 
安裝好Arduino like IDE 後
在工作列最左方會出現 Arduino 的選項
選擇 Perferences->Selest Arduino Application Folder
選擇Arduion 官方 IDE 安裝位置

接下來就可以正常使用拉~~

2015年3月11日 星期三

ATTINY85

 

 

 

轉http://www.instructables.com/id/Digispark-DIY-The-smallest-USB-Arduino/

Digispark is an ATtiny85 based microcontroller development board come with USB interface. Coding is similar to Arduino, and it use the familiar Arduino IDE for development.

Digispark is copyrighted by Digistump LLC (digistump.com) and the full license is here: http://digistump.com/wiki/digispark/policy

Specification:
Support for the Arduino IDE 1.0+ (OSX/Win/Linux)
Power via USB or External Source - 5v or 7-35v (automatic selection)
On-board 500ma 5V Regulator
Built-in USB (and serial debugging)
6 I/O Pins (2 are used for USB only if your program actively communicates over USB, otherwise you can use all 6 even if you are programming via USB)
8k Flash Memory (about 6k after bootloader)
I2C and SPI (vis USI)
PWM on 3 pins (more possible with Software PWM)
ADC on 4 pins
Power LED and Test/Status LED (on Pin0)

 

Step 1: Prerequisite

AVRISP MKII In-System Programmer
ATTINY85 Microcontroller
2 x 3.6V zener diode
2 x 68 ohm resistor
1 x 1.5K resistor
USB cable (get from broken mouse or keyboard)
Some wires



Step 2: Burning bootloader to ATTINY85

Like Arduino, Digispark require a bootloader to be running on ATTINY85. The bootloader will occupied 2KB flash memory.

Download bootloader
1. Download Micronucleus bootloader for ATTINY85
2. Extract the file (micronucleus-t85-master.zip) to any folder
3. You can find the bootloader file at micronucleus-t85-master\firmware\releases folder
4. Use micronucleus-1.06.hex for the bootloader

Burning bootloader to ATTINY85
You must use the correct fuses bit for the bootloader

Extended: 0xFE
High: 0xDD
Low: 0xE1

Note: The above fuse bit will not enable reset as I/O, so you can have only 5 I/O instead of 6 I/O. I'm still try to figure out on how to set it to 6 I/O

I'm using AVRISP MKII In System Programmer and AVR Studio software for burning bootloader.


Step 3: Installing Digispark USB driver

Digispark use USB to communicate with computer, so your computer must install Digispark USB driver
1. Download Arduino for Digispark which come with USB driver
2. Extract the file (DigisparkArduino-Win32-1.0.4-March29.zip)  to any folder
3. Execute DigisparkArduino-Win32\DigisparkWindowsDriver\InstallDriver.exe to start installing the USB driver

2015年3月9日 星期一

Arduino DC motor - DIY自走車(1)前進後退



從網路上購入自走車車架,

使用壓克力板組成,
搭上3VDC的直流馬達與減速模組構成,
MotorShield 模組相關資料,
http://playground.arduino.cc/Main/AdafruitMotorShield
可同時推動2組步進馬達 或 四組DC馬達正反轉,

亦可推動,兩組伺服馬達,伺服馬達與步進馬達似乎沒辦法同時運作,
在這模組板上 ,
下連結為 模組板library,
https://github.com/adafruit/Adafruit-Motor-Shield-library

 


組裝完成正面
組裝完成背面
 以下為簡單程式碼
動作為前進1000ms,後退1000ms,然後停止1000ms,
然後持續循環,
有遭遇到電流不夠帶動3VDC馬達,因原先使用1.5V充電電池*4,
雖然Arduino可以運作,但在帶動馬達時發出滋滋的聲響,
後改用電源供應器推動,馬達才有動作,馬達的瞬間電流大約落在1A。






後續還需要整合伺服馬達與超音波模組,
完成障礙辨識,
再掛上通訊模組,目前考慮使用wifi或是bluetooth模組,
但如果使用wifi模組,電池電量將是一個問題。
完成通訊之外還要加上cmd才能使用手機或者是電腦去控制自走車,
並請自走車回報狀況。

後續再將進度補上。