Lab 3c Fun with your LED cube. ENGR 40M Chuan-Zheng Lee Stanford University 19 May 2017

Similar documents
ENGR 40M Project 3b: Programming the LED cube

EP486 Microcontroller Applications

Lecture (04) Arduino Microcontroller Programming and interfacing. By: Dr. Ahmed ElShafee

Computer Architecture and Organization. Electronic Keyboard

Fig. 1 Analog pins of Arduino Mega

ENGR 40M Project 3a: Building an LED Cube

FPGA Laboratory Assignment 4. Due Date: 06/11/2012

Bill of Materials: 7-Segment LED Die with Arduino PART NO

Module 4: Traffic Signal Design Lesson 1: Traffic Signal (Arduino) Control System Laboratory Exercise Grade 6-8

UNIVERSITY OF CALIFORNIA, DAVIS Department of Electrical and Computer Engineering. EEC180A DIGITAL SYSTEMS I Winter 2006

EECS145M 2000 Midterm #1 Page 1 Derenzo

ENGR 1000, Introduction to Engineering Design

ECE 372 Microcontroller Design

Ginger Bread House

EE292: Fundamentals of ECE

successive approximation register (SAR) Q digital estimate

Laboratory 9 Digital Circuits: Flip Flops, One-Shot, Shift Register, Ripple Counter

ECE 270 Lab Verification / Evaluation Form. Experiment 9

6.111 Final Project Proposal Kelly Snyder and Rebecca Greene. Abstract

Design Problem 4 Solutions

Lab2: Cache Memories. Dimitar Nikolov

Activity #5: Reaction Timer Using the PIN and CON commands Real World Testing Chapter 3 Review Links

SWITCH: Microcontroller Touch-switch Design & Test (Part 2)

- 1 - Contact info: Name: Petrit Vuthi Room: Office hours: Thuesday: 10:00 12:30 Wendsday: 10:00 12:30

EE 367 Lab Part 1: Sequential Logic

CPE 310L EMBEDDED SYSTEM DESIGN (CPE)

Administrative issues. Sequential logic

Measure the value of water flow using water flow sensor and DC water pump 12 V interfacing with Arduino uno

Software Engineering 2DA4. Slides 9: Asynchronous Sequential Circuits

DIGITAL CIRCUIT LOGIC UNIT 11: SEQUENTIAL CIRCUITS (LATCHES AND FLIP-FLOPS)

Physics 120 Lab 10 (2018): Flip-flops and Registers

NEW MEXICO STATE UNIVERSITY Electrical and Computer Engineering Department. EE162 Digital Circuit Design Fall Lab 5: Latches & Flip-Flops

You will be first asked to demonstrate regular operation with default values. You will be asked to reprogram your time values and continue operation

Marks and Grades Project

ENGR 1000, Introduction to Engineering Design

Digital Circuits 4: Sequential Circuits

Lecture #4: Clocking in Synchronous Circuits

Arduino Lesson 3. RGB LEDs

LabView Exercises: Part II

Digital Signal Processing

Implementing a Rudimentary Oscilloscope

Optical Technologies Micro Motion Absolute, Technology Overview & Programming

ECE 4510/5530 Microcontroller Applications Week 3 Lab 3

ORM0022 EHPC210 Universal Controller Operation Manual Revision 1. EHPC210 Universal Controller. Operation Manual

Part (A) Controlling 7-Segment Displays with Pushbuttons. Part (B) Controlling 7-Segment Displays with the PIC

EECS150 - Digital Design Lecture 3 - Timing

9/23/2014. Andrew Costin, Tom Syster, Ryan Cramer Advisor: Professor Hack Instructor: Professor Lin May 5 th, 2014

Chapter 3. Boolean Algebra and Digital Logic

This module senses temperature and humidity. Output: Temperature and humidity display on serial monitor.

FLIP-FLOPS AND RELATED DEVICES

Music-Visualization and Motion-Controlled LED Cube

ELEC 310 Digital Signal Processing

EXPERIMENT #6 DIGITAL BASICS

Self-Playing Xylophone

Due date: Sunday, December 5 (midnight) Reading: HH section (pgs ), mbed tour

