Pages: 1 [2] 3   Go Down
Author Topic: Arduino PHP Communication  (Read 4441 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 63
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So these right here, you'll need to change the numbers to reflect whatever pins your servos are connected to.

Code:
const int rightPIN=5;  //right servo
const int leftPIN=3;   //left servo
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 63
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

About the testlog.txt you can take that part out.  I am trying to send data from a temperature sensor from the arduino to the web and it looks like I"m going to need an Arduino Mega to do that because one serial port doesn't seem to cut it.  

There is about 6 or 7 lines int he php file dealing with reading from the txt file.  You can just take that out if you wish.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi mate,
I did check the pin assignments before I uploaded and changed it accordingly.  erm I have not tried to light up an LED from a php code. I don't have a spare LED smiley-sad.. does the Arduino have an onboard one?.

I do get message display at the top of the page whenever I press a button, e.g. "The Guardino!Reverse Value = S SentLast Log Entry: Date: Time: Value:"..

I installed Apache XAMPP, should I have installed WAMPSERVER?..
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 63
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would imagine that XAMPP should work...though not sure if it has a php server??  But it sounds like the php code is functioning properly.

I believe pin 13 is the onboard LED.  

You might also try downloading "Processing."  It has the same interface as the Arduino and has some built in example sketches to send serial data to the arduino.  It's very easy to read serial data in that manner and therefore can help confirm where your trouble lies...either in the receiving or transmitting of the data over the serial port.

Change the LEDpin in my arduino code to 13 to see if I'm right about that on board LED.  It should blink when it's not receiving any serial data so that can help you trouble shoot.  If you press one of the buttons in php and the light doesn't go out, then the serial data isn't being recognized.
« Last Edit: January 24, 2010, 12:38:14 pm by linusb212 » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


I changed the pin assignment for the LED in the Arduino code and uploaded it.  As you said, it the LED blinks repeatedly, then when I click a button it goes out.  The repeated blinking does come back on after a few secs though.

I guess it's sending serial data to the Arduino, only it'snt doing anything for my servos.  I am baffled.  
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 63
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.


Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 63
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.  
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Quote
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  smiley.
« Last Edit: January 24, 2010, 01:16:49 pm by nurain » Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 63
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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 smiley-sad.. Still no reaction when I press the buttons.  My servos work perfectly with code to automatically control the functions.

Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 63
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset



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..

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?

Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9470
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
My project is coming to an end and still unable to control the functions using PHP..
Ever consider dumping PHP?
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

0
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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.
Logged

Pages: 1 [2] 3   Go Up
Jump to: