Is there a PWM bit?


maybe I have overlooked it, but I couldn’t find a pwm bit. I mean something where you apply an analog voltage to the input snap and get a fixed frequency signal with a modulated duty cycle, depending on the input voltage, between 0% and 100%.

I would suggest a selectable linear or logarithmic relationship, to drive also a LED with the human-eye based theory of how human perceive the brightness.

Hi @SeventhDwarf,
There is one PWM bit, the little servo is using a PWM signal on pin 1 of the servo connector with a duty cycle controlled by the DC voltage level on the SIG (input) connection, or with a swinging cycle, depending on the position of the little switch on the servo bit.
The range cannot be adjusted, the pulse train is internally generated by a little Attiny 45 controller with its program designed especially for the servo …

See this diagram:

Maybe you still could tinker with it…

And of course, the Arduino bit can be programmed to provide 2 pwm outputs on the d5 and d9 bitSnaps.

1 Like

Hello @alexpikkert and @chris101,

thanks very much for your suggestion.
The servo bit is of course a pwm generator. However, the frequency is about 100Hz with a pulse width between 0.8ms and 2.1ms ( with an input voltage from 0V to 5V ). This is what you would expect to drive a servo.
Related to PWM in percentage this is a range from 8% to 21%. From a PWM bit you would expect a range from about 0% to 100%, or at least 5% to 95%. @chris101 is right, you can do this easily with the Arduino bit and if you really require two PWM signals and maybe some additional functionality this is the right choice. For a simple single PWM signal I think it is an overshoot.
My proto of a PWM bit is almost finished and I will present it soon under my projects.


A new bit - cool!

How would you use this in a littleBits circuit? I imagine there could be many applications (like to drive a stepper motor, or a larger servo …? :smile: )

Ok, here it is PWM bit for LEDs

Honestly speaking I’m not satisfied with the result. So, let’s call it v1.0.
It works as expected for a LED or something similar, but it wont work for a servo. You can see it in the second video that the servo is not keeping stable. I assume that’s because of the internal oscillator, which typically has some tolerances. Additionally the ADC might have some disturbance.

The version 2 will have a crystal and a three way switch ( or how would you call a switch with three positions? ) One can select linear, exponential and servo output. What do you think?

1 Like

I like it @SeventhDwarf! It’s nicely compact & simple. In fact ALL of your projects look great!

As for the servo noise, do you think running the output through a transistor, or even an op-amp might help? The ideal solution would be to use an external power supply, but that would add considerable complexity and decrease the accessibility. The internal oscillator of the (is that a tiny 85?) is an RC circuit, but I don’t think it’s the source of the noise. But to check it out, you could use a ceramic oscillator - they’re small & easy to solder onto existing circuits (of course, you’d need to reprogram the fuse of the Tiny.)

Hi @SeventhDwarf,
In the Littlebits diagram the servo is connected via a 100 Ohm resistor and it has a 47 uF capacitor directly connected to its power supply connections.
Maybe this could decrease the instability of your servo?

1 Like

Hi @chris101 & @alexpikkert,

thank you both for your hints and suggestions. I will try all of them the next days and let you know the result. I will anyway make a version 2.0 with a crystal, add the series resistor and a larger capacitor.

btw, yes I used an ATtiny85, even a ATtiny25 would be sufficient. In this sense I basically followed chris idea to use an Arduino, just made it smaller. I once used a linear tech LTC6992. This is a great device, but only available in SMD and quite expensive when you buy only small quantities. That’s why I use the ATtiny.


Hi @SeventhDwarf! :slight_smile: What does the slide switch do in V 1.0?

Hi @JackANDJude, with the switch you can select between linear ( red ) and exponential transfer curve ( blue ) for the voltage to duty cycle ration. Latter is better to drive a LED, due to the way the human eye sense light.

1 Like

OK, I checked the servo issue.
Today I had some equipment to verify that the servo, even the small one from littleBits, generates a lot of noise on the power supply. This is not a good idea, if you have an ADC connected to it. Therefore the ADC has always bad readings which results in the toggling of the servo.
The original design also used an ATtiny45, but has some clever averaging algorithm, so that the power line noise and the noisy ADC readings does not influence the servo pulse width.
So, for v2.0 I would apply a similar concept. The additional 47µF capacitor did not help.

1 Like