Reputation: 23
Is it possible to control an Arduino Uno with a PHP webpage?
Upvotes: 3
Views: 1597
Reputation: 1894
Yes, you can. You can connect your Arduino via USB to your server, and use phpSerial.
Or you can connect to your Arduino with an Ethernet shield. In PHP you can open a stream to your Arduino.
You can write your own protocol to communicate, for example:
To read the value of an analog input:
rA0
followed by ('\n').rA0
: and sends the value of analog input A0 back in ASCII followed by a newline ('\n').A little more explanation:
r
(to set an I/O port or PWM a w
)On the Arduino side;
atoi()
you can parse ASCII to integers.If it is a legal command; respond to the command.
Upvotes: 4