Time, C and PHP
I have a PHP website that I want to interface with Arduino. What would be the best way to keep track of time in both, for example if my PHP page displays current time, say 开发者_StackOverflow中文版9 p.m., and I have a dropdown, labeled "Next activate", which will activate something at time X, say 11 p.m.
How would I accomplish this? How could I tell Arduino, which is programmed in C, to activate at time 11 p.m. when right now it is 9 p.m.?
The easiest thing to do (assuming a Unix system) is to have the Arduino listen for a signal over the serial port, and write a little application that pokes it when you want it to update. Then just use the Unix at
utility to trigger the event.
Another approach would be to use an asynchronous job dispatch daemon, such as Beanstalk, which would allow you to have a persistent service talking to the Arduino and have transient web requests queueing jobs to manipulate it.
精彩评论