Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example for pwmWrite? #77

Open
hnoesekabel opened this issue May 14, 2017 · 3 comments
Open

example for pwmWrite? #77

hnoesekabel opened this issue May 14, 2017 · 3 comments

Comments

@hnoesekabel
Copy link

Hi,

apologies for a newcomer question, but I was unable to find example code how to pwmWrite to a LED. My setup looks correct, and running Sunfounder Python code (04_pwmLed.py from the Superkit 2 code snippets) lets the LED pulse as expected.

With WiringPi-Node, I'm running the following snippet on my Pi 3:

'use strict';
var wpi = require('wiringpi-node');
wpi.setup('wpi');

wpi.pinMode(1, wpi.PWM_OUTPUT);
wpi.pwmWrite(1, 0);

...which lights up the LED but as soon as I run it, my Rasperry Ext4 filesystem crashes and the only option is to pull the plug. Google results suggest that these Ext4 FS errors occur due to power supply issues - as they do not occur with the Python code, and it's an power supply coming with a standard Rasperry Pi kit, I'd assume it's not hardware related.

Any ideas what's wrong? Any initialisation I skipped? Any code samples I could try? Is there a repository of more WiringPi-Node examples? Any pointers are appreciated.

Thanks!

@carterw
Copy link

carterw commented May 15, 2017

Do you have a resistor in series with the LED?

@RichardChambers
Copy link

RichardChambers commented Nov 26, 2017

Are you running it with sudo? I ran into a similar problem with C using the PWM with GPIO 18 in that I had a program using PWM with an LED circuit and my Raspberry Pi with Raspbian crashed every time I tried to run it.

Then I discovered I needed to use sudo to run the program because the wiringPi library required administrator or root access to the PWM hardware.

I am using the Osoyoo Raspberry Pi Starter Kit (see http://osoyoo.com/2016/04/12/raspberry-pi-3-s/) and the lessons on the Osoyoo web site. I am doing the C language examples with wiringPi library.

@michaeljanich
Copy link

Sounds like a power problem to me. Get a bigger power source (1.5A)

And yes, have a 47Ohm resistor in series with the LED.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants