2013-03-27 58 views

回答

2

簡單地說,答案是肯定的,這是可能的。真正的問題是:如何?我假設你已經有written you first Android app with Mono

接下來,你需要決定你將如何將Android設備連接到Arduino。 BluetoothWi-Fi?網?

其次,它只是使用適當的Android API的問題。檢查出Xamarin documentation for Android

更新

很多比我下面要介紹更多的是可用的ported MonoDroid sample applications。具體來說,你會對BluetoothChat example感興趣。

確保你也看看adding permissions清單文件,當然,在Android Developer Guide for Bluetooth

這就是說,這裏有一個小小的東西,讓你開始,基於Android Quick Look: BluetoothAdapter

txtStatus.Text = "Getting Bluetooth adapter..."; 
BluetoothAdapter bluetooth = BluetoothAdapter.DefaultAdapter; 
if(bluetooth == null) 
{ 
    txtStatus.Text = "No Bluetooth adapter found."; 
    return; 
} 

txtStatus.Text = "Checking Bluetooth status..."; 
if (!bluetooth.IsEnabled) 
{ 
    Toast.MakeText(this, "Bluetooth not enabled. Enabling...", 
     ToastLength.Short).Show(); 
    bluetooth.Enable(); 
} 

if (bluetooth.State == State.On) 
{ 
    txtStatus.Text = 
     "State: " + bluetooth.State + System.Environment.NewLine + 
     "Address: " + bluetooth.Address + System.Environment.NewLine + 
     "Name: " + bluetooth.Name + System.Environment.NewLine; 
} 
else 
{ 
    txtStatus.Text = "State: " + bluetooth.State; 
} 
+0

謝謝來回答案。是的,我已經在使用服務器進行數據傳輸的單聲道應用程序。我更喜歡與藍牙連接...我檢查了類,我注意到[Android.Bluetooth](http://androidapi.xamarin.com/index.aspx?link=root%3a%2fMonoAndroid-lib)類(我沒有但是我的「恐懼」是因爲我無法在google中找到任何例子,所以爲什麼我問你是否嘗試過使用mono + arduino做過一個項目 – Pennas 2013-03-27 10:51:07

+0

我知道這不是'您可能想要了解如何使用Android API(Java)以及C#中的等效代碼,如果您願意,可以在幾個小時內發佈示例代碼你已經使用藍牙與Arduino了嗎? – 2013-03-27 11:42:55

+0

沒有嘗試過,我已經將它控制爲.exe(windows窗體應用程序)並手動使用LCD屏幕,我的下一步是用藍牙誠實地控制它。我正在使用C#來創建連接,我不知道我是否可以像android應用程序一樣使用單聲道droid ..(所以任何例子它將是非常有用的)。預先感謝您 – Pennas 2013-03-27 12:06:22

相關問題