Ambiflex MF620 USER GUIDE

SCE Training Curriculums

RST RST WATCHDOG TIMER N.C.

Experiment 0: Hello, micro:bit!

ECEN689: Special Topics in High-Speed Links Circuits and Systems Spring 2011

Training Note TR-06RD. Schedules. Schedule types

STB Front Panel User s Guide

Digital Circuits I and II Nov. 17, 1999

Working with CSWin32 Software

PASS. Professional Audience Safety System. User Manual. Pangolin Laser Systems. November 2O12

MP-204D Digital/Analog Stereo Monitor Panel

CARLETON UNIVERSITY. Facts without theory is trivia. Theory without facts is bull 2607-LRB

LCD STIMULUS DISPLAY for ENV-007/008 CHAMBERS

Laboratory Sequence Circuits

Laboratory Sequential Circuits

Character LCDs. Created by lady ada. Last updated on :47:43 AM UTC

Circuit Playground Hot Potato

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Electrical Engineering and Computer Sciences

MSCI 222C Class Readings Schedule. MSCI 222C - Electronics 11/20/ Class Seating Chart Mondays Class Seating Chart Tuesdays

CPE 200L LABORATORY 3: SEQUENTIAL LOGIC CIRCUITS UNIVERSITY OF NEVADA, LAS VEGAS GOALS: BACKGROUND: SR FLIP-FLOP/LATCH

Field Programmable Gate Array (FPGA) Based Trigger System for the Klystron Department. Darius Gray

Lab experience 1: Introduction to LabView

8 DIGITAL SIGNAL PROCESSOR IN OPTICAL TOMOGRAPHY SYSTEM

EE 330 Final Design Projects Spring 2015

University of Victoria. Department of Electrical and Computer Engineering. CENG 290 Digital Design I Lab Manual

Digital Logic. ECE 206, Fall 2001: Lab 1. Learning Objectives. The Logic Simulator

CS61C : Machine Structures

EECS150 - Digital Design Lecture 12 - Video Interfacing. Recap and Outline

Fig. 1. The Front Panel (Graphical User Interface)

Lab 1 Introduction to the Software Development Environment and Signal Sampling

Programmable Logic Design I

GAMBIT DAC1 OPERATING MANUAL

Introduction To LabVIEW and the DSP Board

Design and Implementation of an AHB VGA Peripheral

Do the following: a. (12 points) Draw a block diagram of your circuit design, showing and labeling all essential components and connections.

AC : EXPERIMENTS AND RESEARCH ACTIVITIES IN A MICROCONTROLLER LABORATORY

SEQUENTIAL LOGIC. Satish Chandra Assistant Professor Department of Physics P P N College, Kanpur

Laboratory 4. Figure 1: Serdes Transceiver

013-RD

Microcontrollers and Interfacing week 7 exercises

CPS311 Lecture: Sequential Circuits

Chapter 4: One-Shots, Counters, and Clocks

EE 357 Lab 4 Stopwatch

IOT BASED SMART ATTENDANCE SYSTEM USING GSM

LAB 1: Plotting a GM Plateau and Introduction to Statistical Distribution. A. Plotting a GM Plateau. This lab will have two sections, A and B.

Transcription:

Lab 3c Fun with your LED cube ENGR 40M Chuan-Zheng Lee Stanford University 19 May 2017

Announcements Homework 6 is not released today. It will be released on Monday (May 22). It will be due at 11am Tuesday week (May 30). Homework 6 prepares you for lab 4. There is still a prelab 4. Homework 7 will be released Monday, May 29, and will be due Monday, June 5. May 12, 2017 ENGR 40M Spring 2017 C.Z. Lee, J. Plummer, R. Howe 2

Overview of lab 3c Your task is to get your cube to respond to some sort of input. For most of you, this will involve adding hardware. You choose what you want to do, subject to minimum requirements. 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 You re free (and encouraged) to propose something else, but be sure to tell your TA well in advance! May 12, 2017 ENGR 40M Spring 2017 C.Z. Lee, J. Plummer, R. Howe 4

