• Menu
  • Robotics
    • Sensors
    • Motors
    • Motor Drivers
    • Switch Modules
    • DC-DC Converters
    • Signal Processing
    • Development Boards
    • Robot Accessories
  • 3D Printing
    • 3D Printers
    • Filaments
    • Accessories
  • IOT & Wireless
    • Wifi & Bluetooth
    • GSM /GPRS/GPS
    • RF & Xbee
  • Rc Drone
    • Flight Controls
    • Frames
    • Esc's
    • Motors
    • Battery
    • Propeller
    • TX and RX
    • Accessories
  • Arduino
    • Arduino Boards
    • Arduino Shields
    • Accessories
  • Raspberry Pi
    • Raspberry Pi Boards
    • Raspberry Pi Shields
    • Accessories
  • Actives and Passives
    • Resistors
    • Capacitors
    • Potentiometers
    • Crystal & Oscilators
    • Mirocontrollers
    • Voltage regulators
    • Transistors
    • Diodes
    • Siganal Converters(ADC-DAC)
    • OP-Amp
    • Inductors
    • Displays
    • Led Lights
    • Logic Gates
  • Electro-Mechanical
    • Solenoids
    • Switches
    • Connectors
    • Fans
    • Cables
    • Cabins & Cases
    • Heat Sink
  • Power Supplies
    • SMPS
    • Transformer
    • Protectors/Fuse
  • Tools
    • Soldering Accessories
    • Hand Tools
    • Test and Measurements
  • ATAL TINKERING LAB
    • About ATAL TINKERING LAB
    • PRODUCTS
  • +91 9061450999/9061650999
  • help@tomson.in
  • Register
