-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslides-en.html
1009 lines (736 loc) · 33.5 KB
/
slides-en.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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Ladies Learning Code</title>
<link rel="stylesheet" href="framework/css/slideshow.css" data-noprefix>
<link rel="stylesheet" href="framework/css/fonts.css" data-noprefix>
<link rel="stylesheet" href="framework/css/highlightjs/github.css" data-noprefix>
<link rel="stylesheet" href="framework/css/styles.css" data-noprefix>
<link rel="shortcut icon" href="framework/img/favicon.ico">
<!-- Takes care of CSS3 prefixes -->
<script src="framework/scripts/prefixfree.min.js"></script>
<!-- opens all links in a new window -->
<base target="_blank">
</head>
<!-- Timer/progress bar: Define the presentation duration using "data-duration" in minutes. -->
<body class="en" data-duration="360">
<main>
<section class="slide welcome highlight">
<h1><img class="logo-stacked" src="framework/img/llc-logo-stacked-white.png" alt="Ladies Learning Code logo">Welcome!
</h1>
<div class="instructions">
<!-- ADD WIFI INFO HERE -->
<h2>Get <br>Connected</h2>
<p><strong>Wifi:</strong> wifi network</p>
<p><strong>Password:</strong> wifi password</p>
<hr>
<h2>Download<br> & Install</h2>
<ol class="downloads">
<li>Learner files (zip file): <a
href="https://github.com/ladieslearningcode/workshop-repo-name/archive/master.zip">http://bit.ly/create-custom-url</a>
<ul>
<li>unzip the learner file (<em>extract all</em> if you’re on a PC)</li>
<li>open <em>slides.html</em> in the browser to view the slides</li>
</ul>
</li>
<li>Arduino Create: <a href="https://create.arduino.cc/">https://create.arduino.cc/</a></li>
<li>Chrome Browser: <a
href="https://www.google.ca/chrome/browser/desktop/">https://www.google.ca/chrome</a></li>
</li>
</ol>
</div>
<footer>
<a class="left" rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/"><img
alt="Creative Commons License" src="framework/img/cc-by-nc.png"/></a>
<p class="left">Content created by <a href="http://routeique.com">Eric Moon, Rio Nicholas, Kelsey
Shorten</a> for <a prefix="cc: http://creativecommons.org/ns#" href="http://ladieslearningcode.com"
property="cc:attributionName" rel="cc:attributionURL">Ladies Learning Code</a></p>
<p class="right">Use the left <span class="arrow">←</span> and right <span
class="arrow">→</span> arrow keys to navigate</p>
</footer>
</section>
<section class="slide intro">
<img class="logo" src="framework/img/llc-logo-white.png" alt="Ladies Learning Code logo">
<h1 class="heading-bg">
<span>Introduction to MicroControllers:<br>
Sound Reactive Desk Light</span>
</h1>
<!-- FILL IN INSTRUCTOR DETAILS -->
<img class="instructor" src="framework/img/workshop/routeique.jpg" alt="Instructor Name">
<h2><span class="cursive">with</span> Eric & Kelsey </h2>
<ul>
<li><a href="mailto:">[email protected]</a></li>
<li><a href="http://routeique.com">routeique.com</a></li>
<li><a href="http://twitter.com/">@routeique</a></li>
</ul>
<div class="sponsor">
<!--<p>In partnership with<br> <img src="framework/img/telus-logo-white.svg" alt="Telus"></p>-->
</div>
<footer>
<a class="left" rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/"><img
alt="Creative Commons License" src="framework/img/cc-by-nc.png"/></a>
<p class="left">Content created by <a href="http://christinatruong.com">Kelsey Shorten, Eric Moon, Rio
Nicholas</a> for <a prefix="cc: http://creativecommons.org/ns#" href="http://ladieslearningcode.com"
property="cc:attributionName" rel="cc:attributionURL">Ladies Learning Code</a></p>
<p class="right">Use the left <span class="arrow">←</span> and right <span
class="arrow">→</span> arrow keys to navigate</p>
</footer>
</section>
<section class="slide centered" data-markdown data-toc>
<script type="text/template">
# Today's Project
A music reactive desk light using Arduino\!
<video width="1000" controls>
<source src="framework/img/workshop/LLC-hardware%202018_Small.mp4">
</video>
</script>
</section>
<section class="slide" data-markdown data-toc>
<script type="text/template">
# Course Outline
<div class="table-of-contents"></div>
</script>
</section>
<section class="slide title" data-markdown data-toc>
<script type="text/template">
# Hardware
</script>
</section>
<section class="slide" data-markdown data-toc>
<script type="text/template">
#Micro Controllers
What is a Micro controller?
<img src="framework/img/workshop/microcontroller.png" width="400px" align="right"> </img>
<ul>
<li class="delayed"> A full computer system on a single chip. Even if its resources are far more limited
than that of a regular desktop or laptop computer
</li>
<li class="delayed"> Designed for stand alone operations and can operate in extremely low power
condition
</li>
</ul>
</script>
</section>
<section class="slide" data-markdown data-toc>
<script type="text/template">
#Micro Controllers
Why would you use a Micro controller?
* Bridge the world of hardware and software
* Self contained form factor (All in one architecture)
* Low power scenarios
* No need for higher level processing
</script>
</section>
<section class="slide" data-markdown data-toc>
<script type="text/template">
#Micro Controllers
Micro controllers do three basic things
1. Gathers Input
1. Processes
1. Creates output
<img src="framework/img/workshop/needInput.jpg" width="300px" class="delayed">
-><!-- .element: class="delayed" -->
<img src="framework/img/workshop/processing-gif-5.gif" width="300 px" class="delayed">
-><!-- .element: class="delayed" -->
<img src="framework/img/workshop/flexibleLED.gif" width="300 px" class="delayed">
</script>
</section>
<section class="slide centered" data-markdown>
<script type="text/template">
#Meet the Arduino Nano
<img src="framework/img/workshop/arduino.jpg">
</script>
</section>
<section class="slide title" data-markdown>
<script type="text/template">
# Electricity
</script>
</section>
<section class="slide" data-markdown>
<script type="text/template">
# Electricity: Safety First
Electricity is dangerous. Even at 5V
- **Don’t plug anything in until you are expressly instructed to do so. Not following this simple instruction could result in catastrophic component failure or potential bodily harm.**
- Keep hands dry
- Keep water and other liquids clear of the work area
- Please do not insert components into oral cavity
---
<img src="framework/img/workshop/danger-electric-shock-risk-printable-sign.gif" align="left">
<small align="right"> *Or, you know, a mild tingle*</small>
</script>
</section>
<section class="slide" data-markdown>
<script type="text/template">
# Electricity: Power it Up
Positive + Negative
- You need both to complete a circuit
- The wires can be any color but typically follow a red/black or red/white convention
---
**Did you know?** <!-- .element: class="note" -->
Electrons flow from the NEGATIVE terminal to the POSITIVE terminal. <!-- .element: class="note" -->
(Anyone know why?)<!-- .element: class="note" -->
</script>
</section>
<section class="slide" data-markdown>
<script type="text/template">
# Electricity: AC vs DC Electricity
* AC stands for Alternating Current <!-- .element: class="delayed" -->
* DC for Direct Current <!-- .element: class="delayed" -->
* Conversion <!-- .element: class="delayed" -->
</script>
</section>
<section class="slide" data-markdown>
<script type="text/template">
# Electricity: Volts vs Amps
<img src="framework/img/workshop/voltage.jpg" align="right">
<p>Today we are working with:</p>
<ul>
<li>120V Original Source (Dangerous)</li>
<li>3.3 - 5V Transformed Source (Less Dangerous)</li>
<li>Up to 20A Original Source</li>
<li>Up to 2.5A Transformed Source</li>
</ul>
</script>
</section>
<section class="slide" data-markdown>
<script type="text/template">
# Types of Circuits
<p>What’s a circuit?</p>
<ul>
<li>A closed loop that allows electrons to flow freely from a surplus of to a deficit</li>
<li>There are two main types of circuits.
<ul>
<li>Series</li>
<li>Parallel</li>
</ul>
</li>
</ul>
<img src="framework/img/workshop/circuits.jpg" align="right">
<p>We will be constructing a parallel circuit today</p>
</script>
</section>
<section class="slide title" data-markdown>
<script type="text/template">
# Components
</script>
</section>
<section class="slide" data-markdown>
<script type="text/template">
# Component Review: Power Source
We already met our micro controller.
Let’s meet the rest of the team.
**Power pack/Power Source/Wall Plug/Wall Wart**
<img src="framework/img/workshop/wall-wart.jpg">
</script>
</section>
<section class="slide" data-markdown>
<script type="text/template">
<h1 id="componentreviewinputs">Component Review: Inputs</h1>
<img src="framework/img/workshop/sound-sensor.jpg" align="right">
<p>So many inputs to choose from:</p>
<ul>
<li>Switches/Buttons</li>
<li>Light sensors</li>
<li>Temperature sensors</li>
<li>Ultrasonic range finders</li>
<li>Moisture sensors</li>
</ul>
<h2>Sensor we are using:</h2>
<ul>
<li>Sound sensor built into a module</li>
</ul>
</script>
</section>
<section class="slide" data-markdown>
<script type="text/template">
<h1 id="componentreviewoutputs">Component Review: Outputs</h1>
<img src="framework/img/workshop/free-shipping-rgb-5m-5050-led-strip-light-5050-60-led-strip-light-5050-300-led._cpcn-multi-color-waterproof-led-strip-with-remote-control.jpg" align="right">
<p>So much output potential:</p>
<ul>
<li>Buzzers/Speakers</li>
<li>Visual signal generators</li>
<li>Motors and actuators</li>
<li>Ethernet shields</li>
</ul>
<h2> Our output: </h2>
<ul>
<li>LED in the form of a parallel array</li>
</ul>
</script>
</section>
<section class="slide title" data-markdown>
<script type="text/template">
# The Circuit
</script>
</section>
<section class="slide" data-markdown>
<script type="text/template">
# Prototyping the Circuit
This is the diagram of the circuit we are building
<img src="framework/img/workshop/LampDiagram.png">
</script>
</section>
<section class="slide" data-markdown>
<script type="text/template">
# Prototyping the Circuit
Ok. Let’s build our circuit. You guys should have something that looks like this:
<img src="framework/img/workshop/arduinos_rigged.jpg">
</script>
</section>
<section class="slide" data-markdown>
<script type="text/template">
# Prototyping the Circuit
<img src="framework/img/workshop/circuit-picture1.jpg">
</script>
</section>
<section class="slide" data-markdown>
<script type="text/template">
# Testing the Circuit
## Online (Best Option)
1. Open **Arduino Create** [https://create.arduino.cc/](https://create.arduino.cc/)
1. Login and go to the Arduino Web Editor
1. If you have not already installed the Arduino plugin, do so now
It's important to use either Chrome or Firefox when working with Arduino Create <!-- .element: class="note" -->
## Offline
1. Download the Arduino IDE: <a href="https://www.arduino.cc/en/Main/Software">https://www.arduino.cc/en/Main/Software</a>
</script>
</section>
<section class="slide" data-markdown>
<script type="text/template">
# Testing the Circuit
1. In the left hand panel, click the **import** button to upload the test_sketch from the learner files
<img src="framework/img/workshop/arduino_create1.PNG">
1. Alternately, copy paste the following code into the editor window:
```c++
#include "FastLED.h"
// How many leds in your strip?
#define NUM_LEDS 60
// For led chips like Neopixels, which have a data line, ground, and power, you just
// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
#define DATA_PIN 6
#define CLOCK_PIN 13
// Define the array of leds
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
}
void loop() {
// Turn the LED on, then pause
for (int i = 0; i < NUM_LEDS; i++)
leds[i] = CRGB(0, 255-2*i, 0+2*i);
FastLED.show();
delay(500);
// Now turn the LED off, then pause
for (int i = 0; i < NUM_LEDS; i++)
leds[i] = CRGB::Black;
FastLED.show();
delay(500);
}
```
*Don't worry, we'll go over all this code later! For now, we just want to see that the circuit has been set up correctly*<!-- .element: class="note" -->
</script>
</section>
<section class="slide" data-markdown>
<script type="text/template">
# Testing the Circuit
1. Plug in your Arduino board using the provided USB cable
1. Go to the Editor panel and click the dropdown menu to select your Arduino Board
1. Choose 'Board at COM3' (Windows) or 'Board at Serial Port ___' (Mac)
<img src="framework/img/workshop/arduino_create2.PNG">
1. Select COM3 / Serial Port under Ports
1. Select the correct Arduino board under Boards (Check with your instructor if you are unsure which Ardunio board is being used in this workshop)
</script>
---
Mac Users: There may be more than one serial port listed. If the first port you try does not work, try the others until your code is uploaded successfully <!-- .element: class="note" -->
</section>
<section class="slide" data-markdown>
<script type="text/template">
# Testing the Circuit
1. To check your code, click the Verify button at the top left of the editor window.
1. If the code compiles, click the -> button to upload your sketch to the arduino
1. If you did everything correctly, your LED strip should begin to blink!
<img src="framework/img/workshop/loki-success.gif">
</script>
</section>
<section class="slide" data-markdown>
<script type="text/template">
# Manufacturing
Now that we know the circuit is working, it's time to make things a little more permanent.
The best way to do this is to solder all the components together, but you can also use the less permenant (But less secure!) method of twisting all the wires together, and then wrapping them up with electrical tape.
<img src="framework/img/workshop/manufacturing_arduino_routeique.jpg">
</script>
</section>
<section class="slide" data-markdown>
<script type="text/template">
# Soldering Dos and Donts
- <strong>DO</strong></li>
- Keep hair and clothing tied up and out of the way
- Use small amounts of soldering compound
- Lay out all your components beforehand. Check the orientation of all components before soldering
- Wash your hands after using solder! Solder contains lead, which is a poisonous metal.
- <strong>DON'T</strong>
- Touch the electrical components directly with the hot iron. Touch the contacts on the board and wires!
- Rest the iron on your workbench, or near live components. Always return it to its holder.
- Breathe in the fumes from hot solder
</ul>
</script>
</section>
<section class="slide title" data-markdown>
<script type="text/template">
# The Code
</script>
</section>
<section class="slide" data-markdown>
<script type="text/template">
# Arduino Programing
Arduino programs are called "Sketches". A sketch is a single program uploaded to the microcontroller, that
runs all the time when the microcontroller is powered on.
When we clicked the "Compile and Upload" button in the previous step, the Arduino IDE put our program into the microcontroller's memory
<img src="framework/img/workshop/running.gif"/>
</script>
</section>
<section class="slide" data-markdown>
<script type="text/template">
# C++
Sketches are written in C++.
C++ is a *compiled* language. That means we have to run the program through a compiler. The Compiler reduces the C++
code to machine language that can be directly executed by the CPU of the microcontroller.
This is different from other languages that you may have worked with, like Python or Javascript, which are
intrepreted languages, which the computer 'compiles' line by line when you run it.
---
###Reference
[Arduino Language Reference] (https://www.arduino.cc/reference/en/)
</script>
</section>
<section class="slide" data-markdown>
<script type="text/template">
# C++ : Variables
```C
// Variables
int integer_variable = 9; // An Integer
float float_variable = 2.3; // A decimal number
String a_string = "A string"; // A text String
#DEFINE A_CONSTANT 25 // Some kind of constant value
```
---
###Reference
[Arduino Language Reference] (https://www.arduino.cc/reference/en/)
</script>
</section>
<section class="slide" data-markdown>
<script type="text/template">
# C++ : Comments
```C
// Comments in C++ are denoted using // marks
/*
* Multi line comments
* Can be added like this.
* Comments are ingored by the complier, and are there for you, when you go back to edit your program later.
*/
// Comment often!
```
---
###Reference
[Arduino Language Reference] (https://www.arduino.cc/reference/en/)
</script>
</section>
<section class="slide" data-markdown>
<script type="text/template">
# C++: IF
```C
// Control Flow
if ( statement == true) {
// Some Code
} else {
// Code to run if nothing else was true
}
```
Remember: Every time you open a bracket { .... you have to close it again! } <!-- .element: class="note" -->
---
###Reference
[Arduino Language Reference] (https://www.arduino.cc/reference/en/)
</script>
</section>
<section class="slide" data-markdown>
<script type="text/template">
# C++: FOR
```C
// Loops
for ( int i = 0 ; i < 10; i++) {
// The loop increment i by one each time it runs until i is less than 10
}
```
- Q: How many times will this loop run?
- A: 10 times ( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9) <!-- .element: class="delayed" -->
---
###Reference
[Arduino Language Reference] (https://www.arduino.cc/reference/en/)
</script>
</section>
<section class="slide" data-markdown data-toc>
<script type="text/template">
# Structure of the program
<p>The program has three main sections:</p>
<ul>
<li>Imports: <!-- .element: class="delayed" --><ul>
<li>This is the section where we bring in extra code libraries, and define variables for the rest of the program.</li>
</ul>
</li>
<li>Setup: <!-- .element: class="delayed" --><ul>
<li>Code in Setup runs once at the beginning of the program. This is the place where we will tell the program important information, like which pins our LED strip is attached to.</li>
</ul>
</li>
<li>Loop: <!-- .element: class="delayed" --><ul>
<li>Code in the Loop runs over and over again</li>
</ul>
</li>
</ul>
---
###Reference
[Arduino Language Reference] (https://www.arduino.cc/reference/en/)
</script>
</section>
<section class="slide" data-markdown data-toc>
<script type="text/template">
# Imports
The first statement in our imports is an **include** statement.
```C
#include "FastLED.h"
```
This tells the compiler to include all the functions from the FastLED library when building the program for the
micro controller.
---
###Reference
Arduino Library Reference:<!-- .element: class="note" --> https://www.arduino.cc/en/Reference/Libraries/ <!-- .element: class="note" -->
</script>
</section>
<section class="slide" data-markdown data-toc>
<script type="text/template">
# Constants
Next, we define some constants for our program
```C
// Number of LEDs in the strip
#define NUM_LEDS 60
// Output pin for the LED Strip
#define DATA_PIN 6
```
* These are just variables that we have no intention of changing while the program runs
* Why do you think we assign these values to variables instead of just using '60' or '6' all the time? <!-- .element: class="delayed" -->
</script>
</section>
<section class="slide" data-markdown data-toc>
<script type="text/template">
# Setup
```C
void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
}
```
- Setup is a function that runs once at the begining of a program.
- We know it is a function because:
- It starts with a return type (in this case void, because it doesn't return anything)
- Tt is followed by a pair of braces (). The code inside setup is wrapped in {}
</script>
</section>
<section class="slide" data-markdown data-toc>
<script type="text/template">
# Loop
```C
void loop() {
// Turn the LED on, then pause
for (int led = 0; led < NUM_LEDS; led++){
leds[led] = CRGB(0, 255-2*led, 0+2*led);
}
FastLED.show();
delay(500);
// Now turn the LED off, then pause
for (int led = 0; i < NUM_LEDS; led++) {
leds[led] = CRGB::Black;
}
FastLED.show();
delay(500);
}
```
Loop runs over and over again. Once we get to the end of this set of code instructions, the program goes back up to the top and starts it all over again
<img src="framework/img/workshop/A_blink_program_through_LED.gif">
</script>
</section>
</section>
<section class="slide" data-markdown data-toc>
<script type="text/template">
# Getting Some Output
- How are we getting this light and these colours anyway? Anybody want to guess based on the code below?
```C
// Turn the LED on, then pause
for (int led = 0; led < NUM_LEDS; led++) {
leds[led] = CRGB(0,200, 100);
}
FastLED.show();
delay(500);
```
<ul>
<li class="delayed"> In **setup** we told the program that our LED strip was stored in the array ``` leds``` </li>
<li class="delayed"> Next, we use a **loop** to set a colour for each of our leds </li>
<ul>
<li class="delayed"> CRGB is a way of saying use these RGB color values </li>
</ul>
<li class="delayed"> ``` FastLED.show()``` then tells the program to turn on all the LEDs with the colours we just set in the loop </li>
</ul>
---
###Reference
FastLED Documentation:<!-- .element: class="note" --> http://fastled.io/docs/3.1/ <!-- .element: class="note" -->
</script>
</section>
<section class="slide" data-markdown data-toc>
<script type="text/template">
# Change the colours yourself
<img src="framework/img/workshop/rgb.png" align="right" width="300px"/>
- Change the numbers in the CRGB to change the colour of the blink.
- The RGB in CRGB stands for Red, Blue and Green
- Each number can go go from 0 to 255
- <span style="color:rgb(200,0,255);">Purple: CRGB(200, 0, 255)</span>;
- <span style="color:rgb(0,200,0);">Green: CRGB( 0, 200, 0)</span>;
- <span style="color:rgb(0,225,255);">Turquoise: CRGB(0, 225, 255)</span>;
- <span style="color:rgb(255,110,0);">Orange: CRGB(255,110,0)</span>;
- Use variables to make the colours change along the strip!
---
###Reference
Color Picker<!-- .element: class="note" --> : https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Colors/Color_picker_tool <!-- .element: class="note" -->
</script>
</section>
<section class="slide" data-markdown data-toc>
<script type="text/template">
# Getting a signal
Earlier, we set a variable that corresponds to the input pin on the sensor. All we need to do now is to get the reading.
Because this is an analog sensor, we can use the analogRead function
```C
int sensor_value = analogRead(ANALOG_READ);
```
Of course, it would be very helpful if we knew exactly what sort of signal we were getting!
</script>
</section>
<section class="slide" data-markdown data-toc>
<script type="text/template">
# Serial Monitor
```C
void setup() {
Serial.begin(9600);
// ...
}
```
```C
void loop() {
// ...
Serial.println(sensor_value);
}
```
<img src="framework/img/workshop/Monitor.PNG" align="right">
- What is the maximum value this microphone will read? What is the minimum?
In Arduino create, the monitor can be found in the left hand menu. In the offline IDE, you can find it under tools > monitor <!-- .element: class="note" -->
</script>
</section>
<section class="slide" data-markdown data-toc>
<script type="text/template">
# Light some LEDs!
We're going to use the map function to figure out how many LED lights to light up
```C
int sensor_value = analogRead(ANALOG_READ);
int numLedsToLight = map(sensor_value, 0, 737, 15, NUM_LEDS);
```
- Map() re-maps a number from one range to another.
- We're mapping the sensor value onto the the number of LEDs we want to light up
</script>
</section>
<section class="slide" data-markdown data-toc>
<script type="text/template">
# Light some LEDs!
Then,we can use the exact same method we used before to light up the LEDs, only this time, we'll only light up the amount determined by our sensor value!
```C
// First, clear the existing led values
FastLED.clear();
for (int led = 0; led < numLedsToLight; led++) {
// put some fancy colour changes in there
leds[led] = CRGB(255, 255-2*led, 0+2*led);
}
FastLED.show();
```
</script>
</section>
<section class="slide" data-markdown data-toc>
<script type="text/template">
# The Full Code
```C
#include
<FastLED.h>
#define DATA_PIN 6
#define ANALOG_READ 0
#define NUM_LEDS 73
CRGB leds[NUM_LEDS];
void setup() {
Serial.begin(9600);
// put your setup code here, to run once:
FastLED.addLeds
<NEOPIXEL
, DATA_PIN>(leds, NUM_LEDS);
}
void loop() {
int sensor_value = analogRead(ANALOG_READ);
int numLedsToLight = map(sensor_value, 0, 737, 0, NUM_LEDS);
// First, clear the existing led values
FastLED.clear();
for (int led = 0; led < numLedsToLight; led++) {
leds[led] = CRGB(255, 255-2*led, 0+2*led);
}
FastLED.show();
delay(3);
}
```
</script>
</section>
<section class="slide" data-markdown data-toc>
<script type="text/template">
# Make it Better!
This example is for a very, very basic version of the program! There lots of things we can do to improve it
- Use a smoothing function on the sensor reads
- Add a delay to the loop
- Fine tune the max and min of the microphone
- Change colours according to the volume
- ???
</script>
</section>
<section class="slide last" data-markdown data-toc>
# Thanks!
- Our soldering volunteers: Patryk, Rio, Eric, Sam, Tim
- Special thanks to Patryk for manufacturing all our jar assemblies!
- Our awesome team of Mentors
- The INC for hosting us in this space
- Our super great chapter leads from Canada Learning Code
- Routeique for sponsoring!
</section>
<!-- .element: class="delayed" -->
</main>
<script src="framework/scripts/jquery-1.11.0.min.js"></script>
<script src="framework/scripts/slideshow.js"></script>
<!-- Uncomment the plugins you need -->
<script src="framework/scripts/plugins/css-edit.js"></script>
<script src="framework/scripts/plugins/css-snippets.js"></script>
<script src="framework/scripts/plugins/css-controls.js"></script>
<!-- <script src="plugins/code-highlight.js"></script>-->
<script src="framework/scripts/plugins/markdown/marked.js"></script>
<script src="framework/scripts/plugins/markdown/markdown.js"></script>
<script src="framework/scripts/plugins/highlight/highlight-8.4.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="framework/scripts/llc.js"></script>
<script>
var slideshow = new SlideShow();