|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
DS Digital Input/Output
Recently my team went to a competition and I asked for help with out driver station. We had purchased a few Light Switches from the local hardware store and I had no idea how to wire them properly.
So he helped me wire them properly and connect them to DS 1 and 2 on the Driver Station and now I need to figure out how to code them. My current code looks like this Code:
bool switch1;
switch1 = m_ds->GetDigitalIn(1);
printf("Switch Value is: %d ", switch1);
My next problem is we want to wire in a few LED's to the DS so we know what is going on with the robot Code:
m_ds->SetDigitalOut( 1,true); |
|
#2
|
||||
|
||||
|
Re: DS Digital Input/Output
I'm not sure about the switch problem, cuz i was experiencing the same thing. However the if m_ds is a pointer refering to digital out on the ds, then that code should work. I didn't have any problems with the LEDS.
|
|
#3
|
|||
|
|||
|
Re: DS Digital Input/Output
A couple of suggestions:
1.Your printf is set to print an int, not a boolean. I don't think there's a flag for boolean, so you might want to change it to use two different printfs depending on the state of the variable 2.Check your switches with a multimeter and make sure current is actually getting through. 3.Check your digital outputs and see if you're actually turning it on. If you are, chances are that you have reversed the polarity to the LED(LEDs are diodes, so they only work one direction) |
|
#4
|
|||
|
|||
|
Re: DS Digital Input/Output
My next best guess for C++ would be a "c" character flag? If im not mistaken it would print a t or a f then correct?
|
|
#5
|
|||||
|
|||||
|
Re: DS Digital Input/Output
There seems to be a lot of confusion about what "wire them properly" really is. I think the software looks right, so maybe the hardware isn't. What sort of light switches are you using? How are they wired?
|
|
#6
|
|||
|
|||
|
Re: DS Digital Input/Output
I cant get my hands on the light switches right now but I know they have 3 wire leads. I remember him telling me something about "Getting around having to use a resistor" and Double Pole Double Throw
Thanks for all of the help so far! |
|
#7
|
||||
|
||||
|
Re: DS Digital Input/Output
printf("%i", true); will print 1
and printf("%i",false); will print0 you dont need a bool printf flag, or a if statement just use the int flag (%i or %d) |
|
#8
|
|||
|
|||
|
Re: DS Digital Input/Output
It must be in the wiring in the switch then because I have tried that.
|
|
#9
|
|||||
|
|||||
|
Re: DS Digital Input/Output
We experinced similar trouble. Wire a 1kOhm resistor between the power and signal wires on the switch. That should solve your problem.
|
|
#10
|
||||
|
||||
|
Re: DS Digital Input/Output
I have a question on the jumpers also, my code looks like this:
Code:
enum{
ARCADE_MODE = 1,
ENABLE_AUTONOMOUS = 2,
DRIVE = 3,
}jumpers;
....
....
void OperatorControl(void)
{
while(1)
{
if(ds->GetDigtalIn(DRIVE)==1)
{
myRobot->TankDrive(-rightstick->GetY(), -leftstick->GetY());
}
else
{
myRobot->Drive(-leftstick->GetY(), -rightstick->GetX());
}
}
}
|
|
#11
|
|||||
|
|||||
|
Re: DS Digital Input/Output
Explain which pin 3, there are a few of them, and the jumper goes from where to where exactly?
|
|
#12
|
||||
|
||||
|
Re: DS Digital Input/Output
I've been using a really simple program to display my driver station inputs to the driver station LCD panel. C++ sources/project included:
http://www.virtualroadside.com/blog/...-test-program/ |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Digital Input? | boris | C/C++ | 1 | 30-01-2009 14:51 |
| Switch digital input to output during operation? Parallax Ultrasonic | wt200999 | C/C++ | 2 | 28-01-2009 19:30 |
| live input/output to/from application | MarkH | Programming | 3 | 06-04-2006 01:43 |
| digital output frequency | Barth | Programming | 8 | 06-03-2005 21:58 |
| Dynamic Input/Output Changing | Paolo | Control System | 6 | 23-09-2004 19:09 |