Hi again,
Not sure what you mean by 'Firmata is not working'!?! I'm assuming you mean it is not working for you and as your post suggests it is not working for you in the way you would like it to. With Firmata running on your Arduino and using the FirmataVB component you could easily implement a small program in VB.NET or C#.NET to send PWM to any/all of the 6 PWM pins on the Arduino. The issue is then one of knowing how to write the .NET application. Forgive me if i'm wrong on this but it seems that is where you're looking for support.
To 'simply' control your LEDs you don't, of course, need to use Firmata. You do however need to create your own protocol and write not only the Arduino sketch to receive it but to write the VB.NET application as well. You've made a start with the Arduino sketch.
A few comments on your Arduino sketch first:
You appear to be trying to set the value of Pin 13 to 255. Pin 13 is not a PWM pin so to turn it on you'd use digitalWrite(ledboot_ok, HIGH) and to turn it off you'd use digitalWrite(ledboot_ok, LOW).
It looks like you want to send values of 1000 - 1225, 2000 - 2225, 3000 - 3255 to the Arduino from your computer. Any of these values would require you to send 2 bytes. Nothing wrong with that but using com = Serial.read() will only read the first byte you send and as your code stands all of the if statements would be false all of the time.
If you're going to write your own sketch (rather than using Firmata) you will need to write it to accept at least 2 bytes at a time.
Something like the following might work:
if (Serial.available())
{
// read the first byte (1, 2 or 3)
LEDtoSet = Serial.read();
delay(100); // this line may not be necessary
// read the next byte (0 - 255)
PWMvalue = Serial.read();
// code here to then set the LED PWM value
analogWrite(LEDtoSET, PWMvalue);
}
Doing it that way you'd have to send 3 seperate 2 byte messages from your computer to set the LEDs. An alternative approach would be to have the Arduino sketch accept a 4 byte message. The first byte would be the RGB 'cluster' number then the next 3 bytes would be the R, G & B values. Slightly more complex Arduino sketch but would cut down on data sent and be easier to implement in VB.
In Visual Basic (or C#) a simple program that does the following would work:
- Configure a serial port with the name of the port your using and the baud rate your using
- Open the serial port
- Send the bytes you want to send
I'd include a some VB code for you but work beckons.
Cheers,
Andrew Craigie