Alright now I know that there have been lots of threads on this, but I think this is a different approach. I wanted to be able to control my arduino from my cell phone, and without a cell shield or ethernet shield. Thus, i did it through twitter through my computer.
First, I setup mobile status updates in twitter, with a new account, and wrote this php script:
<?
function twitterCapture() {
// Set your username and password here
$user = 'USERNAME';
$password = 'PASSWORD';
$ch = curl_init("https://twitter.com/statuses/user_timeline.xml");
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch,CURLOPT_TIMEOUT, 30);
curl_setopt($ch,CURLOPT_USERPWD,$user . ":" . $password);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
$result=curl_exec ($ch);
$data = strstr($result, '<?');
$xml = new SimpleXMLElement($data);
return $xml;
}
$xml = twitterCapture();
echo $xml->status[0]->text;
?>
Then, I wrote this python script:
from urllib import urlopen
import serial
import time
ser = serial.Serial('/dev/ttyUSB0', 9600)
while(1):
lala = urlopen('PATH TO WEB SCRIPT').read()
if lala == "Ledon":
ser.write('1')
elif lala == "Ledoff":
ser.write('0')
time.sleep(30)
Lastly, this arduino program.
int inByte;
void setup()
{
// start serial port at 9600 bps:
Serial.begin(9600);
}
void loop()
{
if (Serial.available() > 0) {
// get incoming byte:
inByte = Serial.read();
}
if (inByte == '1') {
digitalWrite(13, HIGH);
}
if (inByte == '0') {
digitalWrite(13, LOW);
}
}
Obviously, i will do more interesting things later, but for now, this is cool.