Arduino/ 樹梅派 Raspberry Pi/ 物聯網 專題/小專案開發 /教學,亦或系統整合
-物聯網熱影像偵測系統
-荷重藍牙傳輸顯示系統
-氣體管路壓力流量控制
-電磁閥控制系統
-量測資料擷取/監控
PC人機介面開發/ Android簡易APP
AR/VR 小專案開發
Zenbo機器人 群控/APP/教學
自動控制/影像處理/有限元素分析
有任問題歡迎來信詢問,依據需求與經費提供客製化:
Arduino/ 樹梅派 Raspberry Pi/ 物聯網 專題/小專案開發 /教學,亦或系統整合
-物聯網熱影像偵測系統
-荷重藍牙傳輸顯示系統
-氣體管路壓力流量控制
-電磁閥控制系統
-量測資料擷取/監控
PC人機介面開發/ Android簡易APP
AR/VR 小專案開發
Zenbo機器人 群控/APP/教學
自動控制/影像處理/有限元素分析
有任問題歡迎來信詢問,依據需求與經費提供客製化:
透過 = 傳遞資料的過程中,感覺是等同於 assign ,是將List的位址複製到另一個List,所以當其中一個清除,其數值就會消失。
若要複製其內容,可以改由 list_03的作法。
List<double> list_01 = new List<double>();
List<double> list_02 = new List<double>();
List<double> list_03;
//加入 1~ 10 數值
for (int i = 0; i < 10; i++) {
list_01.Add(i + 1);
}
// list_01總合55
TestShow("list_01 sum ="+list_01.Sum().ToString());
list_02 = list_01; //指派
// list_02總合55
TestShow("After list_02=list01 , list02 sum ="+list_02.Sum().ToString());
list_03 = new List<double>(list_01);
TestShow("After list_03=new List<double>(list_01) , list03 sum ="+list_03.Sum().ToString());
list_01.Clear();
TestShow("After list_01 clear() , list02 sum =" + list_02.Sum().ToString()); // 0
TestShow("After list_03 clear() , list03 sum =" + list_03.Sum().ToString()); // 55
C# Windows form 並沒有內建Inputbox,我以前的做法是透過另一個Form來當作輸入視窗。
後來找到兩個不錯的方法,提供參考。
<方法一>使用Microsoft.VisualBasic.dll
01.方案上案右鍵→加入→參考
02.找到Microsoft.VisualBasic →勾選→確定
03.加入 using Microsoft.VisualBasic;
04.在Button加入底下程式
string input_str;
input_str = Interaction.InputBox("請輸入數值", "提示", "");
if (string.IsNullOrEmpty(input_str))
{
return;
}
else
{
MessageBox.Show(input_str,"資訊", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
05.結果:
<方法二>使用System.Windows.Forms.dll
和 System.Drawing.dll
。
01.同方法一,加入兩個參考。
02.加入using
using System;
using System.Windows.Forms;
using System.Drawing;
03.測試底下程式碼
加入底下的方法
private static DialogResult ShowInputDialogBox(ref string input, string prompt,
string title = "Title", int width = 300, int height = 200)
{
// This function creates the custom input dialog box by individually creating the different
// window elements and adding them to the dialog box
// Specify the size of the window using the parameters passed
Size size = new Size(width, height);
// Create a new form using a System.Windows Form
Form inputBox = new Form();
inputBox.FormBorderStyle = FormBorderStyle.FixedDialog;
inputBox.ClientSize = size;
// Set the window title using the parameter passed
inputBox.Text = title;
// Create a new label to hold the prompt
Label label = new Label();
label.Text = prompt;
label.Location = new Point(5, 5);
label.Width = size.Width - 10;
inputBox.Controls.Add(label);
// Create a textbox to accept the user's input
TextBox textBox = new TextBox();
textBox.Size = new Size(size.Width - 10, 23);
textBox.Location = new Point(5, label.Location.Y + 20);
textBox.Text = input;
inputBox.Controls.Add(textBox);
// Create an OK Button
Button okButton = new Button();
okButton.DialogResult = DialogResult.OK;
okButton.Name = "okButton";
okButton.Size = new Size(75, 23);
okButton.Text = "&OK";
okButton.Location = new Point(size.Width - 80 - 80, size.Height - 30);
inputBox.Controls.Add(okButton);
// Create a Cancel Button
Button cancelButton = new Button();
cancelButton.DialogResult = DialogResult.Cancel;
cancelButton.Name = "cancelButton";
cancelButton.Size = new Size(75, 23);
cancelButton.Text = "&Cancel";
cancelButton.Location = new Point(size.Width - 80, size.Height - 30);
inputBox.Controls.Add(cancelButton);
// Set the input box's buttons to the created OK and Cancel Buttons respectively so the window
// appropriately behaves with the button clicks
inputBox.AcceptButton = okButton;
inputBox.CancelButton = cancelButton;
// Show the window dialog box
DialogResult result = inputBox.ShowDialog();
input = textBox.Text;
// After input has been submitted, return the input value
return result;
}
04.呼叫
string test = ""; // 回傳值
ShowInputDialogBox(ref test, "你今天學會了嗎?", "標題", 300, 200);
// Print the input provided by the user
Console.WriteLine(test);
05.結果
<小結>方法一簡單快速,方法二可以客製調整介面。
你今天學會了嗎?
參考文章:
https://www.twblogs.net/a/5c719306bd9eee68440f7184
https://blog.csdn.net/Never_Satisfied/article/details/129666763
https://www.delftstack.com/zh-tw/howto/csharp/create-an-input-dialog-box-in-csharp
dataRead = serialPort1.ReadExisting(); //會包含換行符號,但不是一行一行讀出,變成要自己判斷分行
EX: 123456789 /n =>
123
4567
8
9
(不一定數量)
dataRead = serialPort1.ReadLine(); //if using readline needs "\n" for changing line
電路可靠度分析是評估電子系統或電路在特定條件下正常運作的能力,以及在面對各種故障或失敗情況時維持運作的能力。這涉及到對電子元件、連接和整個電路的可靠性進行評估和分析。以下是一些電路可靠度分析的主要方面:
在進行電路可靠度分析時,可以使用各種工具和技術,包括模擬軟體、可靠度模型、數據統計方法等。這些分析有助於確保電子系統在各種條件下都能保持穩定和可靠的運作。
來源:網路
在沒有設限的情況,可以透過軟體或硬體解決開關(SPST)訊號彈跳的問題。
透過簡單的電路,就可以省下後面透過軟體解彈跳的時間。
參考文章:
https://www.digikey.tw/zh/articles/how-to-implement-hardware-debounce-for-switches-and-relays
by noodlejay
開發環境:VS2019
作業系統:Win10
Excel版本:2010
加入參考Microsoft.Excel.14.Object.Library
加入namespace
using Microsoft.Office.Interop.Excel;
參考文章:
1.設定換行 NL&CR、BaudRate:9600 (每個模組可能不同)。
2.傳送指令"AT",正確的話就會收到"OK"。
1.X軸接受的資料格式包含DateTime。
2.設定Series的XValueType為DateTime。 (預設應該為Double)
3.設定X軸LabelStyle的Format格式,例如 “HH:mm:ss" // 小時:分:秒