Created
May 1, 2016 11:32
-
-
Save gabonator/ddcf4f661b57752c0a0f1ab9cbf4c5f7 to your computer and use it in GitHub Desktop.
Itead iboard 1.1 arduino with ethernet and sd card sample code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Itead iboard 1.1 | |
| * | |
| * Programmer: Parallel progarmmer | |
| * Processor: Atmel328 (328P) | |
| * Board: Arduino Duemilanove or Diecimila | |
| */ | |
| #include <SPI.h> | |
| #include <Ethernet.h> | |
| byte mac[] = { 0x00, 0x6A, 0xB0, 0x17, 0xEA, 0xD0 }; | |
| byte ip[] = { 192, 168, 1, 51 }; | |
| EthernetServer server(80); | |
| void setup() { | |
| Serial.begin(9600); | |
| Serial.print("Starting board\n"); | |
| Serial.print("Built " __DATE__ " " __TIME__ "\n"); | |
| pinMode(10, OUTPUT); // set the SS pin as an output (necessary!) | |
| digitalWrite(10, HIGH); // but turn off the W5100 chip! | |
| Ethernet.begin(mac, ip); | |
| server.begin(); | |
| } | |
| void loop() | |
| { | |
| EthernetClient client = server.available(); | |
| if (client) { | |
| // an http request ends with a blank line | |
| boolean current_line_is_blank = true; | |
| while (client.connected()) { | |
| if (client.available()) { | |
| char c = client.read(); | |
| // if we've gotten to the end of the line (received a newline | |
| // character) and the line is blank, the http request has ended, | |
| // so we can send a reply | |
| if (c == '\n' && current_line_is_blank) { | |
| // send a standard http response header | |
| client.println("HTTP/1.1 200 OK"); | |
| client.println("Content-Type: text/html"); | |
| client.println(); | |
| client.println("Server working"); | |
| client.print("Built " __DATE__ " " __TIME__ "\n"); | |
| break; | |
| } | |
| if (c == '\n') { | |
| // we're starting a new line | |
| current_line_is_blank = true; | |
| } else if (c != '\r') { | |
| // we've gotten a character on the current line | |
| current_line_is_blank = false; | |
| } | |
| } | |
| } | |
| // give the web browser time to receive the data | |
| delay(1); | |
| client.stop(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment