I want make communication between arduino and visual basic 6 through serial com.
For Send character frm vb6 to arduino its working.the LED function properly.
But for function arduino send to vb6 got problem.
Once i push the button,i check in vb,i no receive "c" or any response that should send frm arduino.
my arduino program as below:
//LED
int led= 9;
//_________________________
//BUTTON
// digital pin 2 has a pushbutton attached to it. Give it a name:
int pushButton = 2;
//_________________________
void setup()
{
Serial.begin(9600);
pinMode(led, OUTPUT);
pinMode(pushButton, INPUT);
}
void loop()
{
if (Serial.available())
//---------------------OUTPUT--------------------------------------
{
int COMRead = Serial.read();
if (COMRead=='a')
{
digitalWrite(led,LOW);
}
else if(COMRead=='b')
{
digitalWrite(led,HIGH);
}
//-------------------INPUT------------------------------------------
// read the state of the pushbutton value:
//buttonState = digitalRead(buttonPin);
else if (pushButton == HIGH)
// Serial.write('c');
//int bytesSent = Serial.write("hello"); //send the string "hello" and return the length of the string
// read the input pin:
{
Serial.write(45); // send a byte with the value 45
int bytesSent = Serial.write("c"); //send the string "c" and return the length of the string.
}
}
}
I use VB6 quite a bit for front-ending Arduino. One thing I have found to be useful, that by-passes everything built in to protect us from ourselves, is to have the comm port in VB configured for InputMode equal to 1 - comInputModeBinary.
You get past all the inherent checking, blah, blah, blah and end up dealing with a simple bit stream. Works (tested) to 1Mbps.
it is very unlikely that two will ever equal one.
Did you forget a digital read?
@OP
Have you taken care of the above comment – Did you forget a digital read?
Look at the following figure and observe that the MCU/program does not see your pushButton. The MCU reads the pin-value (via gate G2D). The pin-vale (DPin-2) assumes LH if the pushButton (K1) is closed, and it assumes LL if the pushButton (K1) is at open position. (Assuming that you have installed external pull-down resistor.)
GolamMostafa: @OP
Have you taken care of the above comment -- Did you forget a digital read?
Look at the following figure and observe that the MCU/program does not see your pushButton. The MCU reads the pin-value (via gate G2D). The pin-vale (DPin-2) assumes LH if the pushButton (K1) is closed, and it assumes LL if the pushButton (K1) is at open position. (Assuming that you have installed external pull-down resistor.)
GolamMostafa: @OP
Have you taken care of the above comment -- Did you forget a digital read?
Look at the following figure and observe that the MCU/program does not see your pushButton. The MCU reads the pin-value (via gate G2D). The pin-vale (DPin-2) assumes LH if the pushButton (K1) is closed, and it assumes LL if the pushButton (K1) is at open position. (Assuming that you have installed external pull-down resistor.)