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

Thread: Teensy 3.5 Unable to determine potentiometer's switch state on board startup.

  1. #1
    Junior Member
    Join Date
    Aug 2019
    Posts
    17

    Teensy 3.5 Unable to determine potentiometer's switch state on board startup.

    Hi,
    On my Teensy 3.5, I have a rotary potentiometer that includes a switch. I can tell if the switch is being turned on or off by checking Bounce.risingEdge() and Bounce.fallingEdge(). I can also set my volume based on the potentiometer output by checking analogRead(A1).

    What I can't figure out is how to tell if the knob is on the on or off side of the switch when the board boots. I tried looking at the potentiometer value and presuming it is on (or off) based on what I get there, but it could be in the on position with the volume at zero, and when it is in the off position, there is apparently noise or whatever that sometimes reads non-zero.

    I am having another issue that isn't as pressing right now, but the potentiometer's output reaches max (1023) at about the halfway point of the full rotation.
    Help with either is appreciated, but the initial switch position is my primary issue right now.

    Thanks.
    Here is the potentiometer:
    Name:  pot.jpg
Views: 57
Size:  6.0 KB

  2. #2
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    9,255
    HI,

    have not tried it, but I guess something like
    Code:
    button.update();
    int state = button.read();
    should do it.

    For the potentiometer values: How is it wired to the teensy?

  3. #3
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    9,255
    Do not connect it to 5V or VIN, use 3V

  4. #4
    Junior Member
    Join Date
    Aug 2019
    Posts
    17
    Quote Originally Posted by Frank B View Post
    button.read()
    Exactly what I needed. Thanks.
    Quote Originally Posted by Frank B View Post
    Do not connect it to 5V or VIN, use 3V
    I have it on VUSB right now, but I'll switch it to 3.3.

Posting Permissions

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