Raspberry Pi Hardware Projects 1 by Andrew Robinson
Author:Andrew Robinson [Robinson, Andrew]
Language: eng
Format: epub, pdf
Tags: Computers, Systems Architecture, General, vl-nfcompvg
ISBN: 9781118588949
Google: hgwFAQAAQBAJ
Amazon: B00FGRLM9U
Publisher: Wiley
Published: 2013-09-25T00:00:00+00:00
Designing the Sequencer
Now that you have all the elements in place you can begin to think about how you want this to look and operate. This is called top-down design because you start with a top-level view of what you want the software to look like.
I envisaged a grid of squares, each one representing an LED and its position in the sequence. A column of eight squares would represent the states of the LEDs at any instance in the sequence. A marker under the column will indicate what LEDs are being lit at any time. A mouse click in one of these squares will toggle the LED.
In order to help set up the sequence there should be some control buttons, one to clear or turn off all the LEDs in all sequence positions, and another to toggle or invert all the LEDs. There should be control buttons to determine the speed of the sequence and finally one to select where to take the trigger to advance the sequence from. This last point is important if you want to synchronise the changing of the lights to the beat of the music. The sequence can either be stepped at a regular rate determined by the speed controls, or locked into the beat of the music. This last feature will require a little bit of extra hardware and is optional – you can skip it for now and add it later if you like.
Finally it would be good if all the colours used in the sequence software were customizable; that is, it should be easy to change by changing a single value at one point of the code only. This means that whenever you use a colour you do not hard code it in by putting the colour numbers into a function call, but rather use a variable to define that colour. Those variables for all the colours should be grouped in one place in the code for easy access.
Implementing the Sequencer
After designing the sequencer from the top down, when it comes to implementing the design it is better to write the code in what is known as a bottom-up implementation. That means starting at the lowest possible function and working your way up. Of course, if you just look at the finished code you don’t see that. I started by taking the window test program and writing the functions that showed the columns representing the LEDs in the sequence. Then I expanded it so that I could click on each LED to turn the box on or off. Next came the controls to clear and invert, followed by the step indicator. This was followed by the speed controls and at this point I added the code to actually output something to the LEDs. Finally the auto/external step control was added and the code tidied up. This might not be the sequence of building up a program that first springs to the mind of a beginner, but the idea is to do a little coding and then test.
Download
Raspberry Pi Hardware Projects 1 by Andrew Robinson.pdf
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Linux Device Driver Development Cookbook by Rodolfo Giometti(3932)
Embedded Programming with Modern C++ Cookbook by Igor Viarheichyk(3594)
Implementing Cellular IoT Solutions for Digital Transformation by Dennis McCain(3533)
Embedded Linux Development Using Yocto Project - Third Edition by Otavio Salvador & Daiane Angolini(3361)
TinyML Cookbook by Gian Marco Iodice(3299)
Simplifying 3D Printing with OpenSCAD by Colin Dow(2839)
TinyML Cookbook by Gian Marco Iodice & Ronan Naughton(2601)
Fusion 360 for Makers by Lydia Sloan Cline(2219)
Networking A Beginner's Guide by Bruce Hallberg(2209)
Hands-On Linux for Architects by Denis Salamanca(2051)
But How Do It Know? by J. Clark Scott(2030)
Computers For Seniors For Dummies by Nancy C. Muir(1995)
Raspberry Pi and MQTT Essentials by Dhairya Parikh(1951)
Arduino Project Handbook, Volume 2: 25 Simple Electronics Projects for Beginners by Geddes Mark(1947)
9781803246888-ENHANCING DEEP LEARNING WITH BAYESIAN INFERENCE by Unknown(1899)
Hack and HHVM by Owen Yamauchi(1884)
31 Days Before Your CompTIA A+ Exams (Shanette Luellen's Library) by Benjamin Patrick Conry(1860)
MicroPython Projects by Jacob Beningo(1731)
Hands-On Internet of Things with MQTT by Tim Pulver(1706)
