Lablecture 3 C
Lablecture 3 C
May 12, 2017 ENGR 40M Spring 2017 — C.Z. Lee, J. Plummer, R. Howe 2
Overview of lab 3c
May 12, 2017 ENGR 40M Spring 2017 — C.Z. Lee, J. Plummer, R. Howe 3
Our suggestions for input
• Serial data
• Potentiometer
• Pushbutton switches (or other switches)
• Audio
• Capacitive touch sensing
May 12, 2017 ENGR 40M Spring 2017 — C.Z. Lee, J. Plummer, R. Howe 4
Serial data
May 12, 2017 ENGR 40M Spring 2017 — C.Z. Lee, J. Plummer, R. Howe 5
Analog-to-digital converter
Serial Monitor:
819
819
May 12, 2017 ENGR 40M Spring 2017 — C.Z. Lee, J. Plummer, R. Howe 6
Potentiometer
May 12, 2017 ENGR 40M Spring 2017 — C.Z. Lee, J. Plummer, R. Howe 7
Potentiometer
May 12, 2017 ENGR 40M Spring 2017 — C.Z. Lee, J. Plummer, R. Howe 8
Potentiometer
May 12, 2017 ENGR 40M Spring 2017 — C.Z. Lee, J. Plummer, R. Howe 9
Audio
May 12, 2017 ENGR 40M Spring 2017 — C.Z. Lee, J. Plummer, R. Howe 10
Audio
May 12, 2017 ENGR 40M Spring 2017 — C.Z. Lee, J. Plummer, R. Howe 11
Audio—frequency response
• Video: https://youtu.be/FRXDTiOHFlI
May 12, 2017 ENGR 40M Spring 2017 — C.Z. Lee, J. Plummer, R. Howe 12
Audio—frequency response
May 12, 2017 ENGR 40M Spring 2017 — C.Z. Lee, J. Plummer, R. Howe 13
Pushbutton switch
May 12, 2017 ENGR 40M Spring 2017 — C.Z. Lee, J. Plummer, R. Howe 14
Pushbutton switch: debouncing
May 12, 2017 ENGR 40M Spring 2017 — C.Z. Lee, J. Plummer, R. Howe 15
Pushbutton switch: debouncing
May 12, 2017 ENGR 40M Spring 2017 — C.Z. Lee, J. Plummer, R. Howe 17
Raindrop pattern
• Videos
• https://youtu.be/-tZJ-3NSlhY?t=52
• https://youtu.be/DahwcDeqyA0
May 12, 2017 ENGR 40M Spring 2017 — C.Z. Lee, J. Plummer, R. Howe 18
Raindrop pattern
Every time period (say, 150 ms):
1. Move the pattern down by one plane
2. Choose an LED at random in the top plane
May 12, 2017 ENGR 40M Spring 2017 — C.Z. Lee, J. Plummer, R. Howe 19
Decomposition
May 12, 2017 ENGR 40M Spring 2017 — C.Z. Lee, J. Plummer, R. Howe 20
Timing and inputs
May 12, 2017 ENGR 40M Spring 2017 — C.Z. Lee, J. Plummer, R. Howe 21
Timing and inputs
May 12, 2017 ENGR 40M Spring 2017 — C.Z. Lee, J. Plummer, R. Howe 22
Timing and inputs
• Better: Check button without delay
void loop() {
static byte ledOn[4][4][4];
static bool running = false;
static long nextUpdateTime = millis();
if (millis() > nextUpdateTime) {
if (running)
updatePattern(ledOn); // updates pattern
nextUpdateTime += 1000;
}
if (digitalRead(BUTTON) == HIGH)
running = !running;
}
May 12, 2017 ENGR 40M Spring 2017 — C.Z. Lee, J. Plummer, R. Howe 23
Complexity requirements
• Minimum requirement:
cubes: 25; 6×6 planes: 35; larger planes: 30
• Must do one “additional handout”, or propose your own
• Details are in the “overview” handout
Points Hardware Software
5 No additional hardware Simple response
(includes serial data)
10 Minor additional hardware Minor complexity
• Raindrop pattern
15 Moderate additional hardware Moderate complexity
• Pushbuttons
• Audio non-frequency
20 Complex additional hardware Impressive complexity
May 12, 2017 ENGR 40M Spring 2017 — C.Z. Lee, J. Plummer, R. Howe 24
Breadboard style
Please don’t:
http://www.electro-music.com/forum/phpbb-files/thumbs/t_klee_bb_131.jpg
May 12, 2017 ENGR 40M Spring 2017 — C.Z. Lee, J. Plummer, R. Howe 25
Coding style
https://www.xkcd.com/1833/
May 12, 2017 ENGR 40M Spring 2017 — C.Z. Lee, J. Plummer, R. Howe 26