Go Down

Topic: Visual studio Express 2010 C++ (Read 650 times) previous topic - next topic

gcharles

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

PaulS

Quote
How can I convert the above code to use it in Visual studio Express 2010 C++  in the form i am making.

You can't. There is so much there that is bound up in the way that the Arduino works that makes no sense on a PC.

What part(s) of it do you want to make the responsibility of the application on the PC?

gcharles

Thanks for the input


I just want to be able to open the txt file and write the 3 values in their corresponding label on my form application in visual studio C++

sureshn

You can save the rgb values to SD card in arduino.  To display your saved data in arduino to your C++ application, serial out the rgb files from the SD card to your application.  In your application, read the values into your application's data structure.  Display the data in the form fields.

Agsabh

Thank for the info, I'am just a beginner webmaster ... want to know about pc programing  :)

Robin2

Presumably the rgb data is stored in a text file on the SD card.

If you have an SD card reader attached to the PC it should be possible to read or write the file with any text editor (but don't use a wordprocessor that may insert all sorts of funny formatting characters).

...R

Go Up