Arduino PWM Visual C#

Hello everyone,

I am new on this forum, and maybe someone can help me with a problem.
I am trying to change a program to control an arduino mega from computer program. I must tell you I am a beginner in programming.

The problem is I want to control pin 2 of an arduino mega with computer software (PWM) and I don't know how do do it
Thank you in advance for help!
Below is the arduino program and visual c# files

ArduinoCompurerCommunication.zip (745 KB)

What is in the huge ZIP file? I don't like opening unknown ZIP files.

If you want help with an Arduino program why not just post the .ino file?

...R

Hello ,
I have attached the ino file and a text with visual studio program.

ArduinoCompurerCommunication.ino (3.93 KB)

Visual studio.txt (6.7 KB)

Your Arduino program is not using Pin 2 for anything.

You need to provide more information about what you are trying to achieve.

...R

I just want to control, for example pin 2 of arduino mega with PWM.

Then you need a line of code like this

analogWrite(2, N);

where N is a value from 0 to 255

If that is not the sort of answer you are looking for you should re-read Reply #3 and think of the bigger picture.

...R