Menu
0
TOMSON ELECTRONICS
    • 0
    Shop by Collection
    • Robotics
      • Sensors
      • Motors
      • Motor Drivers
      • Switch Modules
      • DC-DC Converters
      • Signal Processing
      • Development Boards
      • Robot Accessories
    • 3D Printing
      • 3D Printers
      • Filaments
      • Accessories
    • IOT & Wireless
      • Wifi & Bluetooth
      • GSM /GPRS/GPS
      • RF & Xbee
    • Rc Drone
      • Flight Controls
      • Frames
      • Esc's
      • Motors
      • Battery
      • Propeller
      • TX and RX
      • Accessories
    • Arduino
      • Arduino Boards
      • Arduino Shields
      • Accessories
    • Raspberry Pi
      • Raspberry Pi Boards
      • Raspberry Pi Shields
      • Accessories
    • Actives and Passives
      • Resistors
      • Capacitors
      • Potentiometers
      • Crystal & Oscilators
      • Mirocontrollers
      • Voltage regulators
      • Transistors
      • Diodes
      • Siganal Converters(ADC-DAC)
      • OP-Amp
      • Inductors
      • Displays
      • Led Lights
      • Logic Gates
    • Electro-Mechanical
      • Solenoids
      • Switches
      • Connectors
      • Fans
      • Cables
      • Cabins & Cases
      • Heat Sink
    • Power Supplies
      • SMPS
      • Transformer
      • Protectors/Fuse
    • Tools
      • Soldering Accessories
      • Hand Tools
      • Test and Measurements
    • ATAL TINKERING LAB
      • About ATAL TINKERING LAB
      • PRODUCTS
    • ATAL Tinkering Labs
    • Blog
    • About Us
    • Contact Us
    • New Prodcuts
    • TOMSON ELECTRONICSHome
    • News
    • NodeMCU PWM with Arduino IDE
    Article

    NodeMCU PWM with Arduino IDE

    • News
    • 04 Nov, 2019
    • Posted by: shanto shaji

    Introduction

    Pulse Width Modulation (PWM) is a technique by which width of a pulse is varied while keeping the frequency of the wave constant.

    PWM Generation

    A period of a pulse consists of an ON cycle (VCC) and an OFF cycle (GND). The fraction for which the signal is ON over a period is known as a duty cycle.

    E.g. A pulse with a period of 10ms will remain ON (high) for 2ms.Therefore, duty cycle will be

    D = 2ms / 10ms = 20%

    Through PWM technique, we can control the power delivered to the load by using ON-OFF signal. The PWM signals can be used to control the speed of DC motors and to change the intensity of the LED. Moreover, it can also be used to generate sine signals. Pulse Width Modulated signals with different duty cycle are shown below.

    NodeMCU based ESP8266 has the functionality of PWM interfaces via software programming. It is achieved with the timer interruption method. PWM frequency range for ESP8266 is adjustable up to 1KHz.

    PWM pins on NodeMCU Kit

    Arduino function for NodeMCU PWM

    analogWrite(pin, dutycycle): Enables software PWM on the specified pin. duty cycleis in the range from 0 to PWMRANGE, i.e. 1023 by default.

    analogWrite(pin, 0): Disables PWM on specified pin.

    analogWriteRange(new_range): This function is used to change PWM range (duty cycle).

    analogWriteFreq(new_frequency): PWM frequency is 1kHz by default. Call this function to change it with new frequency.PWM frequency is in the range 1 – 1000Khz.

    Example

    Let’s write an Arduino sketch to set PWM on 6thpin of NodeMCU and vary it’s duty cycle with the potentiometer connected to the ADC pin of NodeMCU. Here we connect LED on PWM pin to visualize effect (Brightness of LED) of PWM variation.

    Arduino Sketch for PWM

     

    • Twitter
    • Facebook
    • Google+

    Leave a comment

    Comments have to be approved before showing up

    Categories
    • Robotics
      • Sensors
      • Motors
      • Motor Drivers
      • Switch Modules
      • DC-DC Converters
      • Signal Processing
      • Development Boards
      • Robot Accessories
    • 3D Printing
      • 3D Printers
      • Filaments
      • Accessories
    • IOT & Wireless
      • Wifi & Bluetooth
      • GSM /GPRS/GPS
      • RF & Xbee
    • Rc Drone
      • Flight Controls
      • Frames
      • Esc's
      • Motors
      • Battery
      • Propeller
      • TX and RX
      • Accessories
    • Arduino
      • Arduino Boards
      • Arduino Shields
      • Accessories
    • Raspberry Pi
      • Raspberry Pi Boards
      • Raspberry Pi Shields
      • Accessories
    • Actives and Passives
      • Resistors
      • Capacitors
      • Potentiometers
      • Crystal & Oscilators
      • Mirocontrollers
      • Voltage regulators
      • Transistors
      • Diodes
      • Siganal Converters(ADC-DAC)
      • OP-Amp
      • Inductors
      • Displays
      • Led Lights
      • Logic Gates
    • Electro-Mechanical
      • Solenoids
      • Switches
      • Connectors
      • Fans
      • Cables
      • Cabins & Cases
      • Heat Sink
    • Power Supplies
      • SMPS
      • Transformer
      • Protectors/Fuse
    • Tools
      • Soldering Accessories
      • Hand Tools
      • Test and Measurements
    • ATAL TINKERING LAB
      • About ATAL TINKERING LAB
      • PRODUCTS
    Recent posts
    Blog
    HTTP Client on NodeMCU with Arduino IDE
    29 Nov, 2019
    Blog
    NodeMCU I2C with Arduino IDE
    12 Nov, 2019
    Blog
    NodeMCU SPI with Arduino IDE
    09 Nov, 2019
    Tags
    • All
    • arduino
    • arduino bluetooht
    • arduino boards
    • arduino wifi
    • Home Automation
    • HomeAutomation
    • iot
    • NodeMcu
    • Raspberry Pi IOT Tutorial
    • Raspberry Pi Tutorial
    • Smart Energy Meters
    Partner
    Partner
    Partner
    Partner
    Partner
    Partner
    Sign up to Newsletter
    Got questions? Call us 24/7! +91 9061450999/9061650999
    Contact info H.O TAARA MANSION, 39/4287-A & B, Manikkiri Cross Road, Pallimukku, Cochin - 682 016, Kerala, India.
    Find In Fast
    • ATAL Tinkering Labs
    • Blog
    • About Us
    • Contact Us
    • New Prodcuts
    Information
    • Privacy Policy
    • Terms & Conditions
    • Shipping/Delivery Policy
    • Return, Refund and cancellation Policy
    Customer Care
    • My Account
    • About Us
    • Shopping Cart
    • Contact Us

    © 2019 TOMSON ELECTRONICS All Rights Reserved

    Product successfully added to your Shopping Cart

    Continue Shopping
    Proceed to Checkout

      Sample Product

      • Twitter
      • Facebook
      • Google+