Go Down

Topic: I need help transmitting a signal. (Read 608 times) previous topic - next topic

Septence

I made a Remote control robot which receives a binary input. The problem is that when one input is received the arduino continues to execute it, BUT when I send another input it does not execute it, instead it only executes the previous input? what could be the problem?
here is the code:

int motor_pin1 = 4;
int motor_pin2 = 5;
int motor_pin3 = 6;
int motor_pin4 = 7;

void setup() {
 pinMode(motor_pin1,OUTPUT);
 pinMode(motor_pin2,OUTPUT);
 pinMode(motor_pin3,OUTPUT);
 pinMode(motor_pin4,OUTPUT);
 pinMode(8, INPUT);
 pinMode(9, INPUT);
 pinMode(10,INPUT);
 pinMode(11, INPUT);

}


void loop() {
 
 
  if( digitalRead(8) == HIGH && digitalRead(9) == LOW && digitalRead(10) == LOW && digitalRead(11) == LOW)
  {
  digitalWrite(motor_pin1, HIGH);
  digitalWrite(motor_pin2, LOW);
  digitalWrite(motor_pin3, HIGH);
  digitalWrite(motor_pin4, LOW);
  digitalWrite(13, HIGH);
  }
 
  if(digitalRead(8) == LOW && digitalRead(9) == LOW && digitalRead(10) == LOW && digitalRead(11) == LOW)
  {
  digitalWrite(motor_pin1, LOW);
  digitalWrite(motor_pin2, LOW);
  digitalWrite(motor_pin3, LOW);
  digitalWrite(motor_pin4, LOW);
  digitalWrite(13, LOW);
  }
 

JimboZA

#1
Jan 07, 2015, 07:04 am Last Edit: Jan 07, 2015, 07:05 am by JimboZA
Not sure what you mean....

Do you mean that the change between high and low on pin 8 isn't having an effect? (Seems that's all that changes.)

How do you know the pin is actually changing?- what do you mean by "transmitting a signal"? If it's remote control. there's no code in there for that, or is it one of these?

If I were you I would use Serial.begin() in setup() and stick some Serial.println()'s in to print out the values of those pins so you can see what they really are.

PS.... let's see the circuit diagram.
Johannesburg hams call me: ZS6JMB on Highveld rep 145.7875 (-600 & 88.5 tone)
Dr Perry Cox: "Help me to help you, help me to help you...."
Your answer may already be here: https://forum.arduino.cc/index.php?topic=384198.0

oric_dan


Go Up