This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
user:jr018429:portfolio:webserveronarduino.html [2012/04/17 01:45] – [Execution] jr018429 | user:jr018429:portfolio:webserveronarduino.html [2012/04/17 22:43] (current) – [Code] jr018429 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | <WRAP centeralign round graybg box 96%> | ||
+ | <WRAP muchbigger> | ||
+ | <WRAP bigger> | ||
+ | <WRAP bigger> | ||
+ | </ | ||
+ | ======Objectives====== | ||
+ | ======Prerequisites====== | ||
+ | - Knowledge of microprocessors | ||
+ | - Knowledge of the Arduino Wiring language | ||
+ | - Knowledge of C/C++ | ||
+ | - Knowledge of basic networking | ||
+ | ======Background====== | ||
+ | ======Scope====== | ||
+ | ======Attributes====== | ||
+ | The course requirements for HPC Experience I projects are listed at:\\ | ||
+ | http:// | ||
+ | This project has the following project attributes described on that page: | ||
+ | ======Project Attributes====== | ||
+ | The following are the programming attributes you must consider while undertaking a project for credit in this course: | ||
+ | |||
+ | <WRAP centeralign> | ||
+ | ^ Attribute | ||
+ | | maintenance | ||
+ | | configuration | ||
+ | | logging | ||
+ | | implementation | ||
+ | | enhancement | ||
+ | | virtualization | ||
+ | | redundancy | ||
+ | | administration | ||
+ | | exploration | ||
+ | | log analysis | ||
+ | | troubleshooting | ||
+ | | security | ||
+ | </ | ||
+ | |||
+ | There are a total of 48 items needed; with a maximum of 8 attributes achievable per project, that makes for a __minimum__ of 6 projects you must perform during the semester. | ||
+ | |||
+ | Note that where multiple quantities of attributes are concerned, only a single instance of an attribute can be achieved on any single project. | ||
+ | ======Code====== | ||
+ | ===Arduino Web Server Example Code with my mac and IP addresses=== | ||
+ | < | ||
+ | /* | ||
+ | Web Server | ||
+ | |||
+ | A simple web server that shows the value of the analog input pins. | ||
+ | using an Arduino Wiznet Ethernet shield. | ||
+ | |||
+ | | ||
+ | * Ethernet shield attached to pins 10, 11, 12, 13 | ||
+ | * Analog inputs attached to pins A0 through A5 (optional) | ||
+ | |||
+ | | ||
+ | by David A. Mellis | ||
+ | | ||
+ | by Tom Igoe | ||
+ | |||
+ | */ | ||
+ | |||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | // Enter a MAC address and IP address for your controller below. | ||
+ | // The IP address will be dependent on your local network: | ||
+ | byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0xC5, 0x92 }; //The suggested mac address | ||
+ | IPAddress ip(192, | ||
+ | |||
+ | // Initialize the Ethernet server library | ||
+ | // with the IP address and port you want to use | ||
+ | // (port 80 is default for HTTP): | ||
+ | EthernetServer server(80); | ||
+ | |||
+ | void setup() | ||
+ | { | ||
+ | // start the Ethernet connection and the server: | ||
+ | Ethernet.begin(mac, | ||
+ | server.begin(); | ||
+ | } | ||
+ | |||
+ | void loop() | ||
+ | { | ||
+ | // listen for incoming clients | ||
+ | EthernetClient client = server.available(); | ||
+ | if (client) { | ||
+ | // an http request ends with a blank line | ||
+ | boolean currentLineIsBlank = true; | ||
+ | while (client.connected()) { | ||
+ | if (client.available()) { | ||
+ | char c = client.read(); | ||
+ | // if you've gotten to the end of the line (received a newline | ||
+ | // character) and the line is blank, the http request has ended, | ||
+ | // so you can send a reply | ||
+ | if (c == ' | ||
+ | // send a standard http response header | ||
+ | client.println(" | ||
+ | client.println(" | ||
+ | client.println(); | ||
+ | |||
+ | // output the value of each analog input pin | ||
+ | for (int analogChannel = 0; analogChannel < 6; analogChannel++) { | ||
+ | client.print(" | ||
+ | client.print(analogChannel); | ||
+ | client.print(" | ||
+ | client.print(analogRead(analogChannel)); | ||
+ | client.println("< | ||
+ | } | ||
+ | break; | ||
+ | } | ||
+ | if (c == ' | ||
+ | // you're starting a new line | ||
+ | currentLineIsBlank = true; | ||
+ | } | ||
+ | else if (c != ' | ||
+ | // you've gotten a character on the current line | ||
+ | currentLineIsBlank = false; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | // give the web browser time to receive the data | ||
+ | delay(1); | ||
+ | // close the connection: | ||
+ | client.stop(); | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ======Execution====== | ||
+ | Today, April 16, 2012, I purchased an Arduino Uno and an Arduino Ethernet Shield at Radio Shack. When I got them home, I downloaded and installed the Arduino 1.0 IDE for Windows. Next, I assembled the Arduino Uno and the Ethernet shield. I plugged one end of the USB programming cable into the Arduino Uno and the other end into the computer on which I installed the Arduino 1.0 IDE. Installing the device driver is a little bit on a pain; after plugging the Arduino' | ||
+ | sketch-> | ||
+ | Next, I found an Ethernet example, file-> | ||
+ | of a spare Ethernet cable into the router; I plugged the other end of the cable into Ethernet shield. Lastly, I plugged a power supply (wall wart) into the Arduino' | ||
+ | \\ | ||
+ | {{: | ||
+ | \\ | ||
+ | I haven' | ||
+ | After getting the Arduino Web server to work, I added it as a new project to my portfolio. I plan to add hardware control and improve the server. The Ethernet shield also has a connector for an SD card on which data can be stored. | ||
+ | |||
+ | |||
+ | ======Reflection====== | ||
+ | ======References====== | ||
+ | * http:// | ||
+ | * http:// | ||
+ | * http:// | ||
+ | * http:// | ||
+ | * http:// | ||
+ | * http:// | ||
+ | |||