-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtutorial1-FlashingLED.html
More file actions
152 lines (147 loc) · 8.35 KB
/
tutorial1-FlashingLED.html
File metadata and controls
152 lines (147 loc) · 8.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<!DOCTYPE html>
<html>
<head>
<title>Learn Arduino - Tutorial 1</title>
<link rel="stylesheet" type="text/css" href="./learnArduino.css">
</head>
<body>
<nav>
<a href="./index.html" class="home">Home</a>
<a href="./tutorialsPage">Tutorials</a>
<a href=".">Start here! First tutorial</a>
</nav>
<h1>Tutorial 1 - Flashing LED</h1>
<p>Welcome to your first tutorial!</p>
<h2>You will need:</h3>
<ul class="requirements column0">
<li>1x Arduino <img src="./images/squareArduino.JPG"></li>
<li>1x breadboard <img src="./images/squareBreadboard.JPG"></li>
<li>1x LED <img src="./images/redLEDSquare.JPG"></li>
<li>1x 22Ohm resistor <img src="./images/square220OhmResistor.JPG"></li>
<li>2x wire <img src="./images/squareBrownShortWire.JPG"></li>
</ul>
<or class="steps">
<li>
<h2>Step 1</h2>
<section>
<p>Connect one wire to "GND", and one to any of the numbers 1-13, <br>
for this tutorial we will be using '7'</p>
<aside class="extra">
<h3>What does this mean?</h3>
<p>The holes in which you can insert your wires are called "pins" they can take input or give power output, depending on how you program them.<br>
The "GND" pin stands for "ground" and is the end of your circut.</p>
</aside>
</section>
</li>
<img src="./images/instructionsTwoBrownWires.JPG" class="explainingImage column1">
<li>
<h2>Step 1</h2>
<section>
<p>Wire up the 220Ohm resistor and LED as shown in the diagram</p>
<aside class="extra">
<h3>What does this mean?</h3>
<p>
The breadboard connects all your components and wires without requiring soldering,<br>
The second diagram on the right shows which holes are conected to which others.<br>
The resistor reduces the amount of power going to the LED so it doesn't burn out <br>
The long leg of the LED is called the cathode and connects to the power source through the resistor.
<br>
The short leg is called the anode and connects to ground.
</p>
</aside>
</section>
<img src="./images/completedFlashCircut.JPG" class="explainingImage">
<img src="./images/IMG_1126.JPG" class="explainingImage">
<section>
<p>
Well done! You have completed the circut, lets start coding!<br>
The code to make the LED flash is shown below, we will go through it line by line
</p>
<img src="./images/ArduinoFlashCode.JPG" class="explainingImage">
<ol>
<li>
<p class=code> void setup() {</p>
<!-- <p class=code>int buttonPin = 2;<br>int LEDPin = 3;</p>
<p>
We are going to set buttonPin (orLEDPin) to something, <br>
every time you use buttonPin (orLEDPin) it will mean what you set it to. <br>
In this case we set buttonPin
</p> -->
<p>
"void" basically means "nothing", <br>
so in this case we can ignore it. <br>
"setup()" is the name of this block of code that runs when the program is started, to set everything up. <br>
The curly brackets go around the block of code.
</p>
</li>
<li>
<p class=code> // put your setup code here, to run once:</p>
<p>
The "//" just means that everything after it on that line is a comment. <br>
It does nothing except tell the reader of the code something, <br>
This is very usefull, it can help you and others read and understand your code.
</p>
</li>
<li>
<p class=code> pinMode(7, OUTPUT);</p>
<p>
This sets pin 7's mode to OUTPUT, <br>
output means it will give the circut power <br>
Note how the last two lines are "indented", or moved forward 4 spaces, this shows that they are a part of "setup".<br>
You will also notice that the line ends with a semicolon, this shows that the line has ended.
</p>
</li>
<li>
<p class=code>}</p>
<p>
Ends setup.
</p>
</li>
<li>
<p class=code>void loop() {</p>
<p>
This contains the "loop" part of the code, it repeats till the Arduino is turned off or you tell it to.<br>
Note how this is very similar to "void setup() {}".
</p>
</li>
<li>
<p class=code> digitalWrite(7, HIGH);</p>
<p>
"digitalWrite" lets you change the power of a certain pin, in this case pin 7. <br>
You can use "HIGH" or "LOW" to turn the power on or off, which then switches the LED on and off. <br>
Note that this line is also indented because it belongs to the loop().
</p>
</li>
<li>
<p class=code> delay(1000);</p>
<p>
"delay" pauses the program for the number of milliseconds specified in the brackets, In this case 1000<br>
One millisecond is 1/1000 of a second, so 1000 milliseconds is one second.
Note that this line is also indented because it belongs to the loop().
</p>
</li>
<li>
<p class=code> digitalWrite(7, LOW);</p>
<p>
Turns off the LED, explained ubove.
</p>
</li>
<li>
<p class=code>}</p>
<p>
End of the loop, when it reaches this is goes back to <p class=code>void loop() {</p>, then moves down, line by line till it reaches this statement again, and repeats.
The only way this cycle can be broken is through a return statement which we will cover later.
</p>
</li>
<li>
<h3>Run it!</h3>
</li>
<button type="button" id="completed">It works!</button>
<button type="button">It doesn't work :(</button>
</ol>
</section>
</li>
</or>
<script src="scriptLearnArduino.js"></script>
</body>
</html>