Суть в следующем. Есть код для Ардуины :

PHP код:
void setup()
{
   
Serial.begin(9600);
}

void loop() 
{
   for(
int x 1100001)
  {
   
Serial.println(x);
    
delay(1000);
  }

Думаю в комментариях необходимости нет, но все-же, данная программа считает до 10 000 с промежутком в 1 секунду и выводит цифры в SerialPort.

Так же, есть код написанный на С++ в VS 2010 Express (Windows Forms), который читает данные с Ардуины.

PHP код:
#pragma once

namespace Arduino_Read {

    
using namespace System;
    
using namespace System::ComponentModel;
    
using namespace System::Collections;
    
using namespace System::Windows::Forms;
    
using namespace System::Data;
    
using namespace System::Drawing;
    
using namespace System::IO::Ports;

    
/// <summary>
    /// Сводка для Form1
    /// </summary>
    
public ref class Form1 : public System::Windows::Forms::Form
    
{
    public:
        
Form1(void)
        {
            
InitializeComponent();
            
//
            //TODO: добавьте код конструктора
            //
        
}

    protected:
        
/// <summary>
        /// Освободить все используемые ресурсы.
        /// </summary>
        
~Form1()
        {
            if (
components)
            {
                
delete components;
            }
        }
    private: 
System::Windows::Forms::Button^  button1;
    private: 
System::Windows::Forms::Button^  button3;
    private: 
System::Windows::Forms::Button^  button2;
    private: 
System::Windows::Forms::Label^  label1;
    private: 
System::Windows::Forms::Label^  label2;
    private: 
System::Windows::Forms::Label^  label3;
    private: 
System::Windows::Forms::Label^  label4;
    private: 
System::IO::Ports::SerialPort^  serialPort1;
    private: 
System::ComponentModel::IContainer^  components;

    protected:
    
    private:
        
/// <summary>
        /// Требуется переменная конструктора.
        /// </summary>


#pragma region Windows Form Designer generated code
        /// <summary>
        /// Обязательный метод для поддержки конструктора - не изменяйте
        /// содержимое данного метода при помощи редактора кода.
        /// </summary>
        
void InitializeComponent(void)
        {
            
this->components = (gcnew System::ComponentModel::Container());
            
this->button1 = (gcnew System::Windows::Forms::Button());
            
this->button3 = (gcnew System::Windows::Forms::Button());
            
this->button2 = (gcnew System::Windows::Forms::Button());
            
this->label1 = (gcnew System::Windows::Forms::Label());
            
this->label2 = (gcnew System::Windows::Forms::Label());
            
this->label3 = (gcnew System::Windows::Forms::Label());
            
this->label4 = (gcnew System::Windows::Forms::Label());
            
this->serialPort1 = (gcnew System::IO::Ports::SerialPort(this->components));
            
this->SuspendLayout();
            
// 
            // button1
            // 
            
this->button1->Location System::Drawing::Point(19731);
            
this->button1->Name L"button1";
            
this->button1->Size System::Drawing::Size(7550);
            
this->button1->TabIndex 0;
            
this->button1->Text L"Open Port";
            
this->button1->UseVisualStyleBackColor true;
            
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
            
// 
            // button3
            // 
            
this->button3->Enabled false;
            
this->button3->Location System::Drawing::Point(197186);
            
this->button3->Name L"button3";
            
this->button3->Size System::Drawing::Size(7550);
            
this->button3->TabIndex 2;
            
this->button3->Text L"Read Port";
            
this->button3->UseVisualStyleBackColor true;
            
this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
            
// 
            // button2
            // 
            
this->button2->Enabled false;
            
this->button2->Location System::Drawing::Point(197108);
            
this->button2->Name L"button2";
            
this->button2->Size System::Drawing::Size(7550);
            
this->button2->TabIndex 1;
            
this->button2->Text L"Close Port";
            
this->button2->UseVisualStyleBackColor true;
            
this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
            
// 
            // label1
            // 
            
this->label1->AutoSize true;
            
this->label1->Location System::Drawing::Point(1231);
            
this->label1->Name L"label1";
            
this->label1->Size System::Drawing::Size(8113);
            
this->label1->TabIndex 3;
            
this->label1->Text L"Temperature IN";
            
// 
            // label2
            // 
            
this->label2->AutoSize true;
            
this->label2->Location System::Drawing::Point(14031);
            
this->label2->Name L"label2";
            
this->label2->Size System::Drawing::Size(3713);
            
this->label2->TabIndex 4;
            
this->label2->Text L"read...";
            
// 
            // label3
            // 
            
this->label3->AutoSize true;
            
this->label3->Location System::Drawing::Point(1267);
            
this->label3->Name L"label3";
            
this->label3->Size System::Drawing::Size(9313);
            
this->label3->TabIndex 5;
            
this->label3->Text L"Temperature OUT";
            
// 
            // label4
            // 
            
this->label4->AutoSize true;
            
this->label4->Location System::Drawing::Point(14067);
            
this->label4->Name L"label4";
            
this->label4->Size System::Drawing::Size(3713);
            
this->label4->TabIndex 6;
            
this->label4->Text L"read...";
            
// 
            // Form1
            // 
            
this->AutoScaleDimensions System::Drawing::SizeF(613);
            
this->AutoScaleMode System::Windows::Forms::AutoScaleMode::Font;
            
this->ClientSize System::Drawing::Size(284262);
            
this->Controls->Add(this->label4);
            
this->Controls->Add(this->label3);
            
this->Controls->Add(this->label2);
            
this->Controls->Add(this->label1);
            
this->Controls->Add(this->button3);
            
this->Controls->Add(this->button2);
            
this->Controls->Add(this->button1);
            
this->Name L"Form1";
            
this->Text L"Form1";
            
this->ResumeLayout(false);
            
this->PerformLayout();

        }
#pragma endregion
    
private: System::Void button1_Click(System::Object^  senderSystem::EventArgs^  e)
             {
             if(!
this->serialPort1->IsOpen)
                    {
                        
this->serialPort1->PortName="COM3";
                        
this->serialPort1->BaudRate=Int32::Parse("9600");
                         
this->serialPort1->Open();
                        
this->button1->Enabled false;
                           
this->button2->Enabled true;
                        
this->button3->Enabled true;
                    }
             }
    
    private: 
System::Void button2_Click(System::Object^  senderSystem::EventArgs^  e
             {
                        
this->serialPort1->Close();
                        
this->button1->Enabled true;
                           
this->button2->Enabled false;
                        
this->button3->Enabled false;
            }
    private: 
System::Void button3_Click(System::Object^  senderSystem::EventArgs^  e)
             {
              if(
this->serialPort1->IsOpen){
              try{
              
this->label2->Text=this->serialPort1->ReadLine();
              }
              catch(
TimeoutException^){
               
this->label2->Text="Timeout Exception";
              }
              
              }
              else
              
this->label2->Text="Port Not Opened";
              }
             
    };

Получается вот-что:

Нажмите на изображение для увеличения. 

Название:	form1.png 
Просмотров:	1496 
Размер:	8.0 Кб 
ID:	15766

Все работает. НО!!! Не так, как хочется! Данные с Ардуины отображаются (обновляются) только при нажатии кнопки Read Port. А хочется, чтобы обновлялись автоматически. Кто нибудь помогите пожалуйста решить эту проблему.