drhall
01-04-2009, 15:38
We are having some trouble trying to get toggle switches to work for switching between autonomous modes. The switches are mounted directly to our robot and connected to digital I/O ports 1,2, and 3. We are progamming in Wind River using C++ and I just can't get the code to work. We hooked up a multimeter to the switches (which we have hooked up as ground, signal and power) and we are getting the expected 5V one way and 0 the other.
Here's the code, any help is greatly appreciated!!!
{
m_disabledPeriodicLoops = 0; // Reset the loop counter for disabled mode
ClearSolenoidLEDsKITT();
// Move the cursor down a few, since we'll move it back up in periodic.
printf("\x1b[2B");
DriveDirection = 1;
DriveSpeed = 1;
if (Switch1->Get() == 0) {
// stuff to do if Switch1 (left) is on
// Set direction to positive 1 for left
DriveDirection = 1.0;
DriveSpeed = 1.0;
}
else if (Switch2->Get() == 0)
{
//not yet
}
else if (Switch3->Get() == 0) {
// stuff to do if Switch3 (right) is on
// Set direction to negative 1 for right
DriveDirection = -1.0;
DriveSpeed = 1.0;
}
}
That is what's in void DisabledInit. We are then using the DriveDirection variable in AutonomousPeriodic.
Thanks!
Here's the code, any help is greatly appreciated!!!
{
m_disabledPeriodicLoops = 0; // Reset the loop counter for disabled mode
ClearSolenoidLEDsKITT();
// Move the cursor down a few, since we'll move it back up in periodic.
printf("\x1b[2B");
DriveDirection = 1;
DriveSpeed = 1;
if (Switch1->Get() == 0) {
// stuff to do if Switch1 (left) is on
// Set direction to positive 1 for left
DriveDirection = 1.0;
DriveSpeed = 1.0;
}
else if (Switch2->Get() == 0)
{
//not yet
}
else if (Switch3->Get() == 0) {
// stuff to do if Switch3 (right) is on
// Set direction to negative 1 for right
DriveDirection = -1.0;
DriveSpeed = 1.0;
}
}
That is what's in void DisabledInit. We are then using the DriveDirection variable in AutonomousPeriodic.
Thanks!