Abstraction: An abstraction is a representation of an object or concept. It could be something such as a door, a speedometer, or a data structure in computer science. Abstraction decouples the design from the implementation. The gauges in an automobile are an abstraction of the performance of a car. A map is an abstraction of the earth.
Modularization: The concept of modularity is like building blocks. Each block (or module) can be put in or taken out from a bigger project. Each module has its own separate function that is interchangeable with other modules.
Simplicity: Simplicity allows a person to better understand hardware and software. Without the clutter of unnecessarily complicated code and interfaces, the software will be more understandable by people that will update the code when requirements change. It will be easier to understand by the testers and they will be able to spot problems sooner. By keeping software as simple and as focused as possible, the reliability and security is greatly increased.
In this lesson, we will explore a cool hands-on technology called Littlebits. Littlebits follows a component-based design paradigm using GPIO (or general purpose input/output) to let you easily make apps. We will learn how to plug and play bits together to make some simple inventions. Littlebits will be the central platform for the rest of camp and you will be using them in other lessons.
By the end of this tutorial, you will be able to:
modularity
None
First, open your Littlebits box. Take a second to look at the different components you have. Littlebits is organized around three colors:
Look over each module. Your box should include a helpful component diagram fold-out poster that shows off each of your modules. Read about some of them.
No time like the present. Lets make a simple invention:
power
module.button
input modulebright led
output moduleLets make a simple circuit:
power
modulebutton
to the power
modulebright led
to the button
.Press the button and the light turns on. That was easy!
This is GPIO
in a nutshell. Each module has a general purpose input and output, with a standard interface, and doesn’t need to understand or know anything about what they are connected to. These modules also need to protect themselves from invalid input. This is a great example of the modularity
cybersecurity first principle.
Ok, we’ve made our first circuit - but it’s pretty simple. Let’s add some more modules:
o21 number
output moduleTime to extend your previous circuit to
o21 number
to the bright led
o21 number
module. This puts it into count mode instead of voltage mode.Press the button!
Pretty simple. Notice we can chain the output modules together (bright led
and a counter
in this case). Any number of output modules can be chained together.
Now, lets switch up our circuit a bit.
sound trigger
input modulelight sensor
input moduleLets swap some components around.
bright led
module (it is really bright!)Press the button. Everything still works!
light sensor
to the power
and then to the button
Press the button. Does it work? How about if you cover up the light sensor?
This shows you that you can also chain multiple input modules together and their total behavior is a combination of their input designs. In this case, our counter only worked if the light was detected AND the button was pressed.
Lets try one more combo:
button
module.light sensor
module.sound trigger
between the power
and the o21 number
module.Snap your fingers or tap the table near your device.
So far, we have outputs and inputs that result in an on (True) or off (False) behavior.
.
The world is not always on or off
temperature sensor
input module.i23 threshold
input module.light sensor
and bright led
out againWe are going to make a circuit that shows off variable voltage.
temperature sensor
to the o21 number
module.o21 number
switch to value (middle position)temperature sensor
switch to f (for Fahrenheit)You should see the current temperature in the room near the device.
temperature sensor
with the light sensor
o21 number
module back into voltage mode by moving the switch to the bottom position.You should see that the more light it gets, the more voltage it outputs.
bright led
to the right-hand side of the o21 number
moduleYou should notice the light dimming and brightening depending on the voltage it receives.
Ok, last part!
i23 threshold
module between the o21 number
and bright led
modulesi23 threshold
by turning the knob.bright led
So, what did we learn? The thresholder can set a voltage tolerance and output a 1 (True) if its input is greater than the threshold*. This can be helpful if you want to do sound, light, or temperature detection, but you only want to output True if the value is greater than some value.
Photo Credit: CmOrigins@deviantart http://cmorigins.deviantart.com/art/Navi-Hey-Listen-322389835
Sometimes you want your inventions to have some sound. The next design we will explore involves using audio.
mp3 player
input modulesynth speaker
output modulebutton
module againLets play a sound when a button is pressed:
button
to the power
mp3 player
to the button
synth speaker
to the mp3 player
Press the button. This plays all of the tracks. If you move the mp3 player
switch to next, it will allow you to press the button
to switch tracks. You can also use the buttons on the mp3 player
board.
By default, the mp3 player
comes loaded with stock Littlebits tutorial audio. You can replace it using the sdcard
in the board to load it with your own audio.
The next module to explore is the ir transmitter
and power outlet
combo.
ir transmitter
output modulebutton
moduleLets wire this up so that when you press the button the outlet comes on.
button
up to the power
ir transmitter
to the button
Pressing the button should turn on the device. The first time you press it, you will see the outlet light blink. It is pairing up. Once its paired, press the button a few times. You can see the red light turn on and off as you do.
Note: Since it is IR, the IR transmitter needs line-of-sight to the IR sensor on the outlet.
The last module we will explore is the servo
which can bring actual movement into your inventions!
button
to the power
.servo
to the button
.white plastic gear
on the servo
servo
board to turn
.Note you don’t need to use the screw, but hang onto it for later - it should be used in production to secure the turner down
When you press the button, it should rotate the arm 90 degrees.
This can be used for all kinds of purposes!
Try some different designs yourself.
For more information, investigate the following:
Special thanks to Dr. Robin Gandhi for reviewing and editing this lesson.
Nebraska GenCyber
is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Overall content: Copyright (C) 2017-2018 Dr. Matthew L. Hale, Dr. Robin Gandhi, and Doug Rausch.
Lesson content: Copyright (C) Dr. Matthew L. Hale 2017-2018.
This lesson is licensed by the author under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.