Menu
Microbots
0
  • Robots & Kits
    • ProtoBot
    • CubeBot
    • Robot Parts
  • Modules & Parts
    • CodeCell ESP32 Modules
    • Motors & Actuators
    • LiPo Batteries
  • Gear
    • Tools
    • Merch
  • Learn
    • User Guide & Tutorials
    • DIY Projects & Files
    • Education Discounts
  • About
    • Our Story
    • Reach Out
    • FAQs
  • Sign in
  • Your Cart is Empty
Microbots
  • Robots & Kits
    • ProtoBot
    • CubeBot
    • Robot Parts
  • Modules & Parts
    • CodeCell ESP32 Modules
    • Motors & Actuators
    • LiPo Batteries
  • Gear
    • Tools
    • Merch
  • Learn
    • User Guide & Tutorials
    • DIY Projects & Files
    • Education Discounts
  • About
    • Our Story
    • Reach Out
    • FAQs
  • 0 0

CodeCell: Set Up a PWM in Seconds

Pulse Width Modulation (PWM) is essential for controlling LED brightness, motor speed, and even generating audio signals. With CodeCell, setting up PWM is incredibly simple using the pinPWM() function. Unlike traditional Arduino PWM that requires predefined pins and extra setup, CodeCell allows you to enable PWM on any of its 6 available pins effortlessly.

How to Use pinPWM()

To generate a PWM signal, use:

myCodeCell.pinPWM(uint8_t pin_num, uint16_t pin_freq, uint8_t pin_dutycycle);
  • pin_num → The pin you want to use (any of CodeCell's 6 available GPIOs).
  • pin_freq → The frequency of the PWM signal (in Hz).
  • pin_dutycycle → The duty cycle (0–100), representing the percentage of time the signal stays HIGH.

Example: Dimming an LED

Let’s say you want to dim an LED connected to pin 3 with a 1 kHz (1000 Hz) frequency and 50% brightness:

myCodeCell.pinPWM(3, 1000, 50);

To make the LED brighter (e.g., 80% brightness):

myCodeCell.pinPWM(3, 1000, 80);

Or to turn it off (0% brightness):

myCodeCell.pinPWM(3, 1000, 0);

Why Use This Function?

  • Works on Any of CodeCell’s 6 GPIOs - no restrictions.
  • No extra setup required - just call pinPWM() and you're ready to go.
  • Adjustable frequency and duty cycle - perfect for LEDs, motors, and more.

This function makes PWM control on CodeCell more flexible and easier than ever. Try it out in your next project!  

  • Share:

Follow

Github

  • About
  • Software
  • Education
  • Contact
  • FAQs
  • Terms
  • Refund Policy
  • Privacy Policy

Join our Community ~ Be the first to know about new products and get exciting deals!

© 2026 Microbots.

★ Reviews

Let customers speak for us

87 reviews
Write a review
87%
(76)
5%
(4)
2%
(2)
2%
(2)
3%
(3)
81
21
A
CodeCell C3
Anonymous

Perfect product!

A
ProtoBot
Anonymous

This is a great product for beginners who want hands-on experience with Arduino and 3D printing. The Protobot has a sleek, solid design, and the software is just as polished. I’ve bought several educational robotics kits, and this is the best one so far. Looking forward to more awesome products!

Thank you so much for your kind review! 😊

F
ProtoBot
Francis van Uyten

Really love this robot. I like that is simple to assemble and I like that you guys prepares it easy to start programming with examples and libraries. My opinion on what to improve is more like a add-on, can you guys develop a localisation sensor or function so it will know where the bot is. Expecting only great things coming from you guys. Succes

Thank you so much for your thoughtful review! Glad you’re enjoying ProtoBot 😊 A localisation sensor is a great suggestion! The I²C connection lets you add compatible sensors, so there’s room to explore this. Thanks for your support!

G
Experiment in Progress Mug
Gerald Kendrick

I am enjoying my Experiment in Progress coffee mug. It fits in well in the lab.

Hi Gerald, we’re so glad you’re enjoying it! Thanks for sharing your kind review.

K
12-in-1 Screwdriver (Pen-Size)
Klaas

Very useful fun little screwdriver for the all tiny stuff

Hi Klaas, thanks for the great review! We’re glad you’re enjoying your screwdriver!