Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor I
1,269 Views

AnalogWrite in Eclipse Workspace

Jump to solution

I want to know how to write this on the eclipse work-space of the Intel Edison

analogWrite(3, 127);

 

Thanks in Advance

 


Accepted Solutions
Highlighted
Employee
13 Views

Hi dunex_1,

The analogWrite() method is used to generate a PWM wave. You could use the MRAA libraries to accomplish this in C/C++. I recommend you to check the following example which shows how to use the PWM with MRAA: https://github.com/intel-iot-devkit/mraa/blob/master/examples/c%2B%2B/Pwm3-cycle.cpp mraa/Pwm3-cycle.cpp at master · intel-iot-devkit/mraa · GitHub

In the following site there is additional documentation about PWM with MRAA: http://iotdk.intel.com/docs/master/mraa/classmraa_1_1_pwm.html mraa: Pwm Class Reference

Regards,

Diego

View solution in original post

4 Replies
Highlighted
Employee
14 Views

Hi dunex_1,

The analogWrite() method is used to generate a PWM wave. You could use the MRAA libraries to accomplish this in C/C++. I recommend you to check the following example which shows how to use the PWM with MRAA: https://github.com/intel-iot-devkit/mraa/blob/master/examples/c%2B%2B/Pwm3-cycle.cpp mraa/Pwm3-cycle.cpp at master · intel-iot-devkit/mraa · GitHub

In the following site there is additional documentation about PWM with MRAA: http://iotdk.intel.com/docs/master/mraa/classmraa_1_1_pwm.html mraa: Pwm Class Reference

Regards,

Diego

View solution in original post

Highlighted
New Contributor I
13 Views

Hi Diego,

But the pwm pin uses floating numbers in percentage. I want to be able to pass a value of 0 to 255 instead of a duty cycle of 0.0 to 1.0

Thanks

0 Kudos
Highlighted
Employee
13 Views

Hi dunex_1,

You could use the map() function to make the conversion from 0-255 to 0.0-1.0. The map() function is easy to program, the description of how it works can be checked in the following site: https://www.arduino.cc/en/Reference/Map Arduino - Map

Regards,

Diego

0 Kudos
Highlighted
New Contributor I
13 Views

Hi @ DiegoV_Intel

Thank you for directing me to the path. I have improved my code. Can you look at this thread and reply to it too with any suggestion please!

Thanks in advance!

0 Kudos