Intro: Send RGB to Arduino Esplora From C#
OK so I finally bought one of them thar Arduino boards. The Esplora to be exact, thanks to one of those corporate Radio Shacks that closed recently. Hope the employees are out of work for long. Good luck, sincerely.
So I went through many of the basics of using the on board switches, the acceleremeter and the on board potentiometer to control the RGB values of the RGB LED.
But since I really wanted/needed to know how to get some serial communications going and I saw some cool videos showing exactly what I wanted to do, but couldn't find any simple code for the whole process especially for the Esplora, I had to buckle down and figure it myself, but I'm sharing.
So assuming you know how to upload a sketch (arduino code file) to your board, which means you also know how to get the drivers loaded and select the proper board and proper com port. Also assuming you know enough about C# to open the file I uploaded on your system and run it. You should have little to no problems to get this running yourself.
The C# program was made in Visual Studio 2010 Express C# and it should work in the newer Visual Studio IDEs. I have on occasion had to add each file individually to a new empty project with some other people's code files to get them to load/debug correctly in VS 2010 Express. Don't be shy if you have to do the same this file.
1. download both files.
2. open both files in their respective IDEs.
3 connect the Arduino to your PC
4 verify both programs compile without errors
5 make sure you Arduino Sketch program is set to the Esplora (this code would need quite a bit of modifying to work with the other Arduino models).
6. make sure you have the com port set for the Arduino in the Arduino sketch program.
7. upload the sketch file to the Arduino.
8. you can test that is loaded by pressing the UP switch (switch 3), this will set the RGB values to 10, 10, 10 respectively.
9. then press the down switch (switch 1) to set the values to 0, 0, 0 (off).
10. now in the C# program, update the comport setting as noted in the picture above in the C# program.
11. start the C# program.
12 You should now be able to the slide the Red, Green, Blue sliders on the C# program and they should be controlling the RGB LED on the Ardunio.
The values the C# program will send will always be shown in the white textbox under the sliders.
For the advanced folks out there, yes I choose to send the values as a string not as hex values.