I have an annoying problem with my Arduino and PHP server. I want send a value using PHP to port COM with Windows using a simple serial communication.
I tried everything , even deleting the
fclose
of the PHP code, or change the value send of'1' > "1"
or1
. But the communication of the Arduino never activatedI put another LED for trying "debug" and that LED works but other doesn't.
The PHP code.
<?php
$fot = fopen("com1", "r+");
sleep(3);
fwrite($fot, '1');
?>
The arduino code
int numero = -5;
void setup() {
// put your setup code here, to run once:
Serial.begin(57600);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
}
void loop() {
if(Serial.available() > 0){
numero = Serial.read();
digitalWrite(11, HIGH);
}
if(numero == "1"){
digitalWrite(12, HIGH);
}
Serial.println(numero);
delay(1000);
}
- the led on pin 11 works. And the entire code work on the serial monitor but with data send from php only the led 11 works.