我正在试着做一个程序,它必须上传一个Arduino文件(.ino)通过按下一个按钮的窗口窗体。我看了一下怎么做,发现有一个名为"ArduinoUploader“的包,但我想我不明白如何使用它。当我按下按钮"System.NullReferenceException:'Reference to an object not to a object instance‘时,它会给我这个错误。“下面是我使用的代码:
using ArduinoUploader;
using ArduinoUploader.Hardware;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
private void SelectProgramButton_Click(object sender, EventArgs e)
{
var uploader = new ArduinoSketchUploader(
new ArduinoSketchUploaderOptions()
{
FileName = @"C:\Users\.....\Desktop\cscharp\.....\.....\TEST.ino",
PortName = "COM3",
ArduinoModel = ArduinoModel.Mega2560
});
uploader.UploadSketch();
}请帮我把它修好。谢谢。
发布于 2021-05-14 17:25:49
你有没有检查过正确的端口(如果arduino已经在使用串行监视器或者其他类似的端口,通常没有其他东西可以访问它,->在将数据保存到.txt时有问题)和正确的Arduino型号?我遇到过老的arduino主板的问题,因为他们有时不能正确地上传代码,因为你必须选择“作为传统上传”(不是100%确定它是这样叫的)选项,这样它才能与旧的格式兼容。
https://stackoverflow.com/questions/67531037
复制相似问题