Answer the question
In order to leave comments, you need to log in
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);
?>
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);
}
}
}
$fp = fopen("com17", "w");
$fp = fopen("com3", "w");
Answer the question
In order to leave comments, you need to log in
"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.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question