Arduino - Rotary Potentiometer. Arduino's pin A0 to A5 can work as analog input. The analog input pin converts the voltage (between 0v and VCC) into integer values (between 0 and 1023), called ADC value or analog value. By connecting an output pin of the potentiometer to an analog input pin, we can read the analog value from the pin, and then converts it to a meaningful value. Learn how to use potentiometer with Arduino, how potentiometer works, how to connect potentiometer to Arduino, how to code for potentiometer using Arduino, how to program Arduino step by step. The detail instruction, code, wiring diagram, video tutorial, line-by-line code explanation are provided to help you quickly get started with Arduino. Find this and other Arduino tutorials on.
Because of substantial price difference, many users are using Chinese clones of the genuine Arduino development boards. Although in most cases the functionality is similar or even identical to the original, there may be some differences. Unfortunately, quite often there is virtually no schematics, datasheets or detail description available. This is a case for a Chinese clones of the Arduino Nano R3 board as well.
After some research, measurements and detail inspection of the boards I was able to get together all circuits. Below you will find both schematics and few technical comments to the Nano CH340 R3 development board. I have purchased several Nano 3.0 CH340 clones in different orders from several Asian vendors and they are all almost identical, so it seems that this type of the Nano 3.0 board is widely used.
Nano CH340 R3 board description
The Nano CH340 R3 board is similar to the genunine Arduino Nano board, described on the original Arduino website here . The board uses same type of Mini-B USB connector, same side connectors and 6-pin SPI connector, as well as the Atmel ATmega328P microcontroller in the 32-TQFP package. There are also 4 LEDs – Power LED, LED connected to digital output pin D13, and two LEDs showing status of the RxD and TxD communication lines.
To provide +5.0 V Vcc power supply, the board uses LM1117-5.0 SOT-223 linear stabilizer 5.0 V (compared to original UA78M05), with slightly higher current (800 mA vs. 500 mA of original UA78M05) and lower drop-out voltage (typ. 1.2 V vs. 2.0 V for UA78M05).
To facilitate the USB communication and to provide 3.3 V output, the board uses USB communication circuit CH340 in SOP-16 package (instead of FT232RL used on the genuine Nano R3 board), manufactured by several Chinese companies. The CH340 IC requires installation of driver software, which was covered and explained many times already, so I will not repeat this information. With installed driver, communication with Arduino (IDE) is clear and straightforward.
To switch between VIN power supply (6-12 V) and USB power supply, the board includes a Schottky diode with low forward voltage. Most of the boards I got seems to be using the Vishay Semi SD101CWS diode (Vf 0.6 – 0.8 V at 20 mA, S4 SMD marking code).
Differences to the genuine Arduino Nano R3 board
- For both ATmega328P and CH340, the board uses 3-pin SMD ceramic resonators with internal load capacitors, so no external capacitors for oscilating circuit are needed not they are used (although there are soldering pads provided next to the CH340 resonator).
- Rx and Tx LEDs are connected directly to the ATmega328P outputs PD0 and PD1, so keep that in mind in case those two pins will be used for something else than USB communication (on genuine Nano R3 board the Rx and Tx LEDs are driven by additional outputs on the FT232RL chip).
- The CH340 chip includes the 3.3 V LDO voltage regulator, which can supply up to 25 mA. There is no refence in the original CH340 datasheet or elswhere on the internet, so I measured the supplied 3V3 voltage directly.
With no load, the 3V3 pin voltage was 3.28 V. With load up to 25 mA the voltage dropped to 3.18-3.22 V (on different boards); however at 30 mA load the voltage dropped to 3.10 V and further to 2.85 V at 40 mA.
Schematics
Finally, below is a link to schematics of the Nano CH340 R3 board in pdf. Feel to copy and share as you like, providing you will attach the copyright info “copyright actrl.cz”. Please note that previously there was an error in connection of pins 2&3 on CH340 – on rev. 1 of the file this is corrected (CH340 (3) Rx pin is connected to Tx LED and (31) Tx pin of ATMega 328P, while CH340 (2) Tx pin is connected to Rx LED and (30) Rx pin of ATMega 328P – thanks Jindra Fučík to pointing this out).
Created on: 4 January 2018
How to use the photo resistor sensor module from the 37 in 1 sensor kit for Arduino from Geekcreit, Elegoo, Elektor and others. In some kits the module may be called an LDR (Light Dependent Resistor), photocell, or be written 'photoresistor'.
This tutorial shows the basic use and testing of the photo resistor sensor module with Arduino. Arduino sketches show how to read the photo resistor sensor when connected to an analog input pin.
Note that there are two different pinouts for the photo resistor sensor module, depending on which kit it is from. See the photo resistor sensor module pinout for more details.
The image below shows the photo resistor sensor module used in this tutorial.
Elegoo Nano V3 Pinout
Geekcreit Photo Resistor Sensor Module
Photo Resistor Sensor Module Circuit
Important:
Before continuing, refer to the photo resistor sensor module pinout to determine the configuration of your photo resistor sensor. There are two different photo resistor sensors.
The photo resistor module can be wired to the Arduino using the 10k resistor on the module as shown in the circuit diagrams below.
Geekcreit Photo Resistor Sensor Module Circuit
Before building the circuit, it is recommended to check your module with a multimeter to make sure which pins the 10k resistor (R1) on the module is connected to.
Photo Resistor Module Connections to Arduino:
- Pin 1 (S) of the module connects to the Arduino 5V pin.
- Pin 2 of the module connects to the Arduino GND pin.
- Pin 3 (-) of the module connects to an Arduino analog input pin. Arduino analog input A0 is used in the sketches below, but can be changed.
Geekcreit Photo Resistor Sensor Module Arduino Circuit
Alternate Photo Resistor Sensor Module Circuit
If your photo resistor module is configured with the 10k resistor connected between pins 1 and 2 of the module, then use the following circuit.
Photo Resistor Module Connections to Arduino:
- Pin 1 (S) of the module connects to an Arduino analog input pin. Arduino analog input A0 is used in the sketches below, but can be changed.
- Pin 2 of the module connects to the Arduino GND pin.
- Pin 3 (-) of the module connects to the Arduino 5V pin.
Alternate Photo Resistor Sensor Module Arduino Circuit
Photo Resistor Sensor Module Arduino Sketches
Three different sketches can be found below that all use the photo resistor sensor module. All three sketches are used with the above circuits.
Photo Resistor Analog Value Arduino Sketch
The following sketch reads the analog value from the photo resistor module and sends it out of the serial/USB port of the Arduino. Use the Serial Monitor from the Arduino IDE to see the analog value.
Open the Serial Monitor window by clicking the icon at the top right of the Arduino IDE as shown in the image below and marked with a red dot.
How to Open the Arduino Serial Monitor Window
When the serial monitor window is open, make sure that the baud setting is 9600 baud as marked by the red dot at the bottom right of the above image. Values from pin A0 should be seen scrolling in the serial monitor window as shown in the image.
Light Activated LED Arduino Sketch
When the value read from the photo resistor sensor module goes below the threshold value, i.e. it becomes dark, the Arduino on-board LED is switched on. The LED is switched off when the analog value from the sensor goes above the threshold value.
A threshold value can be selected by using the previous sketch to determine the analog value at the desired light level when the LED should be triggered. The value assigned to the threshold variable at the top of the sketch can then be set to the new value.
When the photoresistor sensor is covered, blocking most light, the on-board LED should switch on. When enough light hits the sensor, the LED should switch off.
Analog Input Arduino IDE Example Sketch
Elegoo Arduino Nano Pinout
One of the example programs, called AnalogInput that comes with the Arduino IDE, can be used with the circuit in this tutorial. Find the sketch in the Arduino IDE under File → Examples → 03.Analog → AnalogInput.
Also see the Arduino Analog Input tutorial on the Arduino website that uses this sketch with a potentiometer and the above circuit from this tutorial.
The AnalogInput sketch flashes the on-board LED faster or slower, depending on the light intensity on the photoresistor module.
Donate to Starting Electronics
Arduino Uno R3 Tutorial
Arduino Modules Tutorial