Black Lives Matter - Action and Equality. ... Adafruit joins the Stop Hate for Profit campaign.

PWM (analogWrite) to analog voltage ?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

PWM (analogWrite) to analog voltage ?

by nonrelated on Sun Apr 20, 2008 11:29 am

Im currently working on a Arduino controlled gamecontroller and my idea is that the arduino should control the analog joysticks on my gamecontroller - but it seems almost imposible for me to get it working ?!
Is there a good way to:
1. make arduinos PWM into analog volt ?
2. scale this output down to the gamecontrollers voltage ?
and if is it possible to power the arduino from the gamecontroller ?
im using a standard gamepad with an usb cable

the reason i would like the arduino to control the gamepad is that i want to ad an 3-axis accelerometer to the gamepad so that i will get acceleraometer data in as HID data .. i can then use them in the game im working on (see link: (sorry that its in danish)) ..
the acceleraometer-breakoutboards i ordered from somewhere in sweden gives an analogue output between 1.66 and 1.99 volt that is why i will send them through the arduino -- to scale them to another value ..

hope someone knows the answers to my question

best reggards
Posts: 1
Joined: Sun Apr 20, 2008 11:14 am
Location: denmark

by Entropy on Fri Apr 25, 2008 12:32 pm

Use an RC lowpass filter, or possibly an active opamp filter. Set the cutoff frequency well below the PWM frequency. (Maybe make the cutoff 100 Hz or so?)

You should be able to power the Arduino directly from the 5v available in the controller. Don't go through the voltage regulator on the Arduino/Boarduino board, power it directly with +5v.

Also, if you just want accelerometer input into an HID device, you might want to take a look at the AVR-USB project.
Posts: 472
Joined: Tue Jan 08, 2008 12:43 am
Location: Owego, NY USA

Please be positive and constructive with your questions and comments.