Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Potentiometer Q. Teensy 3.2 and existing electronics

  1. #1
    Junior Member
    Join Date
    Dec 2018
    Silver Spring, MD

    Potentiometer Q. Teensy 3.2 and existing electronics

    Hi all, New here and hoping to get a bit of guidance. I am working on a program that will use a teensy to turn on an android box in the car to power a simple carputer. I have sorted how to get the device to turn on and now i'm working on a way to get the screen to go into standby. I have accomplished this using a simple switch sensor, but now i cant find a place to mount the sensor. The screen in my car opens and closes, its a 2004 RX-8. I found out that the OEM system uses a potentiometer for screen position, and other users have replaced the entire system with arduino and tapped this pot for screen position. Essentially what i want to do is tell the teensy, the screen is up or its down. I think i sorted the code part. I will include below and you guys can tell me if you see something weird or that could be better.

    The question is, can i connect the middle pin of the pot directly to the teensy analog pin in parallel with the existing electronics? The current setup controls opening and closing the screen, so i want to keep that working. my thought was to just pigtail a lead from the existing wiring to the teensy, and then read the pot positions and alter the code accordingly for open and closed positions. I guess what i'm asking is, do all 3 leads from the pot need to be connected to the teensy for it to work, or if it has power and ground from somewhere else can i still get a signal?

    Below is my code in case anyone wants to take a look.


    // Constant Variables for comparison
    const int HoodClosedValue = 950; //suspected pot value for closed
    const int HoodPosTolerance = 10; //tolerance stolen from somewhere else
    const int HoodOpen = 1; //defined placeholder because there is
    //more than one open position
    const int HoodClosed = 0; // only one closed position

    // CurrentState is the new read state from the pot from Nav Hood
    // Old State is the previous state stored in memory
    // these values are compared and if a change is registered
    // the standby button is pressed. (actualy a virtual button)

    int HoodState = 0; //used for initial hood pos function
    int CurrentState = 0; //stored value for now
    int OldState = 0; //stored value for previous

    void setup() {
    // put your setup code here, to run once:
    // 3 second delay before device turn on

    // pinMode(2, INPUT_PULLUP);
    // pin 2 is the nav hood sensor, old setup to test functionality

    pinMode(1, OUTPUT);
    // Power button input to android box

    digitalWrite(1, LOW);
    //pulse to turn device on

    pinMode(1, INPUT_PULLUP);

    //Release of power button

    // Gives 23 seconds for device to boot

    // This is the check to see if hood is intitially up or down
    // If open this does nothing, and loop starts after
    // matching the old and new state for loop
    if (HoodState < (HoodClosedValue-HoodPosTolerance)) {
    // This records the oldstate as open for the loop

    // If closed, this puts device into standby mode

    else {
    pinMode(1, OUTPUT);
    digitalWrite(1, LOW);
    pinMode(1, INPUT_PULLUP);

    // this records the oldstate as closed for loop
    // functionality of standby feature


    void loop() {

    // put your main code here, to run repeatedly:
    //Checks current hood position

    if (HoodState < (HoodClosedValue-HoodPosTolerance)) {
    CurrentState = HoodOpen;
    else {
    CurrentState = HoodClosed;

    // If position has changed since intialization
    // this pulses standby button

    if (CurrentState != OldState) {
    pinMode(1, OUTPUT);
    digitalWrite(1, LOW);
    pinMode(1, INPUT_PULLUP);

  2. #2
    Senior Member
    Join Date
    Jul 2014
    Quote Originally Posted by Capt.Ron View Post
    I guess what i'm asking is, do all 3 leads from the pot need to be connected to the teensy for it to work
    IMO, yes that seems the best: one outside pin goes to 3.3V, the other outside pin goes to ground, the middle pin goes to ADC (any Ax pin)

    Any outside electronics needs care (voltage > 5V may destroy T3.2)

  3. #3
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Colmar, France
    I allow to add from the NXP application note: For stable conversion by the Teensy's integrated delta-sigma ADCs, the potentiometer's impedance should be less or equal than 10kOhm and a 10-100nF capacitor should be added between the wiper and GND.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts