Using microswitches


#1

I recently purchased an ultimate robot kit. I’m programming it in arduino, working on basic movements. The ultrasonic sensor works well for walls and such, but unless the wall is like RIGHT IN FRONT OF IT, it often doesn’t stop. This makes corners difficult to navigate. I want to set up the microswitches in front of the treads so that if it runs into a corner, it’ll know it hit something and turn. I have a couple issues with figuring out how to do this.

  1. wiring the damn things. There is no guidance whatsoever on which wire goes where.
  2. I cannot find the object for the microswitches or the RJ25 adaptor they plug in to. Also, once I know those, how do I set up the declaration of the microswitches? Since the adaptor plugs into the board, then the microswitches, do I have to declare the microswitches, then the port on the adapter, then where the adapter is attached? And if so, how would that look?
    Please help. I’m lost

Limit switch
#2

Use MeLimitSwitch class.
This is how I connected it (but you can experiment with other setups)


#3

Thanks! That helps a lot. How would the declaration look though? Do I just say botH switches are assigned to PORT_4?


#4

You can choose the post of the RJ25 adapter in the constructor of MeLimitSwitch. See this example:
https://github.com/Makeblock-official/Makeblock-Library/blob/master/makeblock/examples/Me_LimitSwitch/TestMicroSwitch/TestMicroSwitch.ino


#5

Thank you so much, that helps a LOT


#6