Arduino Platform (Part I)

Here is the pdf of the slides of my online talk on "Arduino Platform Part I" for asDevs Download a PDF of my talk (5.8 MB).

The session was recorded and you can listen and view it here.

Any questions on my talk just comment below or email me.

Here are the sample programs I went through.

Arduino code to make a led blink on and off.

view plain print about
1int led = 3;
2
3void setup() {
4 Serial.begin(9600);
5 pinMode(led, OUTPUT);
6}
7
8void loop() {
9 Serial.println("LED on");
10 digitalWrite(led,HIGH);
11 delay(1000);
12 Serial.println("LED off");
13 digitalWrite(led,LOW);
14 delay(1000);
15}

Arduino code to make a led blink on and off depending on how much light falls on a light dependant resistor.

view plain print about
1int led = 3;
2int pin = 0;
3
4void setup() {
5 Serial.begin(9600);
6 pinMode(led, OUTPUT);
7}
8
9void loop() {
10 int value = analogRead(pin);
11 Serial.println(value);
12 Serial.println("LED on");
13 digitalWrite(led,HIGH);
14 delay(value);
15 Serial.println("LED off");
16 digitalWrite(led,LOW);
17 delay(value);
18}

And finally a simple web sever.

view plain print about
1#include <Ethernet.h>
2#include <SPI.h>
3
4byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
5byte ip[] = { 192,168,1,50 };
6
7// listen on port 80 for connections
8
Server server(80);
9
10void setup()
11{
12 Serial.begin(9600);
13 Ethernet.begin(mac, ip);
14 server.begin();
15}
16
17void loop()
18{
19 Client client = server.available();
20
21 if (client) {
22 boolean blankline = false;
23
24 while (client.connected())
25 {
26 if (client.available())
27 {
28 char c = client.read();
29 Serial.print(c);
30
31 // if line is blank, the http request has ended, so we can send a reply
32
if (c == '\n' && blankline) {
33 // Send a standard http response header
34
client.println("HTTP/1.1 200 OK");
35 client.println("Content-Type: text/html");
36 client.println();
37
38 // Send some HTML
39
client.println("<html>");
40 client.println("Hi I'm an Arduino");
41 client.println("
</html>");
42
43 Serial.println("
");
44 Serial.println("
Sent reponse");
45 break;
46 }
47 // we're starting a new line
48
if (c == '
\n' || c == '\r') {
49 blankline = true;
50 }
51 else {
52 blankline = false;
53 }
54 }
55 }
56
57 client.flush();
58 client.stop();
59 }
60}

Related Blog Entries

TweetBacks
Comments (Comment Moderation is enabled. Your comment will not appear until approved.)