1 Video View·Apr 21, 2025
The real power of an Arduino Microcontroller is it's ability to control real world devices from programs we write! These real world devices are called inputs when they are devices we read information from, such as the state of a pushbutton. These devices are called outputs when they are devices we want to control, such as LED lights.
If you want to follow along with this project exactly and need the same hardware kit, you can grab it here from Amazon!
https://amzn.to/3zppXAr
Check out the full Arduino Tutorials Playlist on the channel for more automation and electronics content!
https://www.youtube.com/playlist?list=PLsFyHm8kJsx0wNcgdb9mSZHqwQoC9HBlc
Consider becoming a super supporter of the channel and helping us grow into bigger and better projects!!!
https://www.patreon.com/LeMasterTech
In this video we start by covering quickly the basics of wiring electrical components in parallel versus series. We then dive into how to write the full code to read from the pushbutton and control the states of the three LED lights.
The pushbutton serves as our input and we want the Green LED light to be on while it isn't pressed. Then when the light gets pressed we want the Red LEDs to flicker between the two and the green light to go off!
We then show how to assemble every electrical components to fully build the physical project. We cover how to use the LEDs, resistors, pushbutton, and input and output wires with your breadboard! In this video we focus on digital inputs and digital outputs, but we'll be taking a look at analog inputs and outputs in the upcoming videos!
Be sure to leave a comment if you have any questions or want to see more of something specific on the channel in the future! Don't forget to leave a like and subscribe and maybe even ring the bell if you want, or don't, I'm not a cop.
Timestamps:
00:00 Intro and Background
01:20 Quick Science-y Lesson Thing: Parallel and Series Circuits
03:16 Writing the Code for Arduino Spaceship Interface
07:12 Building the Physical Circuit for the Project
08:35 Showcase, Project Completed and Outro
what's up you guys welcome back to the
channel in today's video we are going to
build the Arduino beginner project
called spaceship interface it's a cool
name for a cool beginner project with
some great electronics and programming
Concepts so let's get right into it
[Music]
so this project builds right off the
first Arduino tutorial video we just
rolled out on the channel I'll leave a
link to the playlist of the Arduino
videos in the description of this video
and a card to it somewhere in the top of
the video right now as well the kit
we're using in these initial few
projects is the Arduino starter kit I
got it from Amazon and I will put a link
to it in the description section of this
video if you'd like to get the same kit
to follow along with all these projects
exactly in the first video I show you
how to get everything set up initially
so we dive right into the concepts in
this project assuming you've got the
programming software on your computer
and your board and breadboard all set up
and ready to go so we built a very basic
circuit in our first tutorial and to
summarize it we provided a 5 volt power
supply from our Arduino through a 220
Ohm resistor into a push button switch
then through to an LED and finally back
to ground via the Arduino board again
check out the previous video if you need
a deep dive into what's happening in
this circuit and before we get into the
spaceship interface it's time for a
quick sciency lesson thing
lesson thing so everything in an
electrical circuit exists in either
parallel or in series with the
components around it things in series
can be considered what a programmer
would call an and command while
everything stacks on top of each other
while something in parallel can be
viewed as an or command where there's
basically a branch and you can do either
option to look at the circuit we already
built let's take a look at how we would
add a second push button to this circuit
once in series and once in parallel to
add a second push button here we are
adding it in series meaning that for the
LED to get turned on AKA for electricity
to get to the LED from our power supply
we need this push button to be pressed
and this push button to be pressed the
conditions are additive and there is no
other combination of these switches
other than both being pressed that will
lead to the LED lighting up however if
we add a second push button to the
Circuit here we we are now adding it in
parallel to the first switch that means
by pressing this switch or this switch
we provide a valid flow path for
electricity to make it to the LED both
parallel and series circuits have
different rules for calculating current
resistance and voltage using Ohm's law
but that's a discussion for a future
lesson that's it for this quick sciencey
lesson thing
all right so this project is called the
spaceship interface because the overall
look and concept of the project is meant
to replicate the special effects of a
classic 70 eras sci-fi spaceship control
board in the first configuration we
build we're going to use three LEDs one
that will be on the whole time our
control button is not pressed and then
when we press the control button the
other two lights will alternate flashing
between and the first light will turn
off this will be our first project
reading physical input signals into our
Arduino board and controlling outputs
based on those signals let's start by
taking a look at what the code for this
project object is going to look like so
as always in an Arduino project often
typically referred to as a sketch the
two main areas for putting functional
code are the setup area which executes
once at the beginning of your code and
the loop area where a code that you want
to run continuously goes for this
project we are also going to create a
global variable before those two areas
to keep track of the state of our
control push button do this by creating
a line of code where we Define a
variable that'll be an integer using int
give it a descriptive variable name in
this case switch State and an optional
but good step to add is give the
variable an initial state in this case
we'll use zero then in the setup region
of your program Define which pins you're
going to use for physical inputs and
outputs in your build because the
digital pins on arduinos can be used as
inputs or outputs you need to tell your
board which way you want to use them in
this case we have one push button as an
input in our project and we're going to
control the state of three LEDs as
outputs therefore we'll Define pin mode
2 as an input so we can hook our push
button up to that pin and we'll make pin
mode 3 4 and 5 all outputs to control
our three LEDs if you build your
programming first it's very important to
make sure you keep your PIN definitions
in mind as you build the physical
circuit likewise if you build the
physical circuit first it's very
important to keep an eye on where you
hooked everything up when you write your
code so next let's take a look at what
to put in the loop region of the sketch
first thing we will do in every Loop is
check the state of the push button
switch we do this simply by setting our
Global variable switch State equal to
the status of the input on pin 2. this
requires the simple command digital read
followed by the pin you want to read
from in this case pin 2. this means we
can create a simple if else piece of
code to determine what to do with our
outputs based on the state of our push
button now stored in the switch State
variable first if the switch state is
low meaning button not pressed we want
the green light to turn on so we'll use
the simple command digital right to tell
our green light to turn on this requires
giving digital right to arguments first
we tell it what pin to write to in this
case three for the green light then what
value to write to that pin in this case
hi to turn it on now use the same
command line for Pins four and five but
this time write a command low to turn
off our two red lights while the button
is not pressed this is everything we
want to have happen while the button is
not pressed now let's take a look at
what to do if the button is pressed
because with digital Boolean points the
only two states are on or off so just
else is all we need to say to put
commands in for while the button is
pressed so the first line is going to be
the most direct and easy because all
we're going to say is that we want the
green led to turn off the whole time the
button is pressed similar to before
we're just writing a value of low to pin
three now let's take a look at what
we're going to do to command the red
lights when the button is initially
pressed we'll turn one light on and
another light off while it's just two
identical red lights which one we turn
on and off doesn't really matter too
much so I'll just say pin for off in pin
5 on initially then to incorporate
alternating flashing lights put a delay
into your code and hold those States for
a defined duration the delay command
uses units of milliseconds so we'll use
250 or one quarter of a second as a
default value after the delay of 250
milliseconds we'll flip the states of
pins four and five then add another 250
millisecond delay in total this reads as
while the button is pressed and held in
flip the states of my two red lights
every quarter second back and forth this
is the whole project so go ahead and
verify it to make sure there's no errors
with your build and then if you have
your Arduino plugged in you can go ahead
and upload the build to the controller
you could also wait to upload until we
built the circuit because as always we
should build the circuit with the board
disconnected from power now let's check
out the physical circuit build for this
project you'll need your Arduino board
and your breadboard and a few jumper
wires and in addition to those you'll
need two red LED lights a green LED
light a push button switch three 220 ohm
resistors and one 10 kilo Ohm resistor
start by putting 5 volt power and ground
connections to one of your breadboard's
power rails this gives that entire
column of terminals power and ground
properties respectively next run a
jumper wire from the respective pins for
your three LEDs to the long leg or anode
of that led then connect the short leg
also known as the cathode to one leg of
a 220 ohm resistor and then connect the
other leg of the resistor to ground for
this circuit the pins that act as
outputs will serve as the power supplies
to the lights when they're commanded to
be on AKA High next hook up the push
button as follows on one leg of the push
button switch provide a power feed then
on the other side of that switch connect
the leg to one leg of the 10 kilo Ohm
resistor connect the other leg of that
resistor to ground this resistor in this
case is known as a pull down resistor
because it'll Ensure sure that that leg
of the switch reads Low when the push
button is not pressed the final step in
the push button circuit is placing a
connection from Arduino pin 2 which is
our input to the downstream leg of the
switch now that's it for building this
circuit and the time has now come to put
it all together and enjoy the project if
you haven't uploaded the project to your
Arduino board yet go ahead plug it into
your computer and upload now once the
project is loaded and the board is
powered on you should have your LEDs in
their default states of green light on
both red lights off now try pressing and
holding the push button switches and you
should start to see the red lights
flashing and the green light go off
there are a lot of great ways to expand
and play around with this project for
example one of my favorites is to make
the three lights run in a sequential
order while the button's not pressed and
then do a pattern of blinks in
increasing speed when you press the
button to kind of simulate a launch
sequence already with this simple build
in this simple project there are so many
variations and creative ways to make it
your own and these base basic concepts
we've learned here of digital inputs and
outputs should get you thinking about
what kind of real world applications can
I take and use these sorts of projects
for so that's as far as we'll be going
today we covered a ton of content in
this video hopefully nothing left you
too confused or overwhelmed if you have
any questions about anything you saw
here today be sure to let me know about
in the comments below and I'll get back
to you as soon as I can all the viewers
on the master attack in the Master Tech
Community have been really amazing and
been encouraging me to become a better
engineer and continue trying new things
if you guys want to help me do bigger
and better robotics projects on the
channel consider becoming a patreon
supporter at the link in the comments
below and everyone who hits that like
button subscribes to the channel Rings
the little notification Bell will get
instant Good Vibes delivered directly to
their doorstep for free thanks and until
next time as always good luck with your
projects and thanks for watching
[Music]