Arduino PHP Communication

Ok, well that is a good sign. It's just that the Arduino isn't properly interpreting the data.

If your servos aren't using PWM pins, they probably won't work in the way that I have them coded.

Quote form arduino reference pages: On newer Arduino boards (including the Mini and BT) with the ATmega168 chip, this function works on pins 3, 5, 6, 9, 10, and 11. Older USB and serial Arduino boards with an ATmega8 only support analogWrite() on pins 9, 10, and 11.

As a consolation, these are all things I should have mentioned in the beginning but being a noob myself I didn't think about them until you ran into problems and until I started thinking about what it might be is when it came to me.

In case you don't understand, the PWM pins allow signals of varying duration (I think that's the right description) instead of a simple HIGH/LOW. Analog.write commands are driving the servos, and analog.write only works with PWM pins. digital.write works on them all.

I have the ATmega328 though, so shouldn’t that work?.. All the pins you mentioned are pwm pins on the 328 too right?

As a consolation, these are all things I should have mentioned in the beginning but being a noob myself I didn’t think about them until you ran into problems and until I started thinking about what it might be is when it came to me.

Hey, no worries mate, I really appreciate your help… I am learning a lot :).

YEah, those are all PWM pins on the 328 as well. Let me know how it goes.

If you still don't have success, change those analogWrite lines to

digitalWrite (leftPIN,HIGH); digitalWrite (rightPIN,HIGH);

Have you tested your servo circuitry using a simple arduino sketch that doesn't rely on any external data. Just some basic code that moves the wheels?

YEah, those are all PWM pins on the 328 as well. Let me know how it goes.

If you still don't have success, change those analogWrite lines to

digitalWrite (leftPIN,HIGH); digitalWrite (rightPIN,HIGH);

Have you tested your servo circuitry using a simple arduino sketch that doesn't rely on any external data. Just some basic code that moves the wheels?

I am getting nowhere :(.. Still no reaction when I press the buttons. My servos work perfectly with code to automatically control the functions.

I had some problems getting the arduino to recognize certain characters sent from PHP, which is why the seemingly random usage of letters for the various controls of forward, backward, reverse. I was going to do simple A,B,C convention but it didn't recognize certain characters.

You may perhaps try defining the BYTE variable as a CHAR...I haven't tried that yet, but it's worth a try.

Hi linusb,

Sorry to bother you again but I am still having problems mate.. Any other suggestions?

My project is coming to an end and still unable to control the functions using PHP..

anybody tried transfer the data in and out a arduino thought the Ethernet shield to a server? by using PHP and MYSQL

any difference with the serial connection?

My project is coming to an end and still unable to control the functions using PHP..

Ever consider dumping PHP?

Yeah I have… but don’t really know what else to use… Others have suggested Python and Processing… Don’t even know where to start with that.

I'd suggest Python. THe syntax for the code is pretty forgiving for the most part. You can use the same IDE that you use for PHP.

You'll have to download the Python files and configure Eclipse slightly to configure it. It's not too hard. I was able to figure it out and I'm a newb at all this too.

Though before you do all that, I'd suggest you download Processing. It pretty much has the same exact interface as the ARduino so it will be very famililar and it has some ready-to-go sketches in which you can test to see if you are correctly transferring serial data from or to the ARduino. Once you know you are properly receiving or transmitting, then I suggest going to Python.

If you need interactivity through the web, you'll probably have to do like I did and use Python as a go-between with the ARuino and php becuase php's serial capabilities are limited in Windows.

If you are trying to read data from the Arduino, you'll create a python script to read the serial data and write it to a file and then your php script can read the data from a file easily enough and display it on web page.

If you're sending data to the arduino, you do the opposite: use php to write whatever data/code is needed to a file, have Python running in the background which will read the file and then send whatever contents to the aRduino via serial.

By my novice perspective, other than Processing, Python is the easiest way to communicate with the Arduino's serial port.

Just start with very basic stuff so you know whether or not you are reading/sending serial data as intended and then troubleshoot as you get more sophisticated.

Post up just what strings or bytes you are trying to send to the arduino including line feeds and carrage returns if used (don’t include any PHP stuff) and I’ll see if I can show you how I would do it.