SkyDuino

This is really not much of an Arduino project (it only involves hooking up two servos and controlling it via serial port to respond to U,D,L,R,C for Up, Down, Left, Right, and Center). But it is pretty cool to be able to control my home webcam without having to mess with DynamicIP, port forwarding, etc because Skype does all that for you.

If you ever want to have a remote pan/tilt webcam and do not want to setup a home webserver, this maybe of interest to you.

Sorry, it’s windows only, but C# source code is included and Skype API is available for Java and Python, so it should be easily ported.

/*
======================================
  SkyDuino Sketch - Hari Wiguna 2010
======================================

*/

#include <Servo.h> 

Servo xServo;
Servo yServo;

int stepSize = 10;

const int xInit = 90;
const int yInit = 90;
const int xMin = 0;
const int xMax = 180;
const int yMin = 0;
const int yMax = 180;

int x = xInit;
int y = yInit;
int xNew = x;
int yNew = y;

void setup()
{
  Serial.begin(9600);
  //establishContact();  // send a byte to establish contact until receiver responds 

  xServo.attach(5);  // attaches the servo on pin 9 to the servo object 
  yServo.attach(6);  // attaches the servo on pin 9 to the servo object 

  delay(1000);
  MoveServo(xServo, xServo.read(), x);
  MoveServo(yServo, yServo.read(), y);
  delay(100);
  pinMode(11, OUTPUT);
}

void Beep()
{
  digitalWrite(11,HIGH);
  delay(250);
  digitalWrite(11,LOW);   
}

void loop()
{
  // if we get a valid byte, read analog ins:
  if (Serial.available() > 0) {
    Beep();
    char msg = Serial.read();

    if (msg == 'C') {xNew=xInit; yNew=yInit;}

    if (msg == 'R') xNew = x - stepSize;
    if (msg == 'L') xNew = x + stepSize;

    if (msg == 'D') yNew = y - stepSize;
    if (msg == 'U') yNew = y + stepSize;

    xNew = constrain(xNew, xMin, xMax);
    yNew = constrain(yNew, yMin, yMax);
  }

  MoveServo(xServo, x, xNew);
  MoveServo(yServo, y, yNew);
  x = xNew;
  y = yNew;
}

void MoveServo(Servo servo, int moveFrom, int moveTo)
{
  if (moveFrom <= moveTo)
  {
    for (int c=moveFrom; c<=moveTo; c++)
    {
      servo.write(c);
      delay(50);
    }
  }

  if (moveFrom > moveTo)
  {
    for (int c=moveFrom; c>=moveTo; c--)
    {
      servo.write(c);
      delay(50);
    }
  }
}

really really interesting project.

I love your project! Not only clean and simple, the use of Skype is brilliant! Just like Newtons apple, its easy to understand but tricky to invent.
Could you describe, in just a few words, how you handle the Skype in the Arduino end? Answering only the right call and transferring the order to a serial? I will read the source later.
Does Skype need a server connection or is it true peer to peer? Is it possible to use it in a closed network, without an internet connection?
Btw, that comment of Davide (the Global Moderator!) must be a killer!

Thanks... :)

As far as the Arduino and Skype connection... there is none! ;D At least not directly. It goes like this...

Let's start with the remote side: 1. User clicks "Start" in Skyduino windows app. 2. It uses SkypeAPI to tell Skype to call the home skype. 3. Once connected, remote skype and home skype are talking as if two humans initiated the call. 4. when user clicks Up/down/left/right in SkyDuino windows app, it again uses SkypeAPI to send it to the home Skype.

On the other side... at home: 1. Skype app receives the command from remote Skype 2. Skyduino windows app on the home server is registered to listen to those commands via Skype API. 3. SkyDuino windows app passes those commands to Arduino via USB/comm port 4. Arduino sees characters as if someone typed it in the Arduino IDE "Serial Monitor window" and move the servo.

Except of course that someone could be on the other side of the world.

Another benefit of using Skype over standard webserver is that it is two way communication. Not only you can see and hear your dog/cat, but your dog/cat can also see and hear you! And he/she doesn't even have to know how to use a mouse. :D

Oh, I've just re-read SRyLul's question and realized I didn't really answer his questions. :-[ Let me try again...

The home skype is setup to auto-answer ANY call from skype users in its contact list, so you should setup a dedicated skype user just for the skype home machine. You then add "real" skype users as contacts that are allowed to call to skype home. Only those people can connect to the home skype, control the SkyDuino Widows app, and the Arduino.

I don't know if Skype require a server or if it would work in closed network or not. Sorry.