How to setup a Rotary Switch with 1 Input

Поділитися
Вставка
  • Опубліковано 15 вер 2024

КОМЕНТАРІ • 23

  • @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 6 місяців тому +1

    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.

  • @mikey38632
    @mikey38632 10 місяців тому

    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!

  • @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.

  • @Travelife2000
    @Travelife2000 3 місяці тому

    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!

  • @shamrock1ization
    @shamrock1ization 2 місяці тому

    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 .

  • @awaagrikh8331
    @awaagrikh8331 6 місяців тому

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

  • @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).

  • @hralvesoctopi3504
    @hralvesoctopi3504 Рік тому

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

  • @jhonyyoelromerocapcha5400
    @jhonyyoelromerocapcha5400 7 місяців тому

    ¿Cual es el voltaje del capacitor?

  • @Roadstercycle
    @Roadstercycle 2 роки тому

    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?

  • @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.

  • @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.

  • @hurricanenzl
    @hurricanenzl Рік тому

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

  • @Scoobydcs
    @Scoobydcs 11 місяців тому

    does this work the same with leo bodner boards?

  • @fernandogs8377
    @fernandogs8377 Рік тому

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

  • @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.

  • @skorkmaz
    @skorkmaz Рік тому

    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

  • @hatray4540
    @hatray4540 9 місяців тому

    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

  • @KiKoLaw
    @KiKoLaw Рік тому

    Thx 🙏

  • @chunhochan7157
    @chunhochan7157 2 роки тому

    1