ARC Pro

Upgrade to ARC Pro

Harnessing the power of ARC Pro, your robot can be more than just a simple automated machine.

#9  

no, the v4 doesn't have built in pull up or down resistors on the digital pins. you would have to supply one.

How would you accomplish this on an arduino? It would be the same for the V4. The arduino would have to measure the pin (d2 for example) for high or low. in order to do that, you would have to have a breadboard or some circuit that provides the 5V or 0V back to the arduino on the d2 pin. You would have to provide the pullup or pull down resistor in the circuit. You would have to provide positive and neg to the circuit or breadboard because there is no voltage coming across the solution you mentioned.

With a double pole single throw switch, you could take the digital signal pin from say D0, pass it through the switch and read the result on D1. Set D0 to high and then measure on D1. If the switch has been switched, D1 would be high. if it isnt, D1 would be low. This would be the easiest way to do what you are looking for.


set(D0,on)
if(GetDigital(d1) = 1)
#the switch is in the on position
else
#the switch is in the off position
endif

This would work because there is a common ground between D0 and D1 (along with every other ground pin) on the V4.

#10  

Now I'm getting some where. Ok now I see how we are going to do this. Cool Thanks.:)

On The Arduino I use:



// Note one leg of the switch goes to the S or signal pin on pin set #2 and the other leg goes to the - (negative) pin on pin set # 2

int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  
  pinMode(13, OUTPUT);      
  // initialize the pushbutton pin as an input:
  pinMode(2, INPUT);     
}

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(2);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:

  if (buttonState == HIGH) 
    {     
      // turn LED on:    
      digitalWrite(13, HIGH);  
    } 
  else {
     // turn LED off:
     digitalWrite(13, LOW); 
   }
}



#11  

Anytime bud. You're basically doing the same thing with 2 digital pins.

Glad to have been of help.

#12  

The EZB4 cant read from the Signal pin to ground? I thought it had built in pull ups and pull downs.... ?

#13  

You will just have to use the signal pin. D0 to one side of the switch. D1 to the other side of the switch. The V4 has power to the other pins that is common (ground and +). You wont have to worry about these at all and no wires are needed at all on these pins (+ or -).

If you set D0 to on then d1 should read high or the other way around depending on which you want to do. I dont have one available to test with right now, but I will do a test tonight for you.

#14  

Your last code works well. Just put your switch from S signal to - or ground and the port will go 1 or 0 depending on how the switch is set.