This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Microswitch input

Hi

I am controlling the tilt/pan operations of a camera using a c167 microcontroller and i would like to use a microswitch as an end stop to stop the camera turning to far. Please could you give me some advice on to get the microcontroller to recognise when the switch has been pressed.

Thanks

John

Parents
  • Hi,

    you need to use a free processor portpin - best one which is capable of external interrupt. For example P2.8 on a C167.

    Connect the switch between this Portpin and GND and connect a pullup resistor - for example 10 kiloohms between Portpin and +5V processor supply. You also should connect a small capacitor (100nF) from portpin to GND to avoid signal distortion.

    Configure the portpin as input and interrupt on falling edge. As the switch is pressed, the voltage on the pin drops from +5V to zero and the isr is called.

Reply
  • Hi,

    you need to use a free processor portpin - best one which is capable of external interrupt. For example P2.8 on a C167.

    Connect the switch between this Portpin and GND and connect a pullup resistor - for example 10 kiloohms between Portpin and +5V processor supply. You also should connect a small capacitor (100nF) from portpin to GND to avoid signal distortion.

    Configure the portpin as input and interrupt on falling edge. As the switch is pressed, the voltage on the pin drops from +5V to zero and the isr is called.

Children
No data