What language do I use?

I am using and arduino with wifi and port forwarding. My goal is to be able to create a web based program that will communicate with my arduino wirelessly to control a sunrise sunset affect with an led array. I want the program to be accessible anywhere and I want to be able to interrupt the program for set periods of time like a storm for example and then have the program go back to its normal original program(sunrise/sunset)

I am a beginner at programming I have my arduino set on a timed program not on a clock and I'm getting my wifi shield and I need help getting started. Anything with be greatly appreciated.

Thanks

What language do I use?

The Arduino is programmed in C++ (which is a superset of C). The Arduino has to be programmed to served up, and respond to, a web page which is coded in html. But, html is text based, so you will be sending text that some other computer sees as a distinct language.

This is not beginner programming, if you have never done web programming, web page design, client/server communication, or (as appears to be your case) any programming.

You know, someone could make a killing selling an aquarium control shield, given the number of posts on here on the subject. An RGB LED string driver, an RTC module, perhaps some relays for air pump control and feeders, with a library to tie it all together.

In a nut shell that is my overall goal. A complete stand alone module that can control lights. Next would be the I/o for pumps probes ect. I need to first figure out what I need to learn programming wise before I get in over my head too fast. So c++ and then I need to convert HTML a text language into c++ where next?

then I need to convert HTML a text language into c++

No.
HTML is a text language, you have to make sure that your arduino serves up this language on request from a web client.

before I get in over my head

I think you were there a long time ago if you don't know what language an arduino uses.

Forget your project for a moment and get a wi-fi shield and go through the various examples using it. Learn that first.

Forget your project for a moment and get a wi-fi shield and go through the various examples using it. Learn that first.

I've got to disagree, Mike. The wifi shields are not beginner devices. Learning to blink LEDs is first. Then, learn to send data to the serial port, and receive a response. Then, learn to collect that response into a string. Then, learn to parse that string, and do something with the parsed data.

Then, as a completely separate activity, learn to develop web pages. Then, learn to develop functionality to be called when the submit button is pressed.

Then, get an ethernet shield, and learn to make the Arduino serve the web page, and respond to submissions.

Only then would one get a wifi shield, and make the Arduino wireless.

I've got to disagree, Mike.

Yes you are probably right to disagree with me on this. :wink:

Maybe you could help, I am three and have just learned to walk. How can I run 6 Marathons in 10 days?

K3IHI:
In a nut shell that is my overall goal. A complete stand alone module that can control lights. Next would be the I/o for pumps probes ect. I need to first figure out what I need to learn programming wise before I get in over my head too fast. So c++ and then I need to convert HTML a text language into c++ where next?

No - It's a little more complex than that.

First off - what do you mean by "communicate wirelessly with the Arduino"? Do you mean over wifi, xbee, some kind of RF module - something else? The choice there will determine how you communicate with it.

For example, using a wifi module would mean communicating via network message passing, whereas the latter two might mean using a serial port of some kind.

Know this may influence what language(s) you can use on the PC end of things (it may even determine what OS platform you can use; for instance, it is very difficult to perform 2-way serial comms under Windows - not impossible, but they don't make it easy for some reason, either - especially if using PHP); most languages have the necessary interfaces and libraries for both serial and network messaging, but you should plan this carefully.

Also note that once you even know that, you may also need to know how to set up and use a communication protocol to communicate with the Arduino. Fortunately, there are some good libraries out there for both ends (because you need to do this both on the PC side and the Arduino side) of the chain.

As far as programming is concerned, on the Arduino side, it's essentially C/C++; play around with the demos, read some tutorials, etc - but I wouldn't go "whole-hog" into in-depth C/C++ programming tutorials meant for the PC. C/C++ on a microcontroller (especially one like the Arduino where a lot of stuff has been abstracted away for you) is a vastly different beast from doing the same on the PC (mainly due to memory and other resource limitations compared to a PC). So - learning C/C++ programming for the PC may actually hinder your understanding of doing it on a microcontroller (and vice-versa, unfortunately). Keep the differences in mind, though, and you might find that even PC tutorials may be helpful for some things.

On the PC side of things, for a web application, your choices are much broader. I would -not- recommend attempting to do web development using C/C++; while it is possible, for the tasks you are facing it is very much overkill. I would actually say for your application, using PHP or Python (or even a combination) would be the best solutions. Another solution might be Processing (note that Processing is essentially C/C++, which may seem like I am contradicting myself - I only mention it, though, because it is an abstracted form of C/C++ much in the same way the Arduino platform is, which is why the Arduino platform was based on it; thus, it may be easier to learn both the Arduino and Processing in parallel - just something to keep in mind).

If you are windows-centric, there's also the possibilities of using Windows technologies (just be aware that you may limit yourself, and any future users of your system, by doing this). These would include ASP, ASP.NET, C#.NET, VB.NET - plus for DB stuff things like IIS/MSSQL or Access (you may also find connectors and ways to use open-source DBs like MySQL and Python).

At any rate, on the PC side (also note when I say "PC", I generally mean Windows, Linux, or Mac - but each has it own strengths), you'll need to learn a language for the coding of the web application that will communicate with the Arduino (in some manner - it may or may not -directly- communicate with the Arduino, or it may communicate with a service on the PC, which you would have to write, which would run in the background communicating with the Arduino; the advantage of this service method is that, if the service or your web app should fail, the whole thing wouldn't necessarily "freeze up" or otherwise totally fail - however, it is more difficult and complicated to implement). This web application would output (to the browser) an HTML page, which would display your information, and maybe have a form or two that you could submit data back to your web application, which would then act on it to send a message to the Arduino. It may also need to write this information out to a file, or to a database. So there are a couple more things to learn.

