Intel® Makers
Intel® Edison, Intel® Joule™, Intel® Curie™, Intel® Galileo
Announcements
Welcome - This is a Peer-to-Peer Forum only. Intel has discontinued these products but you may find support from other customers on this Forum
9867 Discussions

AnalogWrite in Eclipse Workspace

COkon
New Contributor I
1,358 Views

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

analogWrite(3, 127);

 

Thanks in Advance

 

1 Solution
Diego_V_Intel
Employee
102 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
Diego_V_Intel
Employee
103 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

COkon
New Contributor I
102 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

Diego_V_Intel
Employee
102 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

COkon
New Contributor I
102 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!

Reply