我一直在努力将加速计传感器的数据保存到文本文件中。但在网上搜索了几个小时后,我发现的方法都没有用。这是我现在的程序。
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader?limit=10000&minetype=application/font-woff&name=/[hash].[ext]'
}
我发现的确似乎做了我想要的,问题是Arduino不想运行它,说'import'没有在范围内声明。我已经尝试安装了一些库,但我找不到导入属于的确切库,或者PrintWriter。以下是导致问题的代码:
// Accelerometer sensor program
const int ar1 = A5;
const int ar2 = A4;
const int ar3 = A3;
int x = 0;
int ov1 = 0;
int y = 0;
int ov2= 0;
int z = 0;
int ov3= 0;
void setup() {
// initialize the communications
Serial.begin(9600);
}
void loop() {
analogReference(EXTERNAL); //connect 3.3v to AREF
// X axis
// Read the analog
x = analogRead(ar1);
// Range of analog out
ov1 = map(x, 0, 1023, 0, 255);
delay(2);
// Y axis
y = analogRead(ar2);
ov2 = map(y, 0, 1023, 0, 255);
// Z axis
delay(2);
z = analogRead(ar3);
ov3 = map(z, 0, 1023, 0, 255);
// Should print to the monitor
// Output for X axis
Serial.print("Xsensor1 = " );
Serial.print(x);
Serial.print("\t output1 = ");
Serial.println(ov1);
// Output for Y axis
Serial.print("Ysensor2 = " );
Serial.print(y);
Serial.print("\t output2 = ");
Serial.println(ov2);
// Output for Z axis
Serial.print("Zsensor3 = " );
Serial.print(z);
Serial.print("\t output3 = ");
Serial.println(ov3);
// Should repeat every second
delay(1000);
提前致谢。
答案 0 :(得分:0)
您拥有的代码不适用于Arduino,而是使用名为Processing的语言编写。它将在您的PC上运行并从Arduino收集数据以保存到文件中。您需要下载Processing IDE来编译代码并运行它。