Arduino不会认出5v输入

时间:2014-12-30 01:13:03

标签: c input arduino

我是编程新手。我正在编写一个程序,用于Arduino克隆。我有一个12V线圈继电器,可以在12V红外开关上工作。继电器从Arduino接收5V电压,并向继电器提供5V电压,当继电器切换时,EG会在IR开关前移动。

该程序似乎忽略了传入的5V,并继续执行该程序,就好像它甚至没有尝试读取它一样。

当我检查串行监视器时,引脚正在读取(高或低),当没有任何东西时它只显示“xxx”,并且当我的手发出信号时没有反应。

我确信这是一些基本的C ++代码语法错误。

以下代码:

void loop() {
  analogWrite(channel_a_enable, 255);
  //turns feeder motor on through H bridge, to feed brass case
  digitalWrite(channel_a_input_1, HIGH);            
  digitalWrite(channel_a_input_2, LOW);
  val = digitalRead (sensor_ir_pin);
  //reads IR switch and checks if it has a case present yet
  Serial.println(val);
  if (val = HIGH)
  //if brass case rolls past sensor, switching IR switch and relay
    analogWrite(channel_a_enable, 0);
    //turns feeder motor off
  digitalWrite(channel_a_input_1, LOW);
  digitalWrite(channel_a_input_2, LOW); 
  current_potent = analogRead(A0);
  //reads the potentiometer setting (set for a max of 15 seconds time)      
  delay(current_potent * 14.6627);
  //delays, while the brass case is in the flame, getting annealed. Also provides the multiplier for 15000 mill seconds into 1023 read point on the potentiometer

0 个答案:

没有答案