How to setup a Rotary Switch with 1 Input

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ธ.ค. 2024

ความคิดเห็น • 24

  • @kinnikunky
    @kinnikunky 2 ปีที่แล้ว +11

    Thanks Scotty! This was super useful.
    If anyone is looking for a more elegant way to select a 'rotswitchNumber' you can do all of that with one line: rotswitchNumber= map(sensorValue, 0, 1023, 1, 8); (with the last number being the number of switch positions your rotary switch has). No need for the big if/then statement so long as the sensor values are evenly spread. Cheers :D

  • @fredmethot6116
    @fredmethot6116 9 หลายเดือนก่อน +2

    I almost gave up on this until tonight... I'm using a modded version of that same switch that allows for infinite rotation... however when the rotary was moved between the 2 pins that aren't bridged together by a resistor (PIN 14 from this video's schematic), it was shorting 3v3 and GND and would reset the board (which is not convenient when workiing on an ESP32 WROOM losing BT connection) .
    Finally resolved the issue by adding a diode in series between 3v3 and the switch PIN connecting to 3v3... BINGO! No more shorts, perfect stable reading @ +/-3.

  • @pi.actual
    @pi.actual ปีที่แล้ว +1

    A tip: soldering the resistors on looked to be difficult and tedious as shown. I would suggest a single wrap of each resistor lead around the pin which will hold them in place then solder all in one go and trim the ends of the leads when done.

  • @mikey38632
    @mikey38632 ปีที่แล้ว

    Awesome video, it's going to be very helpful. I'm learning to code C++ with an interest in MCUs, and my first dev board is on its way. If I'm able to realize my vision down the road, quite a few GPIO will be needed, so this sort of advice is key to success. Thanks again!

  • @johnmitchell130
    @johnmitchell130 2 ปีที่แล้ว +3

    Hi Scotty, Why did you use the 2.2uf Capacitor? You didn't tell us why.

    • @carneeki
      @carneeki 2 ปีที่แล้ว +3

      My guess is to handle debounce. That is, the 2.2uF cap will (hopefully) hold the charge and maintain the present voltage on the analog pin as the switch wiper wipes off one contact before it reaches the next contact.

    • @halcyonanon
      @halcyonanon ปีที่แล้ว

      Hey John - I tried with and without the capacitor (although I only had a 0.1uF. also added the 100Ohm resistor inline which was mentioned in the video).
      Without the capacitor, the values you get from each switch position fluctuated widely; so much so that it was very hard to code discreet switch positions. Adding the capacitor in series smoothed out the figures entirely, and I got stable readings at each switch position (with a margin of ~5).

  • @shamrock1ization
    @shamrock1ization 5 หลายเดือนก่อน

    Hello
    it's been some time with the video, but I've only seen it now.
    Can I also use the circuit in sim racing instead of a Rotary Encoder Ec11 to switch TC and ABS ?.
    I like the rotary switches because they have a noticeable grid.
    Greetings from Germany .

  • @hurricanenzl
    @hurricanenzl ปีที่แล้ว

    Thanks for the video, would this work on a leonardo and return a button push per postion change?

  • @fernandogs8377
    @fernandogs8377 ปีที่แล้ว

    hey! good video,
    how can we use this rotary ladder switch, to drive rgb leds and modify brightness according to ladder value?

  • @Travelife2000
    @Travelife2000 6 หลายเดือนก่อน

    hi i have a rotary switch with these specifications:
    Number of Positions: 12 Position
    Number of Decks: 1 Deck
    Number of Poles per Deck: 1 Pole
    Current Rating: 200 mA
    Voltage Rating DC: 30 VDC
    Voltage Rating AC: 125 VAC
    Contact Style: Shorting
    Termination Style: Solder Lug
    Actuator: Flatted
    Index Stops: Adjustable
    Voltage Rating: 115 VAC, 30 VDC
    what resistors and capacitor do i need to buy to perfect match the rotary switch above? thx!

  • @jiggi2212
    @jiggi2212 หลายเดือนก่อน

    Thx, i have tried same way , it works but 1 to 6 position value is same for 7 to 12 position , dont know why ? do you have any idea ?

  • @awaagrikh8331
    @awaagrikh8331 9 หลายเดือนก่อน

    Hi, will the resistor wear out and reduce its resistant after several years?

  • @Linrox
    @Linrox 2 ปีที่แล้ว

    Love the video thanks. It will help with my current project. Looking at the number bouncing around, i think a debouncer might help stabilize the number. Could be wrong.

  • @Roadstercycle
    @Roadstercycle 3 ปีที่แล้ว

    Hi Scotty, Loved your video. You gave me the basics on controlling my Mustang/Tesla conversion steering wheel buttons. They are a 2 wire setup with resistors that send signals to the onboard computer. I am wanting to change them to use as Park, Reverse, Neutral and drive. So I watched and setup what you did and got my 0-5 switch numbers but now I'm confused as to to implement then in the arduino to use as momentary switches. Any chance you could do a follow up on using the rotary switch to control on and off leds using the switch numbers generated and how to set them up to use as switched to control a relay or Mosfet?

  • @Scoobydcs
    @Scoobydcs ปีที่แล้ว

    does this work the same with leo bodner boards?

  • @fartmaster2933
    @fartmaster2933 2 ปีที่แล้ว

    Amazing video. Is it possible to connect the ground of many rotary switches to a common pin. So that way only 2 new pins are need for each extra switch.

  • @leondcarpenter
    @leondcarpenter 2 ปีที่แล้ว

    Awesome idea and great video. Totally new to Arduinos but am looking to control programable LEDs using the switch to drive different patterns as my first project. In tinkercad, I've mocked up your switch idea and have also loaded the neopixel template as well. If I wanted to combine the two setups (to eliminate the neo Arduino), where do I connect the power and ground for the LEDs? My guess is that the switch and the LEDs are 2 separate operations and the LEDs can connect anywhere there is ground and power. If this is true, and I want to eliminate the breadboard, I see that there are 2 grounds but only one 5v pin on the Arduino. Thanks again for the fantastic vid, I'm just not sure how to now put it into practical use.

  • @skorkmaz
    @skorkmaz 2 ปีที่แล้ว

    Great video. I have the almost same switch (dual pole 6 position). I'll use Arduino Due. Can I use the same? Same resistor and cap value?
    Thanks

  • @jhonyyoelromerocapcha5400
    @jhonyyoelromerocapcha5400 10 หลายเดือนก่อน

    ¿Cual es el voltaje del capacitor?

  • @hralvesoctopi3504
    @hralvesoctopi3504 ปีที่แล้ว

    Muito obrigado por este video! Foi muito importante para um trabalho! Grato, Helder Alves, Portugal

  • @KiKoLaw
    @KiKoLaw ปีที่แล้ว

    Thx 🙏

  • @hatray4540
    @hatray4540 ปีที่แล้ว

    If anyone wants to use this or many buttons on 1 analoge pin with the joystick.h library:
    void loop() {
    int analog = analogRead(A0); // analogue pin "A0"
    if (analog> 800 && analog < 1000) { //we set up range for button 0
    Joystick.pressButton(0);
    button_pressed = 0;
    } else if (analog > 750 && analog< 800) { //we set up range for button 1
    Joystick.pressButton(1);
    button_pressed = 1;
    }.... // etc, if we want more buttons
    ....
    delay(50);
    Joystick.setButton(button_pressed, 0); // we release button when we no longer click

  • @chunhochan7157
    @chunhochan7157 2 ปีที่แล้ว

    1