vs2016编程c++程序,实现对arduino传输字符串通信

本文介绍了如何使用VS2013编程C++程序来与Arduino 2560开发板进行字符串通信。通过电脑作为上位机,实现对Arduino开发板的单向数据传输。在VS中创建空白项目,并粘贴特定代码以实现通信功能。

 vs2013编程c++程序,实现对arduino传输字符串通信

ps:用电脑作为上位机,arduino2560开发板作为下位机,实现上位机对下位机进行单向数据传送。

vs编程:

在vs里创建空白项目,直接将下列代码复制进去即可

// ConsoleApplication5.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include"iostream"
#include <stdio.h> 
#include <tchar.h> 
#include <string> 
#include<stdio.h>
using namespace std;

////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef SERIALCLASS_H_INCLUDED
#define SERIALCLASS_H_INCLUDED
#define ARDUINO_WAIT_TIME 2000
#include <windows.h>
#include <stdlib.h>

class Serial
{
private:
	//Serial comm handler
	HANDLE hSerial;
	//Connection status
	bool connected;
	//Get various information about the connection
	COMSTAT status;
	//Keep track of last error
	DWORD errors;

public:
	//Initialize Serial communication with the given COM port
	Serial(const char *portName);
	//Close the connecti
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值