激光Harp脚本错误与Arduino uno,任何脚本老板我需要你的帮助



几天来,我一直在努力学习arduino脚本,经过无数次的尝试和错误,我设法将其归结为几个错误,但我一辈子都无法弄清楚,我相信这将是一件非常简单的事情。

我已经尽可能多地在网上搜索了,但仍然找不到问题出在哪里。我已经看到了这个网站的好人是多么的优秀,所以我请求你的帮助。

任何帮助都将是惊人的

这是完整的代码。。。

#include <Stepper.h>
void setup() {
const int stepsPerRevolution = 400; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on pins 8 through 11:
Stepper beamsplitter(stepsPerRevolution, 8, 9, 10, 11);
int LaserState = LOW; // The variable that stores the state of the laser beam.
int sensor = 8 ; // Change this value to calibrate your harp's sensor
int delaylaser = 2000; // If you increase this, the laser will be brighter, but the harp will be less fluid
int motorspeed = 100; // This variable affects the speed, and fluidity of the harp.
int stepsize = 2; //size between beams
int LaserPin = 7; // Tell the arduino that the laser is on pin 7
int startupspeed = 3;
int pos = 0; // position of the laser
int beams = 12; // number of beams
int pitch;
void setup() {
pinMode(LaserPin, OUTPUT); // Setup for laser.
pinMode(6, OUTPUT); // Setup for status led.
digitalWrite(LaserPin, HIGH);
delay(1500);
//start sequence
beamsplitter.setSpeed(startupspeed);
beamsplitter.step((-beams * stepsize / 2)-1);
for (int x = 1; x < 60; x++) {
if (x<30) {
startupspeed = 103 - (100/pow(x, 1.0/4.5));
}
if (x>=30) {
startupspeed = 103 - (100/pow(x, 1.0/1.0));
}
beamsplitter.setSpeed(startupspeed);
for (int pos = beams; pos > 0; pos--) { // turn in other direction
beamsplitter.step(stepsize); // direction
}
for (int pos = 0; pos < beams; pos++) { // turn in other direction
beamsplitter.step(-stepsize); // direction
}

beamsplitter.setSpeed(motorspeed);
Serial.begin(31250);

}
}

void loop() {
for (pos = 1; pos < beams; pos++) { // turn in first direction
beamsplitter.step(stepsize); // switch position
//delayMicroseconds(delaymotor);
digitalWrite(LaserPin, HIGH); // turn on laser
delayMicroseconds(delaylaser / 2);
if ( (analogRead(0) > sensor )) // If the sensor gets a signalx
{
digitalWrite(6, HIGH); // Switch on status led.
noteOn(); // Play note 3
}
else if (analogRead(0) < sensor ) // If the sensor does not get a signal:
{
digitalWrite(6, LOW); // Switch off the status led.
noteOff(); // Stop playing note 2.
}
delayMicroseconds(delaylaser / 2);
digitalWrite(LaserPin, LOW); // Turn off the Laser.
}
beamsplitter.step(beams*stepsize);
}

它给了我这些错误。。。

sketch_oct07k.ino: In function 'void setup()':
sketch_oct07k.ino:33:14: error: a function-definition is not allowed here before '{' token
sketch_oct07k.ino:129:1: error: expected '}' at end of input

有谁能帮助一个可怜的人吗?

您已经复制了一些代码。

在第3行和第33行有一个CCD_ 1。我想这是您需要的第33行的第二个变量,否则所有的var都是本地设置的。

最新更新