Leonardo芯片是用USB通信的,有一个模拟键盘功能,官方有个Keyboard.h的库,可以用来模拟键盘,可以看到很多人用来做键盘和鼠标之类的,之前在DF看到一个自动记录传感器数据的,可以直接记录成excel或者TEXT格式的。#include
#define NUMBER_OF_SENSORS 6
#define PREHEAT_TIME 2000
#define VoltageSensor A0
#define StatusLED 13
unsigned int Sample_Number = 1;
float Sample_Value;
void Sensor_Init()
{
}
void Take_Sample()
{
for(char channel = 0;channel < NUMBER_OF_SENSORS;channel++)
{
Sample_Value = analogRead(channel);
}
}
void setup()
{
Sensor_Init();
Keyboard.begin();
delay(PREHEAT_TIME);
}
void loop()
{ digitalWrite(StatusLED,HIGH);
Take_Sample();
digitalWrite(StatusLED,LOW);
Keyboard.print(Sample_Number);
Keyboard.print("\t");
for(char cyc = 0;cyc < NUMBER_OF_SENSORS;cyc++)
{
Keyboard.print(Sample_Value);
Keyboard.print("\t");
//delay(20);
}
Keyboard.print("\n");
Sample_Number += 1;
delay(333);
}
这个是记录的是A0~A5通道模拟电压,可以更改为传感器。
接下来才是重点:我程序烧进去之后,创建一个文本,插上电,开始自动记录,恩一切都是那么顺利,然后发现上电就开始自动采集,不好控制,所以自己在程序里加了个外部中断,准备烧程序,然后。。。。
打开IDE,插上wido后,开始在IDE里面记录数据了。。。。卧槽!!!!无法选择端口!!!!烧不进去!!!!!!怎么办!!!!求帮助啊!!!我靠,还有这种操作、??
Leonardo芯片是用USB通信的,有一个模拟键盘功能,官方有个Keyboard.h的库,可以用来模拟键盘,可以看到很多人用来做键盘和鼠标之类的,之前在DF看到一个自动记录传感器数据的,可以直接记录成excel或者TEXT格式的。#include
#define NUMBER_OF_SENSORS 6
#define PREHEAT_TIME 2000
#define VoltageSensor A0
#define StatusLED 13
unsigned int Sample_Number = 1;
float Sample_Value;
void Sensor_Init()
{
}
void Take_Sample()
{
for(char channel = 0;channel < NUMBER_OF_SENSORS;channel++)
{
Sample_Value = analogRead(channel);
}
}
void setup()
{
Sensor_Init();
Keyboard.begin();
delay(PREHEAT_TIME);
}
void loop()
{ digitalWrite(StatusLED,HIGH);
Take_Sample();
digitalWrite(StatusLED,LOW);
Keyboard.print(Sample_Number);
Keyboard.print("\t");
for(char cyc = 0;cyc < NUMBER_OF_SENSORS;cyc++)
{
Keyboard.print(Sample_Value);
Keyboard.print("\t");
//delay(20);
}
Keyboard.print("\n");
Sample_Number += 1;
delay(333);
}
这个是记录的是A0~A5通道模拟电压,可以更改为传感器。
接下来才是重点:我程序烧进去之后,创建一个文本,插上电,开始自动记录,恩一切都是那么顺利,然后发现上电就开始自动采集,不好控制,所以自己在程序里加了个外部中断,准备烧程序,然后。。。。
打开IDE,插上wido后,开始在IDE里面记录数据了。。。。卧槽!!!!无法选择端口!!!!烧不进去!!!!!!怎么办!!!!求帮助啊!!!我靠,还有这种操作、??