Serial data You ve already used the Serial Monitor You can also write computer software to interact with the serial port directly If you only respond to serial data, we ll expect to see some impressive software May 12, 2017 ENGR 40M Spring 2017 C.Z. Lee, J. Plummer, R. Howe 5

Analog-to-digital converter analogread() reads the voltage on the pin, scaled to be a number between 0 and 1023 void loop() { int reading = analogread(a3); Serial.println(reading); } Serial Monitor: 819 819 This takes longer than digitalread(), but this probably won t bother you May 12, 2017 ENGR 40M Spring 2017 C.Z. Lee, J. Plummer, R. Howe 6

Potentiometer Essentially a variable voltage divider standard symbol internal mechanics photo May 12, 2017 ENGR 40M Spring 2017 C.Z. Lee, J. Plummer, R. Howe 7

Potentiometer Essentially a variable voltage divider R1 and R2 vary with the wiper, but R1 + R2 = constant May 12, 2017 ENGR 40M Spring 2017 C.Z. Lee, J. Plummer, R. Howe 8

Potentiometer Connect the wiper to the analog input Read using analogread() May 12, 2017 ENGR 40M Spring 2017 C.Z. Lee, J. Plummer, R. Howe 9

Audio You can connect an audio output to your Arduino almost. May 12, 2017 ENGR 40M Spring 2017 C.Z. Lee, J. Plummer, R. Howe 10

Audio analogread() the instantaneous value The input will be centered at 2.5 V, so you ll need to process it in software An additional handout guides you through this May 12, 2017 ENGR 40M Spring 2017 C.Z. Lee, J. Plummer, R. Howe 11

Audio frequency response The ArduinoFFT3 library can process your signal to return a frequency-domain representation Implements the fast Fourier transform, an algorithm which computes a close cousin of the Fourier series An additional handout guides you through this 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 SPST, momentary and normally open (sometimes known as push-to-make) May 12, 2017 ENGR 40M Spring 2017 C.Z. Lee, J. Plummer, R. Howe 14

Pushbutton switch: debouncing What we think a switch does: What it actually does: May 12, 2017 ENGR 40M Spring 2017 C.Z. Lee, J. Plummer, R. Howe 15

Pushbutton switch: debouncing As the switch bounces, the Arduino can register many transitions Dealing with this is called debouncing One strategy: Ignore transitions too soon after the last one An additional handout guides you through this May 12, 2017 ENGR 40M Spring 2017 C.Z. Lee, J. Plummer, R. Howe 16

Programming a pattern Since you ve abstracted away the timemultiplexing part, displaying a pattern consists mainly of filling in the pattern array. Recall triply-nested loops: for (int z = 0; z < 4; z++) { for (int y = 0; y < 4; y++) { for (int x = 0; x < 4; x++) { pattern[z][y][x] = (some value); } } } May 12, 2017 ENGR 40M Spring 2017 C.Z. Lee, J. Plummer, R. Howe 17

Raindrop pattern The raindrop pattern looks like rain is falling from the top of the cube to the bottom 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 Every time period (say, 150 ms): 1. Move the pattern down by one plane 2. Choose an LED at random in the top plane Decompose this into smaller steps: 1. movepatterndown(pattern) 2. chooserandomledintopplane(pattern) As a principle, each function should do exactly one thing May 12, 2017 ENGR 40M Spring 2017 C.Z. Lee, J. Plummer, R. Howe 20

Timing and inputs Update the pattern once every (say) second With no inputs, this will work: void loop() { static byte ledon[4][4][4]; updatepattern(ledon); // updates pattern delay(1000); } May 12, 2017 ENGR 40M Spring 2017 C.Z. Lee, J. Plummer, R. Howe 21

Timing and inputs Stop/start whenever the button is pressed Why won t this work? void loop() { } static byte ledon[4][4][4]; static bool running = false; if (running) updatepattern(ledon); if (digitalread(button) == HIGH) running =!running; delay(1000); // updates pattern 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 (includes serial data) Simple response 10 Minor additional hardware Minor complexity Raindrop pattern 15 Moderate additional hardware Pushbuttons Audio non-frequency Moderate complexity 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