Now we will build our C# app, create a new winforms project and a panel from the toolbox, also add a serialport and colordialog control.

Now when you click on the panel a Color dialog box will appear, selecting a color will send those color details to the Arduino which will try and display the appropriate color, this is not perfect so some of the more unusual colors will not be an exact match.

In this example we connect an LDR to analog 0 and depending on the value read in we then vary the brightness of an LED connected to Pin 9 using PWM.

The input read from the analog pins will be in the range 0 to 1023. But the PWM function has a the width parameter ranging from 0 to 25 so in this case we use the map() function to convert the values ranging from 0-1023 to 0-255.