Varying The Voltage On A Dio?


Is it possible to vary the voltage output by one of the digital ports? I have a laser I want to use that works best at 3.3V - more than that and the laser gets dimmer. Any suggestions (other than tying resistors in line)? I can use resistors if I have to but wondered if there was a more practical and elegant way.




why don't you put it on an ADC port?

Also, it seems that if you hooked up like a servo, as you would control the value, the voltage would change maybe?

I don't think you need to go adding diodes, resistors, etc.

servocity, I think it was that sold a 5v-3.3 adapter. It was very cheap.


There are a few places to read about your EZ-B to understand the different ports. The Tutorial section contains this useful resource:

The ADC is input (read) only. ADC stands for "Analog Digital Convertor" and reads an analog input and converts it into a digital value. For example, the ADC input is between 0 and 5 volts, this means that the value of 2.5 volts would equal the value of 128 in digital. 0 volts would be the digital value of 0. And 5 volts would be the digital value of 255.

The Digital I/O (Digital Ports) can output a specific voltage by using PWM. PWM will vary the duty cycle of the digital port, which appears like a lower voltage. The duty cycle is specified in percentage (between 0 and 100).

3.3 volts would be approx 60%

However, I would recommend using a voltage regulator and switching transistor to operate the laser correctly. Digital Ports are not made for powering devices. Digital Ports are made for input and output for communication. The digital port current is very low and will not power the laser's current demand.

Use a TIP120 NPN transistor, combined with a 3.3V Regulator L4931CZ33-AP.

User-inserted image


They are called " Darlington Switching transistors , tip120" they support up to 5 amps current. Take in mind the transistor is a switch that opens to ground not positive. This was for anyone who reads this in the future. Ive done 7 circuits with them and they work very very well.


Yeah, I use the TIP 120s for all my othe switching options and I love them. I just wasn't sure what to do to regulate the voltage. Thanks all!

User-inserted image

Only 3.55 on Ebay - free shipping.


So I have found a nice buck converter for 12V to 3.3V really cheap. I will use that as the power source for my lasers and just trigger them with a DIO port. Just like my LED blinker circuits. Thanks!


How much current will a digital port on the EZB supply? I have two micro motors I want to just turn on and off with an EZ script and they will only be turning in one direction. I was hoping to just run them to a digital port's Sig pin and it's ground pin. I do have a open side of a double H-bridge I could use but wanted to keep it simple.


The AIO ports are 5V and can drive small servos so I don't see why you couldn't do that.


The Digital Ports are 5 volts and are not for power anything. They do not power servos. Servos are powered by the +5 and GND, not the signal. The reason they are called "Digital Ports" is because they are ON or OFF ports for communication and signal. No microcontroller can power anything from it's digital ports.

You may reat this tutorial page to understand the ports on your EZ-B:

Use a TIP120 for switching to power external devices Smile


My Error, I look at all three pins as the port - and not just the communication pin. Sorry for my confusion.