-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweek4.html
243 lines (227 loc) · 11.9 KB
/
week4.html
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<!DOCTYPE html>
<html lang="en">
<head>
<title>PHYSCI 70: Intro to Digital Fabrication </title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<link href="./style.css" rel="stylesheet">
</head>
<body>
<div class="container-fluid bg-3 text-center">
<a href="./index.html">
<div class="header-container">
<h3>PHYSCI 70: Introduction to Digital Fabrication </h3>
<h4>Marie Konopacki</h4>
</div>
</a>
<div class="header-buttons">
<a href="./final-project.html">
<div class="header-button">
<h4>Final Project Proposal</h4>
</div>
</a>
<a href="./about-me.html">
<div class="header-button">
<h4>About Me</h4>
</div>
</a>
</div>
<h3>Week 4</h3>
<div class="page-specs">
<div class="page-specs-section">
<div class="col-sm-4">
<div class="page-image"><img src="./images/week4 1.jpg"></img></div>
</div>
<div class="col-sm-8">
<p>For this week, we were assigned to make a “microcontroller do something”. I spent some time trying to think about what I would make it do. I wanted to lean more into the coding side of the project, considering I was really interested in the prospect of written code achieving real life commands. Although I’ve coded before, it was always front-end web development, so everything my code achieved was purely on a screen. Eventually, I decided to make a morse code translator.</p>
</div>
</div>
<div class="page-specs-section">
<div class="col-sm-4">
<div class="page-image"><img src="./images/week 4 2.jpg"></img></div>
</div>
<div class="col-sm-8">
<p>Essentially, it takes in a user-inputted string, and then the microcontroller, using its built-in LED, would flash, in morse code, the original input. For the code, I created functions that turned the LED on for both short and long increments. I then made a switch case for each letter of the alphabet and used a morse-code chart I found online to properly assign functions to each one.</p>
</div>
</div>
<div class="page-specs-section">
<div class="col-sm-4">
<iframe width="100%" height="300px" src="https://www.youtube.com/embed/DA6ZZ2rbGb8" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
<div class="col-sm-8">
<p>Overall, I'm pretty satisfied with the finished project. To the left, I've attached a demo of me inputting the string "marie". Attached below is the code I wrote to achieve this project.</p>
</div>
</div>
</div>
</div>
<!-- HTML generated using hilite.me --><div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #333399; font-weight: bold">void</span> <span style="color: #0066BB; font-weight: bold">setup</span>() {
<span style="color: #888888">// initialize digital pin LED_BUILTIN as an output.</span>
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(<span style="color: #0000DD; font-weight: bold">9600</span>);
}
String input <span style="color: #333333">=</span> <span style="background-color: #fff0f0">""</span>;
<span style="color: #333399; font-weight: bold">void</span> <span style="color: #0066BB; font-weight: bold">loop</span>() {
<span style="color: #008800; font-weight: bold">if</span> (Serial.available() <span style="color: #333333">></span> <span style="color: #0000DD; font-weight: bold">0</span>) {
input <span style="color: #333333">=</span> Serial.readStringUntil(<span style="color: #0044DD">'\n'</span>);
Serial.print(input);
<span style="color: #008800; font-weight: bold">for</span>(<span style="color: #333399; font-weight: bold">int</span> i <span style="color: #333333">=</span> <span style="color: #0000DD; font-weight: bold">0</span>; i<span style="color: #333333"><</span>input.length(); i<span style="color: #333333">++</span>) {
<span style="color: #333399; font-weight: bold">char</span> letter <span style="color: #333333">=</span> input[i];
<span style="color: #008800; font-weight: bold">switch</span> (letter) {
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'a'</span>:
Short();
Long();
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'b'</span>:
Long();
Short();
Short();
Short();
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'c'</span>:
Long();
Short();
Long();
Short();
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'d'</span>:
Long();
Short();
Short();
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'e'</span>:
Short();
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'f'</span>:
Short();
Short();
Long();
Short();
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'g'</span>:
Long();
Long();
Short();
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'h'</span>:
Short();
Short();
Short();
Short();
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'i'</span>:
Short();
Short();
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'j'</span>:
Short();
Long();
Long();
Long();
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'k'</span>:
Long();
Short();
Long();
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'l'</span>:
Short();
Long();
Short();
Short();
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'m'</span>:
Long();
Long();
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'n'</span>:
Long();
Short();
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'o'</span>:
Long();
Long();
Long();
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'p'</span>:
Short();
Long();
Long();
Short();
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'q'</span>:
Long();
Long();
Short();
Long();
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'r'</span>:
Short();
Long();
Short();
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'s'</span>:
Short();
Short();
Short();
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'t'</span>:
Long();
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'u'</span>:
Short();
Short();
Long();
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'v'</span>:
Short();
Short();
Short();
Long();
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'w'</span>:
Short();
Long();
Long();
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'x'</span>:
Long();
Short();
Short();
Long();
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'y'</span>:
Long();
Short();
Long();
Long();
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'z'</span>:
Long();
Long();
Short();
Short();
<span style="color: #008800; font-weight: bold">break</span>;
}
delay(<span style="color: #0000DD; font-weight: bold">1500</span>);
}
}
}
<span style="color: #333399; font-weight: bold">void</span> <span style="color: #0066BB; font-weight: bold">Long</span>() {
digitalWrite(LED_BUILTIN, HIGH);
delay(<span style="color: #0000DD; font-weight: bold">1200</span>);
digitalWrite(LED_BUILTIN, LOW);
delay(<span style="color: #0000DD; font-weight: bold">200</span>);
}
<span style="color: #333399; font-weight: bold">void</span> <span style="color: #0066BB; font-weight: bold">Short</span>() {
digitalWrite(LED_BUILTIN, HIGH);
delay(<span style="color: #0000DD; font-weight: bold">300</span>);
digitalWrite(LED_BUILTIN, LOW);
delay(<span style="color: #0000DD; font-weight: bold">200</span>);
}
</pre></div>
</div>
</body>
</html>