I am currently working on an arduino mega driving RGB led on PWM ports my project consists as follows
Arduino Mega with SD card reader & 6 PWM output , the arduino will load the values of PWM channels 1 to 6 from a text file on the SD card each file contains 3 channels RGB .
//////////////////Contents of text file on Sd card below
//RED PWM VALUE
RED3 = 255
//GREEN PWM VALUE
GREEN3 = 255
//BLUE PWM VALUE
BLUE3 = 255
As for the arduino part i have the code running and works fine but now I would like to implement same thing running on Arduino and convert it to C++ to use it in a windows application i am doing to generates the text files to place in SD card.
Below code that works for me on Arduino :
void LOAD_CH1_PWM(){
Serial.println(F("Loading Channel 1 PWM Values ....... "));
// Open the settings file for reading:
commandFile = SD.open("RGB1.txt");
char character;
String description = "";
String value = "";
// read from the file until there's nothing else in it:
while (commandFile.available()) {
character = commandFile.read();
if(character == '/') {
// Comment - ignore this line
while(character != '\n'){
character = commandFile.read();
};
}
else if(isalnum(character)) { // Add a character to the description
description.concat(character);
}
else if(character =='=') { // start checking the value for possible results
// First going to trim out all trailing white spaces
do {
character = commandFile.read();
}
while(character == ' ');
if(description == "RED1") {
value = "";
do {
value.concat(character);
character = commandFile.read();
}
while(character != '\n');
String1 = value;
RED1 = String1.toInt();
}
else if(description == "GREEN1") {
value = "";
do {
value.concat(character);
character = commandFile.read();
}
while(character != '\n');
String2 = value;
GREEN1 = String2.toInt();
}
else if(description == "BLUE1") {
value = "";
do {
value.concat(character);
character = commandFile.read();
}
while(character != '\n');
String3 = value;
BLUE1 = String3.toInt();
}
else { // unknown parameter
while(character != '\n')
character = commandFile.read();
}
description = "";
}
else {
// Ignore this character (could be space, tab, newline, carriage return or something else)
}
}
// close the file:
Serial.print(F("RED 1 VALUE "));
Serial.println(RED1);
Serial.print(F("GREEN 1 VALUE "));
Serial.println(GREEN1);
Serial.print(F("BLUE 1 VALUE "));
Serial.println(BLUE1);
String1 = "";
String2 = "";
String3 = "";
commandFile.close();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
How can I convert the above code to use it in Visual studio Express 2010 C++ in the form i am making.
attached also I posted a picture of my form application