ARC Pro

Upgrade to ARC Pro

ARC Pro is your passport to a world of endless possibilities in robot programming, waiting for you to explore.

#1  

By switch, you mean an on off switch, right?

What you can do is pass a wire from the on side of the switch to a digital signal port (making sure that the voltage is regulated down to 5 volts). From there, the V4 will be able to see if that digital port is in a high or low state.


if(GetDigital(d0) = 1)
#do something if the switch is on
else
#do something if the switch is off
endif

BTW, example is available in the If condition in ARC script help


If (Value Condition Value )
IF condition can support multiple comparisons and functions.
Condition tree must be closed with an ENDIF
See the Functions section of this document.
Condition can be =, <, >, <=, >=, !=, AND, OR
Example: 
If (GetDigital(D0) = 1)
  Print(One)
EndIf
Example: 
If ($Day = 2 AND $Hour = 3)
  Print(Hello)
EndIf
Example: 
If (GetServo(D5) >20 OR ($x >= 3 and $y < 2))
  Print(Yup!)
EndIf



#2  

Thanks so much easer then Arduino's. So I'm going to put the switch a crossed the signal pin and ? (+ or - )? Thanks:)

#4  

Nothing other then being monitored by the EZ-B4 as in the state of OFF or ON. The switch is closed or NC when my robot is plugged into the shop sensor cable. Two wires represent the switch. The two wires at the end of a cable that has the shop PIR sensors on it. The two wires are solder to each other to for the switch in the closed position. So when the cables plugged in to the robot, its the same as a switch being turned on or in closed. So when the EZB4 sees the switch on it will set a variable named $LOCATION and it will = SHOP. If the cable is not plugged in it will = 0 . Thus telling my robot it is in the shop.

#5  

I assumed that you are talking about a switch as in an on/off switch that is supplying power to something. If this is the case, you would just come off of the on position of the pin to the v4 on a digital signal port. This port is a 5 volt port so it is necessary to then reduce the power down to 5 volts if it is being supplied more than 5 volts. This pin can then be monitored with a script for a high state. If it is high, it would return a 1 in the script (or on). If it is off or 0 volts, it would be 0 volts or off. The ground pin would probably have to be connected to the switch also but everything depends on what you are doing with the switch and how you are using it in your system.

It would work the same on an arduino. It is all based on low(0 volts) or high logic (5 volts). If it is some other type of switch, it would still depend on low or high logic, but how you supply that to the board from the switch could be different.

#6  

You replied while I was typing, let me go back and read that.

#7  

Here is how you would do it on an arduino. The same way can be used on a V4 only you would use the same pins in the digital port instead of pins from various parts of the board. The script above would work.

Connect three wires to the Arduino board. The first two, red and black, connect to the two long vertical rows on the side of the breadboard to provide access to the 5 volt supply and ground. The third wire goes from digital pin 2 to one leg of the pushbutton. That same leg of the button connects through a pull-down resistor (here 10 KOhms) to ground. The other leg of the button connects to the 5 volt supply.

Pushbuttons or switches connect two points in a circuit when you press them. When the pushbutton is open (unpressed) there is no connection between the two legs of the pushbutton, so the pin is connected to ground (through the pull-down resistor) and reads as LOW, or 0. When the button is closed (pressed), it makes a connection between its two legs, connecting the pin to 5 volts, so that the pin reads as HIGH, or 1.

Switches come in many forms. Some have 2 pins on the back of the switch that would be used for something like power. Some have 3 pins and some have 4 pins. What configuration is your switch? Does it except ground and positive or just have 2 pins (in and out)?

#8  

I'm use to working with with the Arduino's. But that set-aside. For simplicity sake Lets say I have a switch. It is a DPST (Double pole single throw) When you turn it on the switch close the contacts. When you turn the switch off it opens the contacts. I need the EZB4 to set a variable when the switch is closed.

To do this one leg of the switch is connected to the S or signal pin on D0 and the other wire goes to the?

Dose the EZB4 have a built in pull down / pull up resistor ?