Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arduino 加工格列茶素_Arduino_Processing - Fatal编程技术网

Arduino 加工格列茶素

Arduino 加工格列茶素,arduino,processing,Arduino,Processing,我正试图建立这个: 如果没有killswitch和debugmode,代码如下所示: // glitchamin // simple theremin synth with killswitch // Jacob Peck (a.k.a. ~suspended-chord, http://suspended-chord.info) // adapted from http://www.adafruit.com/blog/2009/05/19/piezo-with-an-arduino-phot

我正试图建立这个:

如果没有killswitch和debugmode,代码如下所示:

// glitchamin
// simple theremin synth with killswitch
// Jacob Peck (a.k.a. ~suspended-chord, http://suspended-chord.info)
// adapted from http://www.adafruit.com/blog/2009/05/19/piezo-with-an-arduino-photoresistor/

// circuit:
// pin d9: pin > +buzzer- > gnd
// pin d10: pin > switch > 5v, switch > 10kOhm resistor > gnd (optional)
// pin a0: 5v > cds > pin, pin > 10kOhm resistor > gnd
// pin a1: 5v > pot, pot > pin, pot > gnd
// pin a2: 5v > pot, pot > pin, pot > gnd

//#define DEBUG // uncomment to get serial output, but it kills the speed of the
                // algorithm, making for a very bad cycle rate
//#define KILLSWITCH // comment to disable killswitch code

int photosensorPin = 0;
int cutterpotPin = 1;
int cyclepotPin = 2;
int piezoPin = 9;

//#ifdef KILLSWITCH
//int killswitchPin = 10;
//#endif

int val = 0;
int cut = 0;
int cycle = 0;
int kill = 0;

void setup() {
  pinMode(piezoPin, OUTPUT);

//#ifdef KILLSWITCH  
//  pinMode(killswitchPin, INPUT);
//#endif

//ifdef DEBUG  
//  Serial.begin(115200);
//endif

}

void loop() {
  digitalWrite(piezoPin, LOW);
  val = analogRead(photosensorPin);
  cut = analogRead(cutterpotPin);
  cycle = analogRead(cyclepotPin);

//#ifdef KILLSWITCH
//  kill = digitalRead(killswitchPin);
//#endif  

////#ifdef DEBUG  
////  Serial.print("CdS: ");
////  Serial.print(val);
//  Serial.print("\tCutter: ");
//  Serial.print(cut);
//  Serial.print("\tCycle: ");
//  Serial.print(cycle);
//#ifdef KILLSWITCH  
//  Serial.print("\tKill: ");
//  Serial.println(kill);
//#else
//  Serial.println("");
//#endif // killswitch
//#endif // debug

  val = val / map(cut, 0, 1023, 15, 2);
  cycle = map(cycle, 0, 1023, 1, 1000);

//#ifdef KILLSWITCH
// if (!kill) { // if not killed
//#endif
    for( int i=0; i<cycle; i++ ) {  // play for cycle pot's reading
      digitalWrite(piezoPin, HIGH);
      delayMicroseconds(val);
      digitalWrite(piezoPin, LOW);
      delayMicroseconds(val);
    }
//#ifdef KILLSWITCH
//  }
//#endif  
}
//glitchamin
//带killswitch的简单theremin合成器
//雅各布·佩克(又名《悬弦》,http://suspended-chord.info)
//改编自http://www.adafruit.com/blog/2009/05/19/piezo-with-an-arduino-photoresistor/
//线路:
//引脚d9:引脚>+蜂鸣器->接地
//引脚d10:引脚>开关>5v,开关>10K欧姆电阻器>接地(可选)
//引脚a0:5v>cds>引脚,引脚>10K欧姆电阻器>接地
//引脚a1:5v>电位计,电位计>引脚,电位计>接地
//引脚a2:5v>电位器,电位器>引脚,电位器>接地
//#定义DEBUG//uncomment以获得串行输出,但它会降低
//算法,使得循环率非常糟糕
//#定义KILLSWITCH//comment以禁用KILLSWITCH代码
int photosensorPin=0;
int切割器插销=1;
int cyclepotPin=2;
int=9;
//#ifdef基尔开关
//int killswitchPin=10;
//#恩迪夫
int-val=0;
int-cut=0;
整数周期=0;
int kill=0;
无效设置(){
引脚模式(压电引脚,输出);
//#ifdef基尔开关
//pinMode(killswitchPin,输入);
//#恩迪夫
//ifdef调试
//序列号开始(115200);
//恩迪夫
}
void循环(){
数字写入(压电引脚,低电平);
val=模拟读数(光敏素);
切割=模拟读数(刀头销);
循环=模拟读数(循环肽);
//#ifdef基尔开关
//kill=数字读取(killswitchPin);
//#恩迪夫
////#ifdef调试
////连续打印(“CD”);
////串行打印(val);
//Serial.print(“\tCutter:”);
//连续打印(剪切);
//串行打印(“\t循环:”);
//串行打印(循环);
//#ifdef基尔开关
//Serial.print(“\tKill:”);
//序列号println(kill);
//#否则
//Serial.println(“”);
//#endif//killswitch
//#endif//debug
val=val/map(截,0,1023,15,2);
循环=映射(循环,0,1023,1,1000);
//#ifdef基尔开关
//if(!kill){//if未终止
//#恩迪夫

对于(int i=0;i,这是因为您正在处理中运行代码,需要使用Arduino IDE编译代码并将其上载到Arduino。这是一个非常常见的错误,因为这两个IDE看起来完全相同,因为Arduino IDE基于处理IDE

您可以在Arduino网站上下载