In short - here is a list of technologies you would need to learn:

C/C++ (for Arduino)

One or more of:

Processing (PC)
PHP (PC)
Python (PC)
ASP/ASP.NET/C#.NET/VB.NET (Windows PC)

For the web stuff:

A minimum of how HTML and CGI works
As well as (possibly) DHTML, Javascript, AJAX, POST/GET, etc.

...and a database (as well as how to write SQL), such as:

MySQL (PC)
PostgreSQL (PC)
IIS/MSSQL or Access (Windows PC)

...and/or:

General file handling (reading and writing files with the language on the PC you use), and serial or network communications and message passing.

Not too mention all the hardware interfacing and electronics. Also - I am sure I forgot something along the line here; everything written above is a very simplified list - there's much more to learn than just the languages and the syntax of them. You'll also have to understand synchronous vs asynchronous communications, event driven vs polling design, stateful processes (as well as how and why web applications don't hold state between requests, what that means, and how you work around it)...

As you can see - this is hardly a beginner's project. But, if you take it one bit at a time (while taking your time, asking questions, and gaining understanding), you can come up with a working system in the end. Just don't let the "grand scope" overwhelm you. Instead, start with the basics (the Arduino, and simple serial communications via the virtual USB serial port) to get a feel for the hardware end of things, and simple messaging via serial (and the terminal). Then you can move on to the PC side of things, and work your way around over there.

Good luck with your project!

:smiley:

You may find it a little more motivational if you can take some concrete steps towards building your project - look at your overall requirement and find the one simplest piece of it. Might well be your led array. Look through the examples to find help, also search the forums for other acquarium projects. Light a single led, then many, fade them with PWM. Gradually build it up until you have a standalone controller. Only then would I worry about the web.

To specify a few things:
1 I want to use a wifi shield
2 I have the basic program written and in use now but it's simply a timer based program that dims after certain delays and shuts off after certain specified amounts of time delays
3 I want to start out controlling the led array only
4 what is the simplest way to do this?

Maybe that will help

Thanks

Controlling a bunch of LEDs --> go to my webpage www.blinkenlight.net
Using a WIFI or lan shield --> don't do it. An Arduino is to underpowered for a webserver. Also an Arduino + Shield will cost more than a stronger machine. Go for a cheap computer that already supports WIFI and connect the Arduino to it.
Guru plug, hacked WLAN routers and other computers come to mind.

An Arduino is to underpowered for a webserver.

That all depends on what is being served. For some small web pages, it works just fine.

For about $30 for an Arduino and $45 for an ethernet shield, it's hard to find another option for a better price.

This is wrong:-

An Arduino is to underpowered for a webserver

It should say:-

An Arduino is too underpowered for a webserver

Then it is just incorrect.

K3IHI:
I am using and arduino with wifi and port forwarding. My goal is to be able to create a web based program that will communicate with my arduino wirelessly to control a sunrise sunset affect with an led array.

After re-reading that a few times I think this could be achievable with fairly minimal effort. As I read it, you are planning to have an Arduino somewhere (eg. in an office) where you have web access, via wifi (so I presume there is power around). Connecting the wifi to an Arduino ethernet shield could be done by an existing WAP (wireless access point) device, such as the one I use here at home to connect a non-wifi gadget (like a TV) to the wifi, where cables are not available.

You mention port forwarding, so it sounds like you know about that, and thus you have plans to communicate with your device from "outside" its local network. Say, you might be in the street a few blocks away holding a laptop.

Now you want to enter some sort of command on the laptop, which gets sent to the Arduino, which alters what it is doing, am I right?

The tricky bit will be to send the data and have the server understand it. The examples for the Ethernet card, as far as I can see, do not involve web forms. There are probably thousands of pages that explain that, but I investigated a while back when I was trying to do a Lua-based web server, some of my findings are here:

To "send a web page" you need to send the HTTP headers, followed by a blank line, followed by the page, as a minimal example:

HTTP/1.1 200 OK
Date: Fri, 28 Apr 2006 03:14:58 GMT
Server: MyArduinoServer version 1.0
Connection: close
Content-Type: text/plain

Hello, world

To receive a HTTP request you need to parse the various headers you get from the web browser. I'm not sure how much of this the Ethernet library does for you, if any.

There is quite a bit of string manipulation involved, and playing with strings can be problematic when you only have 2 Kb of RAM. You would need to go for something pretty simple (like, very simple commands).

I would agree with the others, start simple, and work your way up. Don't try this particular project as your first one or you will get frustrated.

Of course you can implement a web server with an Arduino. You can implement a web server with less powerful machines. True. But if you look at the other options I would not bother doing so. In my opinion it is way too restricted for a reasonable web server.

If you're dead set on wifi, then I would recommend investigating the Roving Networks RN-XV wifly ($35) and the SeeedStudio Xbee shield ($10).

The xbee shield has a switch that lets you select between soft serial on Digital pins 11 and 12 or hardware serial, and a second switch that lets you connect the wifly module directly to the USB interface on the Arduino so you can use the serial monitor to configure the module. Very convenient and it makes it painless to configure (e.g. no need to remove the atmega chip from the Arduino to set up the wifly, no need to remove the shield to load a sketch).

I've been trying these out and found it really easy to configure and use. No problems connecting to my wireless network with WPA2 support. At the moment my Arduino is receiving a UDP packet every second via the wifly that reports the current internet download rate from my DSL router and then displays it on a small oled display. The sketch just treats the interface to the wifly as a simple serial stream carrying the payload of the UDP packets.

The wifly has built in support for making http client and server implementation easier also. Take a look at the spec: Wifly User Manual.

There's an example here:

http://www.nuelectronics.com/estore/index.php?main_page=project_eth

This particular page has an example in the library of a page with a button on it. If you hit the button it toggles an LED on and off.

The code isn't written the way I would (eg. it has lots of goto statements) however it demonstrates that a remote controlled gadget, via a web server, is possible. The sketch only uses about 5 Kb so there is room for other stuff.

That example is amazing. I think i am now better understanding the process. The arduino in the example acts as a web server when you push the button on the web page (remotely) it in turn sends data to the arduino, arduino (webserver) processes the data and then changes the digital pin to on.

Is this right?

Questions: I understand there is limitations in the arduino as far as memory ram ect... Is there a way you can assemble a webpage to send the codes to the arduino? Like a hosted website, instead of the arduino having to use all of its memory to be the server have a server do all the calculations and just send them to the arduino? Can't you buy a a service like this?

If this doesn't make sense at all i understand. Just a thought.

This is awesome, Thanks for all the help and suggestions.

Is this right?

Yep, that's what happens. I assembled it right here, and it works.

I didn't have an Ethernet shield handy but had one of those ENC28J60 boards ($8 from IteadStudio):

http://iteadstudio.com/store/index.php?main_page=product_info&cPath=18&products_id=224

Since it has an SPI interface I connected together MOSI/MISO/SCK/SS (4 wires on the right of the Arduino) plus 3.3V, Gnd and reset.

There is also an LED+resistor on pin 4.

I ran the demo program from the page I quoted above, after altering the IP address/MAC address to suit my local network.

The page it serves up looks like this:

More information about programming them here:

http://www.tuxgraphics.org/electronics/200606/article06061.shtml

Is there a way you can assemble a webpage to send the codes to the arduino?

Let's not get ahead of ourselves. To control some lights from the network should be well within the capabilities of the Arduino.

Then you can make a wireless version by just hooking it up to a commercial wireless access point: