DSH 772-196 1
DSH 772-196 1
DSH 772-196 1
get up
and running with an Arduino
Here is a picture of the board, a few code examples are available later on in the article.
Features
Blinking LED
1 int led = 13; ?
2
3 void setup()
4 {
5 // initialize the digital pin as an output.
6 pinMode(led, OUTPUT);
7 }
8
9 void loop()
10 {
11 digitalWrite(led, HIGH);
12 delay(1000);
13 digitalWrite(led, LOW);
14 delay(1000);
15 }
********************************************************************
********************************************************************
Switches example
1 const byte LED[] = {13,12,11,10}; ?
2
3 #define BUTTON1 A1
4 #define BUTTON2 A2
5
6 void setup()
7 {
8 // initialize the digital pin as an output.
9 /* Set each pin to outputs */
10 pinMode(LED[0], OUTPUT);
11 pinMode(LED[1], OUTPUT);
12 pinMode(LED[2], OUTPUT);
13 pinMode(LED[3], OUTPUT);
14 }
15
16 void loop()
17 {
18 if(!digitalRead(BUTTON1))
19 {
20 digitalWrite(LED[0], HIGH);
21 digitalWrite(LED[1], HIGH);
22 digitalWrite(LED[2], HIGH);
23 digitalWrite(LED[3], HIGH);
24 }
25
26 if(!digitalRead(BUTTON2))
27 {
28 digitalWrite(LED[0], LOW);
29 digitalWrite(LED[1], LOW);
30 digitalWrite(LED[2], LOW);
31 digitalWrite(LED[3], LOW);
32 }
33 }
********************************************************************
Potentiometer 1
1 #define Pot1 0 ?
2
3 void setup()
4 {
5 Serial.begin(9600);
6 }
7
8 /* Main Program */
9 void loop()
10 {
11
12 Serial.print(“Potentiometer reading: “);
13 Serial.println(analogRead(Pot1));
14 /* Wait 0.5 seconds before reading again */
15 delay(500);
16 }
********************************************************************
Pot and led
28 Serial.print(“Potentiometer: “);
29 Serial.println(PotValue);
30 }
31 else
32 {
33 digitalWrite(LED[0], HIGH);
34 digitalWrite(LED[1], HIGH);
35 digitalWrite(LED[2], HIGH);
36 digitalWrite(LED[3], HIGH);
37 Serial.print(“Potentiometer: “);
38 Serial.println(PotValue);
39 }
40 delay(500);
41 }
********************************************************************
segment display
********************************************************************