Quote:
|
Originally Posted by Code\\monkey
Hello cool people from this wonderful forum.
I was wondering if there is a way to put switches on the robot like last year.
Remember? that you could set jumpers so the robot will do different things depending on the jumpers.
If there is a way, can you tell me how?
Cause i am writing a dead reck' code, so i wan it to be able to switch the code before the game, you know, like, if i am going to be on the right side, the code makes it go right, an the same with the left.
Thanks.
Oh, one more thing, be happy.
Code\\monkey.
|
Here's an example of something you could do. I only use three switches, but this could be easily expanded.
The firstSwitch and such are the digital pins that the switches you are using are attched to.
User_Autonomous_Code() in fast_user_routines.c
Code:
#define SWITCH_ON 1
#define SWITCH_OFF 0
User_Autonomous_Code()
{
unsigned char autonomousSettings = 0;
// Check switches for settings
if(firstSwitch == SWITCH_ON)
autonomousSettings += 1;
if(secondSwitch == SWITCH_ON)
autonomousSettings += 2;
if(thirdSwitch == SWITCH_ON)
autonomousSettings += 4;
while(autonomous_mode) // This is the autonomous loop. The switches are evaluated before entering here
{
get_data();
// In here, you can have things that use the settings
switch(autonomousSettings)
{
case 1: // Right side for autonomous mode 1
break;
case 2: // Left side for autonomous mode 1
break;
case 3: // Right side for autonomous mode 2
break;
case 4: // Left side for autonomous mode 2
break;
case 5: // Right side for autonomous mode 3
break;
case 6: // Left side for autonomous mode 3
break;
case 7: // Misc empty for now.
break;
default: // Use this for error checking
printf("Something went wrong");
break; // Force of habit
}
put_data();
}
}
Well, anyway, I 'm too lazy to type any more.

That should give you the idea, though.