Pages: [1]   Go Down
Author Topic: Visual studio Express 2010 C++  (Read 641 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


* Untitled.jpg (31.95 KB, 306x520 - viewed 24 times.)
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 653
Posts: 50921
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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++
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
Webmaster berikhtiar.com : Indonesia Fashion Store
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

UK
Offline Offline
Tesla Member
***
Karma: 141
Posts: 8015
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: [1]   Go Up
Jump to: