This process is made really simple using the Teleduino sketch for your ethernet enabled Arduino. Haven't heard of Teleduino? That's cool, you may want to take a look at Arduino Control via a Web Service with Teleduino to get yourself started.
This tutorial will guide you through the process of attaching an LED to your Arduino, and provide some example Teleduino API calls to:
- Define the pin mode of a pin
- Turn on the LED
- Turn off the LED
- Set the brightness of the LED (using one of the PWM supported pins on the Arduino)
If you get stuck on any of the steps, or if you feel that there is a step that could be explained better, please leave a comment so that we can improve things.
Let's begin!
Step 1: Prepare an LED
Parts needed:
- An LED (we decided to use a 10mm white LED because they look neat)
- A 1K Resistor (or similar)
- Some hookup wire (we chose to use some single strand ethernet cable because it's cheap, and connects well to the Arduino pin sockets)
- Some heatshrink (optional, but makes it look nice and tidy)
Steps:
- Take the LED and shorten the lead on the flat-edge side (the shortest lead).
- Shorten one of the leads on the resistor.
- Solder the short lead of the resistor to the short lead of the LED.
- Shorten the other lead on the resistor so that it's the same length as the remainder lead on the LED.
- Solder the hookup wire to the two leads, and apply heatshrink. Take note of which lead is soldered to the resistor (we chose the white wire for this).
- Strip the other end of the hookup wires and connect to the Arduino. The white wire (the wire connected to the resistor) connects to a GND pin, and the other (our green wire) connects to a digital pin (we chose pin 3 because it also supports PWM).
Awesome!
Step 2: Control LED via the Teleduino API
Define the pin mode of digital pin 3 (Must be done once per boot prior to setting digital outputs. 'pin=3' mean pin 3, 'mode=1' means OUTPUT):
http://us01.proxy.teleduino.org/api/1.0/328.php?k={key}&r=definePinMode&pin=3&mode=1
Set the output of digital pin 3 to HIGH ('pin=3' means pin 3, 'output=1' means HIGH):
http://us01.proxy.teleduino.org/api/1.0/328.php?k={key}&r=setDigitalOutput&pin=3&output=1
Set the output of digital pin 3 to LOW ('pin=3' means pin 3, 'output=0' means LOW):
http://us01.proxy.teleduino.org/api/1.0/328.php?k={key}&r=setDigitalOutput&pin=3&output=0
Toggle the output of digital pin 3 ('pin=3' means pin 3, 'output=2' means toggle):
http://us01.proxy.teleduino.org/api/1.0/328.php?k={key}&r=setDigitalOutput&pin=3&output=2
Set the PWM value of pin 3 to 32 (LED will glow dull. 'pin=3' means pin 3, 'output=32' means PWM value):
http://us01.proxy.teleduino.org/api/1.0/328.php?k={key}&r=setPwmOutput&pin=3&output=32
Set the PWM value of pin 3 to 255 (LED will glow bright. 'pin=3' means pin 3, 'output=255' means PWM value):
http://us01.proxy.teleduino.org/api/1.0/328.php?k={key}&r=setPwmOutput&pin=3&output=255
Pretty neat, huh?
Step 3: Further Reading
To view the full API reference manual, take a look at http://www.teleduino.org/rtfm/api/328.php.
Have fun!



































Visit Our Store »
Go Pro Today »




---Define the pin mode of digital pin 3 (Must be done once per boot prior to setting digital outputs. 'pin=3' mean pin 3, 'mode=1' means OUTPUT):
http://us01.proxy.teleduino.org/api/1.0/328.php?k={key}&r=definePinMode&pin=3&mode=1------
When you say that it has to be done once per boot does that mean that this will have to be done every time you turn on the teleduino.
Thanks for your comment, and great to hear that you get everything up and running nice and easy.
You're right about definePinMode having to be called each time the Teleduino is turned on, HOWEVER, you can set preset values on your Teleduino device which means that this can occur automatically and you'll no longer have to call definePinMode.
To set preset values on your device, pop over to https://www.teleduino.org/tools/manage-presets. Your device needs to be online for presets to be set (the values are stored in the Arduino's EEPROM).
Thanks for trying Teleduino!
Thanks for the comment!
Absolutely, the output time can be set. There is an optional parameter expire_time which sets the expiry on the output in milliseconds. If you set it to output=1&expire_time=1000 then the output will go HIGH, then go LOW after 1 second.
Thanks!
Nathan.
Thanks again. Love your work.
Thanks for the comment.
The PHP class isn't for running on the device itself, it's for running on an external web server that supports PHP. The PHP class contains the methods required to communicate with the Teleduino.
Hope that helps! Let me know if I can help any further.
Do you plan to share your server code so anyone can implement their own web service using your library?
Thanks for the interest and for the kind comment.
There is no intention to release the server code into the public domain at this stage, however there are ways to interface with the device without needing to use the proxy server. If you download the PHP class from the Teleduino website, and use the Web Server example sketch, then you can interact directly with the device. This does, however, require port forwarding.
Enjoy!
I am getting an error on upload "Teleduino was not declared in this scope" can you advise.
Thanks,
Ken
Thanks for making contact.
I suspect the problem is due to the Teleduino library not being extracted to the correct libraries folder under your Arduino IDE. If you're certain it's in the right place and you're still having trouble, please advise what version of the IDE you're running.
Incase you haven't seen it already, there is an Instructable which guides you through the installation process: http://www.instructables.com/id/Arduino-Control-via-a-Web-Service-with-Teleduino/
Please let me know how you get on, it could be of great benefit to others who may experience the same problem.
Thanks!
Thank you for your prompt reply, you were correct, In my haste to see what happens next, I just copy the code, drop the library into the library folder but forgotten to reload the ide hence the library was not extracted even though it is in the right directory (i am using ver1.01).
I slowed down and followed your instruction carefully, the sketch loaded ok this time but i still have no joy. I did changed the api key to the one u sent me; the mac addr (to the one on the label on the ethernet board); after loading, the light flashed few times but not a steady pattern, and I cant make out what sequence it is. then stop for about a minute, then flashed a few times again.
Its a bit late in NZ now, i will try again some other time. Need to check my ethernet board or may buy one of those integrated arduino with ether on board, I will try to use a static ip (dhcp=false) next.
Anyway, you are doing an excellent job.
Many thanks,
Ken
Great to hear you're getting a little bit further, and thanks for the kinds words about the project!
Is it possible to take a video of the flashing sequence? Sounds like it's trying to get connected but it's hitting a block somewhere.
Great to see a fellow NZer getting involved with Teleduino.
Thanks again,
Nathan.
Finally got it going! I will share my experience ... the problem is with the Vodafone hg556 asdl router, even though the lan ports and the modem works perfectly when pcs are hooked up to it, the router does not recognise my ethernet shield for some reason. It took me a long time to work this out as the router lan port was working perfectly with other devices.
In the end, I did the following to make it work
I hook up an old router (dl524) as a hub and plug the ethernet shield to the dl524 and link it to the land port in the hg556. To do this I have to disable the dhcp on the dl524, reassign the ip address on the dl524 to the same network config (192.168.1.123 ), ensuring that it is outside the dhcp assigned range in the hg556.
I change the sketch by disabling dhcp (dhcp=false), setting a fix ip address for the shield, again making sure it does not clash with the hg556 dhcp range, in this case 192.168.1.180.
to further make sure, I defined & added the âgatewayâ pointing to the hg556: Ethernet.begin(mac, ip, gateway, subnet);
So all good, now. Thanks Nathan.
Ken
Great to hear you got it up and running - enjoy!
any way good day to you, and cool idea, ill be watching.
There are some resources available at http://www.teleduino.org which include the Arduino library with example sketches, and also a PHP library to interface with them. There are a few different ways that you can interface with the device. You could either use the proxy server (which is demonstrated in this tutorial and doesn't matter if you have a dynamic IP), or you can interface with the Arduino directly using the web server sketch. Using the web server sketch means you need to configure port forwarding, dyndns etc.
I hope that answers your questions. Thanks!
Easy as pie, as promised. I have tried other methods and failed, at least without paying for DDNS service. I have an SSR at the ready, bring on your next instructable....not like you're busy with a new server and new web page and, and, and....
They'd just be treated as a digital output as far as the Teleduino is concerned (same as this LED tutorial).
I haven't integrated an SSR before, perhaps you could post a Instructable about it? :)
Can I ask what sort of SSR you have there? The circuitry may be different than a standard relay. Do you have a datasheet?