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.
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.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);
pinPWM()
and you're ready to go.This function makes PWM control on CodeCell more flexible and easier than ever. Try it out in your next project!
Join our Community ~ Be the first to know about new products and get exciting deals!
© 2025 Microbots.