023 - MicroPython TechNotes: Continuous Rotation Potentiometer

In this article, we will tackle on how to use CONTINUOUS ROTATION POTENTIOMETER with ESP32 using MicroPython programming language.

  1. GND – for the ground.
  2. VCC – for the supply voltage.
  3. SIG – for the signal pin.
  1. ESP32 development board.
  2. Gorillacell ESP32 shield.
  3. 3-pin female-female dupont wires.
  4. Continuous Rotation Potentiometer module.
  1. First, attach the ESP32 dev board on top of the ESP32 shield and make sure that both USB port are on the same side.
  2. Next, attach the dupont wires to the Continuous Rotation Potentiometer module by following the color coding which is black for the ground, red for the VCC, and yellow for the signal pin.
  3. Next, attach the other end of the dupont wires to the ESP32 shield by matching the colors of the wires to the colors of the pin headers which is black to black, red to red, and yellow to yellow.
  4. Next, power the ESP32 shield with an external power supply with a type-C USB cable and make sure that the power switch is set to ON state.
  5. Lastly, connect ESP32 to the computer with a micro USB cable. Our demo circuit should now be ready.

I prepared 2 example source code for this demonstration.

Copy and paste it to Thonny IDE.

Modify and adapt it according to your needs, and most of all enjoy learning.

For any concern, write your message in the comment section.

You might also like to support my journey on Youtube by Subscribing. Click this to Subscribe to TechToTinker.

Thank you and have a good days ahead.

See you,

– George Bantique | tech.to.tinker@gmail.com

 1# More details can be found in TechToTinker.blogspot.com 
 2# George Bantique | tech.to.tinker@gmail.com
 3
 4from machine import Pin, ADC
 5from time import sleep_ms
 6
 7p32 = Pin(32, Pin.IN)
 8crpot = ADC(p32)
 9crpot.atten(ADC.ATTN_11DB)
10
11while True:
12    print(crpot.read())
13    sleep_ms(300)
...
py
 1# More details can be found in TechToTinker.blogspot.com 
 2# George Bantique | tech.to.tinker@gmail.com
 3
 4from machine import Pin, ADC
 5from neopixel import NeoPixel
 6from time import sleep_ms
 7
 8p32 = Pin(32, Pin.IN)
 9crpot = ADC(p32)
10crpot.atten(ADC.ATTN_11DB)
11
12NUM_OF_LED = 16
13np = NeoPixel(Pin(25), NUM_OF_LED)
14np.fill((0,0,0))
15
16def map(x, in_min, in_max, out_min, out_max):
17    return int((x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min)
18
19while True:
20    crpot_value = crpot.read()
21    np.fill((0,0,0))
22    np_addr = map(crpot_value, 0, 4095, 0, 15)
23    np[np_addr] = (10, 0, 0)
24    np.write()
25    sleep_ms(300)
...
py
  1. Purchase your Gorillacell ESP32 development kit: gorillacell.kr


Posts in this series



GitHub-flavored Markdown & a sane subset of HTML is supported.