Hi everyone! I just ported my Arduino Mega project over to a Teensy 4.1 because I need the faster processing speed for my stepper motors. The Arduino Mega's digital pins output 5V whereas the Teensy 4.1 outputs 3.3V. I believe my problem is related to this.
The Setup
Hopefully the picture/diagram below explains my situation.
I have set up the End Stop so that it connects to Digital Pin 11 using
pinMode(11, INPUT_PULLUP);
I have connected the cables such that it remains HIGH when the switch is untouched (not pushed in), and LOW when the End Stop switch is closed (pushed in).
The Problem
This works UNTIL I turn on the 24V power supply which (through a 5V regulator) powers various devices, and shares a ground with the Teensy, at which point the Digital Pin 11 consistently reads "LOW", or sometimes erratically wavers between "LOW" and "HIGH."
Based on my research, I suspect this may be related to a floating voltage between the grounds since I'm using two power supplies (one is the 24V-5V regulator, and the other is the USB), but I'm not sure how to diagnose this or fix it. I tried using a multimeter to read the voltage difference between the "S" and "G" pins on the End Stop when the switch is open, and it reads ~3.3V when the Power Supply is off, and ~3.2V when the Power Supply is turned on, both of which should be sufficient to keep it as "HIGH". Yet turning the Power supply on causes the Teensy to read it as "LOW."
(The Teensy remains powered via a separate USB cable connected to my PC).
Any advice is appreciated! (and please let me know if you need more detail!)