S
S
Sprite1052014-07-11 09:30:46
PHP
Sprite105, 2014-07-11 09:30:46

Why can't PHP write a value to arduino ?

In general, there is an arduino uno (made in china of course...) and so, I connected it to a PC, it was defined as com3, put the script and everything works with a bang!
Here is the php:

<?
$fp = fopen("com17", "w");
fwrite($fp, chr(1));
fclose($fp);
?>

Here is the sketch:
const int ledPin7 = 12;

void setup() {
pinMode(ledPin7, OUTPUT);
 Serial.begin(9600);
  digitalWrite(ledPin7, LOW);
  
}
void loop() 
{
    
    if (Serial.available() > 0) 
    {
        byte x = Serial.read();
        if (x == 1)
        {
        digitalWrite(ledPin7, HIGH);
        }
    }
}

But, when connecting the fool to the laptop, it was defined as com17. I put the same script, I did everything as on a PC, but the 1st is not transferred to Durin.
If you run something from the basic examples - it works.
If in php replace
$fp = fopen("com17", "w");
with
$fp = fopen("com3", "w");
then php knocks out an error that such a directory was not found.
This means that it sees COM17, but cannot transmit values ​​... Tell me
, what's the matter?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
svd71, 2014-07-11
@Sprite105

"Sho, again???" ©
1. Try to call in the pipe format: "COM17:" - in capital letters and another variant with a colon at the end.
2. Enter the device settings, then change 17 to 1,2,3 in the comport properties. But no more than 5. Not all programs work the same way with an extended list of ports.
3. Windows is not a very good idea for a server in particular. The difference with Linux is that it is configured in Linux and will always work. And in Windows constantly dancing with a tambourine.

N
Nazar Mokrinsky, 2014-07-11
@nazarpc

Maybe something with permissions?
What OS?

S
Sprite105, 2014-07-11
@Sprite105

Everything worked out by reinstalling EVERYTHING, svd 71's advice on renaming the port helped a lot! Thanks to !
@svd71
It works like this:
com2
and so
COM2
and so
COM2:

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question