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.

Oh, one more thing, be happy. :slight_smile:


just hook them up to a digital input pin, and use and if statement (or multiple if-elses) to select the code to run - you robot can read the input pins any time when it is on, including disabled mode.

you could even wire the switch up to one of the joystick ports on the OI and use that to switch the program - disabled mode allows input from the OI.

yeah, but i wasn’t thinking 'bout a manual switch, where when you want to set it to some state, you just have to press something on the robot. With out touching the OI.

yea make a switch box then figure out what the pin numbers are in 1 of your joystick. then wire by wire insert them into the proper pins…so basically the compition will be over when your done.

Pluss in order to get the arm or whatever you are moving with a switch you need to use encoders so the program knows when to stop the motors.

Potentiometers. You know the angle (in pot units!)

You would have to make sure not to try to read the switch after autonomous mode kicks in, as the OI inputs are not passed through then.

there is that. however, one could simply put the code to read the sensor in Process_Data_From_Local_uP (or Process_Data_From_Master_uP) - thus, once the robot goes into autonomous mode, Process_Data_From_Local_uP is no longer called, and thus the switch value read will not be overwritten.

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

#define SWITCH_ON 1 
#define SWITCH_OFF 0
	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
		// In here, you can have things that use the settings
			case 1:  // Right side for autonomous mode 1
			case 2: // Left side for autonomous mode 1
			case 3:  // Right side for autonomous mode 2
			case 4: // Left side for autonomous mode 2
			case 5: // Right side for autonomous mode 3
			case 6: // Left side for autonomous mode 3
			case 7: // Misc empty for now. 
			default: // Use this for error checking
				printf("Something went wrong"); 
				break; // Force of habit

Well, anyway, I 'm too lazy to type any more. :wink: That should give you the idea, though.

I’m trying to do something similar to what codemonkey is doing. How would I go about making a switchbox for the robot (to attach to the rc)? Basically how do I return a “1” to a digital input.

it’s really just a matter of closing the circuit between the GND and SIG pins of the digital input (someone correct me if I’m wrong). just hook up a switch in between the pins.

use an 8-way rotary switch. This way you can have up to 8 selections and it would be very easy to wire and program

Thanks, that was what I was hoping, the RC guide was unclear to me. Is it legal to use limit switches provided by innovation first in the EDU kit on the robot? We ordered some extra ones. I would have to rewire them because the +5v pin is in the middle of the grounds and sig’s and they only have a 2 pin connector :rolleyes:

Actually, and somebody should correct me if I’m wrong, the pins are pull ups, meaning they are normally on unless something connects the GND and SIG pins, which pushes them off. So, to turn it on, you don’t close the GND and SIG pins. :eek: Or, I could be totally wrong and you’ll have to yell at me. :wink:

I’m thinking it returns a “1” if you do close them, there is an indicator LED on the RC, too bad I don’t have access to the “robot room” today to test this. I attached a banner sensor once, though, to a digital input and it indicated the switch variable was equal to “1” when the banner sensor detected white, that was of course with the white wire from the banner sensor… oh well I’ll figure out what it does tomorrow lol