1M ohm 16mm Rotary Pot Variable Potentiometer (Pack of 5) Documentation
The 1M ohm 16mm Rotary Pot Variable Potentiometer is a analog rotary potentiometer with a resistance value of 1M ohm and a physical size of 16mm in diameter. This component is commonly used in various applications such as audio equipment, robotics, and IoT projects to control voltage levels, signal amplitude, and frequency. This documentation provides technical details and code examples for using this component in different contexts.
Resistance: 1M ohm
Power rating: 0.5W
Operating voltage: 12V
Physical size: 16mm diameter
Rotation angle: 270
Linearity: 5%
Temperature range: -20C to +70C
The 1M ohm 16mm Rotary Pot Variable Potentiometer has three pins:
Pin 1: CCW (Counter-ClockWise) terminal
Pin 2: Wiper terminal
Pin 3: CW (ClockWise) terminal
### Example 1: Analog Voltage Control using Arduino
In this example, we will use the 1M ohm potentiometer to control the analog voltage output of an Arduino Uno board.
Arduino Uno board
1M ohm 16mm Rotary Pot Variable Potentiometer
Breadboard
Jumper wires
Code
```c
const int potPin = A0; // Potentiometer wiper pin connected to A0
const int ledPin = 9; // LED connected to digital pin 9
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
int potValue = analogRead(potPin); // Read potentiometer value (0-1023)
int voltage = map(potValue, 0, 1023, 0, 255); // Map pot value to voltage (0-255)
analogWrite(ledPin, voltage); // Write voltage to LED
delay(10);
}
```
In this example, the potentiometer is connected to analog input A0 of the Arduino Uno, and the LED is connected to digital pin 9. The Arduino reads the potentiometer value and maps it to a voltage value between 0 and 255. The voltage is then written to the LED using the `analogWrite()` function.
### Example 2: Signal Attenuation using Raspberry Pi and Python
In this example, we will use the 1M ohm potentiometer to attenuate a signal using a Raspberry Pi and Python.
Raspberry Pi board
1M ohm 16mm Rotary Pot Variable Potentiometer
Breadboard
Jumper wires
Signal source (e.g., audio signal)
Code
```python
import RPi.GPIO as GPIO
# Set up GPIO mode
GPIO.setmode(GPIO.BCM)
# Define pin for potentiometer wiper
pot_pin = 17
# Set up potentiometer pin as an analog input
GPIO.setup(pot_pin, GPIO.IN)
def attenuate_signal(pot_value):
# Calculate attenuation factor based on potentiometer value
attenuation_factor = pot_value / 1023.0
return attenuation_factor
while True:
pot_value = GPIO.input(pot_pin)
attenuation_factor = attenuate_signal(pot_value)
# Apply attenuation factor to signal
# (e.g., using a software-based audio mixer or signal processing library)
print("Attenuation factor:", attenuation_factor)
```
In this example, the potentiometer is connected to a GPIO pin on the Raspberry Pi, and the Python script reads the potentiometer value using the `GPIO.input()` function. The script then calculates an attenuation factor based on the potentiometer value and applies it to the signal using a software-based audio mixer or signal processing library.
### Example 3: IoT Application using ESP32 and MicroPython
In this example, we will use the 1M ohm potentiometer to control a remote IoT device using an ESP32 board and MicroPython.
ESP32 board
1M ohm 16mm Rotary Pot Variable Potentiometer
Breadboard
Jumper wires
Wi-Fi antenna
Code
```python
import machine
import urequests
# Set up potentiometer pin as an analog input
pot = machine.ADC(32) # Pin 32 is the ADC input for the potentiometer
def send_data(pot_value):
# Send potentiometer value to remote IoT device using HTTP
url = "https://example.com/iot_device_control"
headers = {"Content-Type": "application/json"}
data = {"pot_value": pot_value}
response = urequests.post(url, headers=headers, json=data)
return response.text
while True:
pot_value = pot.read_u16() # Read potentiometer value (0-65535)
send_data(pot_value)
machine.delay(500)
```
In this example, the potentiometer is connected to an ADC input on the ESP32 board, and the MicroPython script reads the potentiometer value using the `machine.ADC.read_u16()` function. The script then sends the potentiometer value to a remote IoT device using an HTTP POST request.
Note: These code examples are for illustrative purposes only and may require modifications to work with specific hardware and software configurations.