Arduino AREF flashes

0

I have a very simple php code with two buttons, one to turn on and another to turn off the led.

A very simple arduino code, too.

My problem is, using the arduino ide console the program goes well, without failures, but when it comes to controlling it by php, it simply blinks 2 times the aref and led 13, next to the codes.

PHP


$comPort = "/dev/ttyACM0";
if (isset($_POST["rcmd"])) {
$rcmd = $_POST["rcmd"];
switch ($rcmd) {
     case On:
        $fp =fopen($comPort, "w");
  fwrite($fp, H); 
  fclose($fp);
  break;
     case Off:
        $fp =fopen($comPort, "w");
  fwrite($fp, L); 
  fclose($fp);
  break;
}

And Arduino:


const int ledPin = 13; // the pin that the LED is attached to - change this if you have a separate LED connected to another pin
int incomingByte;      // a variable to read incoming serial data into

void setup() { // initialize serial communication: Serial.begin(9600); // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); }

void loop() { // see if there's incoming serial data: if (Serial.available() > 0) { // read the oldest byte in the serial buffer: incomingByte = Serial.read(); // if it's a capital H (ASCII 72), turn on the LED: if (incomingByte == 'H') { digitalWrite(ledPin, HIGH); } // if it's an L (ASCII 76) turn off the LED: if (incomingByte == 'L') { digitalWrite(ledPin, LOW); } } }

    
asked by Jorge_Garza 25.09.2018 в 17:40
source

1 answer

1

I solved my problem, I leave the solution / information or if someone in the future should ask for it.

It turns out that the arduino stops receiving data through the serial port, goes into sleep mode, then looks for a way to avoid this, a way that worked for me is to place a capacitor of 22microFaradios from the input "Reset" to " gnd ", there are more solutions mentioned in this post:

link

    
answered by 26.09.2018 в 17:10