Making short circuit on Teensy 4.1

Hello guys,

I am currently working on a project and I just new started to work on teensy. I wanted to ask a question. I have teensy 4.1 and it has two sensors these are: mpu6050 and ms5611. I have to connect a connector to the circuit and when the connector is connected, sensors should not send data, when the connector is disabled, sensors will start send data. To do this, I thought, there will be an pull-up resistor (10kohm) between 3.3v and pin2 and pin 2 connected to the ground by using connector. When the connector disabled, pin 2 will get 3.3v signal and circuit will start. Is it correct? I do not want to damage the teensy so, I wanted to ask to you. (I decided to use 3.3v pin instead of Vin because Vin has 5v and digital pins has 3.28v. If I try to use Vin it might be damaged the teensy.) I waiting for your advices.

Best regards.
 
@kazmyldrm10:

Yes, what you describe should be just fine. And, you are absolutely correct that the digital pins on a Teensy 4.x should never be subjected to any input voltage that is higher than 3.3VDC . . . damage will occur if 3.3VDC is exceeded.

Although you can certainly add an external pull-up resistor on your disable pin, you don't absolutely have to. Instead, you can simply make use of the available built-in pull-up by configuring the pin in the correct INPUT_PULLUP mode.

In your sketch, you will make use of pin 2 to do what you describe using something similar to this:

In your global declarations area (at the top of your sketch, not inside any functions), include the following:

Code:
#define DISABLE_SENSORS_PIN 2
#define SENSORS_ENABLED HIGH

In your setup() function, include the following:

Code:
pinMode(DISABLE_SENSORS_PIN, INPUT_PULLUP);

And, finally, around the area where you are gathering data from your sensors, include the following:

Code:
if (digitalRead(DISABLE_SENSORS_PIN) == SENSORS_ENABLED) {
  // read your sensors here
}

Hope that helps & good luck with your project.

Mark J Culross
KD5RXT
 
Back
Top