世界角落裡的程式
個人作品展示及工作備忘錄
2011年9月24日 星期六
Arduino:我的遙控器
1.紅外線發射器 x 1
2.Arduino x 1
3.Arduino 網路模組 x 1
4.Android 手機 x 1
5.226歐姆 x 1
Arduino控制紅外線發射器
撰寫Android手機程式送出訊息到Arduino
Arduino:紅外線發射器
參考:
http://coopermaa2nd.blogspot.com/2011/04/22-keypad.html
紅外線發射器長腳為正極,短腳為負極
紅外線發射器
Arduino + 紅外線發射器
Arduino + 紅外線發射器接線圖
Arduino:紅外線接收器
參考:
http://coopermaa2nd.blogspot.com/2011/04/22-keypad.html
接收結果 .....如下:
音量大聲
Protocol: SONY
irCode: 490, bits: 12
Protocol: SONY
irCode: 490, bits: 12
Protocol: SONY
irCode: 490, bits: 12
音量小聲
Protocol: SONY
irCode: C90, bits: 12
Protocol: SONY
irCode: C90, bits: 12
電視開關
Protocol: SONY
irCode: A90, bits: 12
Protocol: SONY
irCode: A90, bits: 12
Protocol: SONY
irCode: A90, bits: 12
頻道選上
Protocol: SONY
irCode: 90, bits: 12
Protocol: SONY
irCode: 90, bits: 12
頻道選下
irCode: 890, bits: 12
Protocol: SONY
irCode: 890, bits: 12
[1]
Protocol: SONY
irCode: 10, bits: 12
Protocol: SONY
irCode: 10, bits: 12
[2]
Protocol: SONY
irCode: 810, bits: 12
Protocol: SONY
irCode: 810, bits: 12
Protocol: SONY
irCode: 810, bits: 12
[3]
Protocol: SONY
irCode: 410, bits: 12
Protocol: SONY
irCode: 410, bits: 12
Protocol: SONY
irCode: 410, bits: 12
[4]
Protocol: SONY
irCode: C10, bits: 12
Protocol: SONY
irCode: C10, bits: 12
[5]
Protocol: SONY
irCode: 210, bits: 12
Protocol: SONY
irCode: 210, bits: 12
[6]
Protocol: SONY
irCode: A10, bits: 12
Protocol: SONY
irCode: A10, bits: 12
Protocol: SONY
irCode: A10, bits: 12
[7]
Protocol: SONY
irCode: 610, bits: 12
Protocol: SONY
irCode: 610, bits: 12
Protocol: SONY
irCode: 610, bits: 12
[8]
Protocol: SONY
irCode: E10, bits: 12
Protocol: SONY
irCode: E10, bits: 12
Protocol: SONY
irCode: E10, bits: 12
[9]
Protocol: SONY
irCode: 110, bits: 12
Protocol: SONY
irCode: 110, bits: 12
Protocol: SONY
irCode: 110, bits: 12
[0]
Protocol: SONY
irCode: 910, bits: 12
Protocol: SONY
irCode: 910, bits: 12
Protocol: SONY
irCode: 910, bits: 12
[MUTE]
irCode: 290, bits: 12
Protocol: SONY
irCode: 290, bits: 12
Protocol: SONY
irCode: 290, bits: 12
[Enter]
irCode: D10, bits: 12
Protocol: SONY
irCode: D10, bits: 12
Protocol: SONY
irCode: D10, bits: 12
紅外線接收器
Arduino + 紅外線接收器
2011年7月6日 星期三
php配置備註
php5.2.16在win7 64bit下的配置 (需使用到mysql and mcrypt)
php.ini 可放置在原來的目錄下(例如:c:\php5\)
將
libmysql.dll
libmcrypt.dll
copy 到 C:\Windows\SysWOW64
php4在win7 64bit下的配置 (需使用到iconv)
php.ini 可放置在原來的目錄下 (例如:c:\php4\)
將
iconv.dll
copy 到 c:\windows\SysWOW64
2011年1月13日 星期四
C# 執行緒寫法
using System.Threading;
namespace testThread
{
public partial class Form1 : Form
{
private work w1;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
if (w1 == null)
w1 = new work();
}
private void button1_Click(object sender, EventArgs e)
{
// 啟動
if (!w1.State())
w1.Start();
}
private void button3_Click(object sender, EventArgs e)
{
// 停止
w1.Stop();
}
private void button2_Click(object sender, EventArgs e)
{
// 暫停
w1.Pause();
}
private void button4_Click(object sender, EventArgs e)
{
// 繼續
w1.Resume();
}
}
// 執行緒處理
internal class work
{
private ManualResetEvent ThreadControl = new ManualResetEvent(true);
private Thread prog;
public void Pause()
{
// 執行緒暫停
ThreadControl.Reset();
}
public void Stop()
{
// 執行緒停止
ThreadControl.Set();
prog.Abort();
}
public void Resume()
{
// 執行緒繼續
ThreadControl.Set();
}
public void Start()
{
// 執行緒啟動
if (prog == null || !prog.IsAlive)
{
prog = new Thread(run);
prog.Start();
}
}
public bool State()
{
// 執行緒狀態取得
if (prog == null)
return false;
return prog.IsAlive;
}
public void run()
{
// 執行緒工作執行進入點
while (true)
{
Thread.Sleep(1000); // 閒置時間
// 當 ThreadControl 事件被設為 set 時,讓執行緒進入等待
ThreadControl.WaitOne(-1);
}
}
}
}
// 參考 MSDN
//
http://msdn.microsoft.com/zh-tw/library/system.threading.manualresetevent(VS.80).aspx
首頁
訂閱:
文章 (Atom)