(upbeat music)
- Hello everyone.
Hello, thank you so
very loud.
Thank you so much for coming to my talk.
My name is Colleen Schnettler
and I am a Ruby on Rails
developer and consultant.
You can find me on Twitter @leenyburger.
I run a Rails consultancy
called Bitmapped Designs.
Pro tip, don't name your
consultancy Bitmapped Designs
'cause no one can spell that.
And today I want to talk to you about
energy and happiness and creation.
We're also gonna talk a little bit about
electronics and family.
So I'm going to attempt to cover
the entire human emotional spectrum.
So wish me luck.
So I want everyone to think back.
Think back about when you
got into software development
whether it was six months
ago or 20 years ago.
What brought you into
software development?
Like really take a minute
and just think about it.
So I had been thinking about
this question recently.
And some things came to mind for me.
Such as, like creating something.
You know, more ambitious
things like changing the world.
Having control over my own
destiny and my own career.
And of course you know, making money
was always important to me as well.
But I think the main reason
I got into engineering
was because I really loved math.
And I've always loved math.
I was really good at it and
I was gonna be a math major.
But I discovered engineering
and I decided to become an engineer
'cause I realized it
seemed to be a better way
to kind of mold physics
and math and practicality
and actually build something.
So I went to Purdue University
and I studied electrical engineering.
And I had a wonderful
four years at university.
And you know it was this amazing culture
of really believing we
could change the world.
We were learning the skills
that were gonna impact people
all over the world.
And 'cause we're software engineers.
Like the things we do have
a direct impact on mankind.
So I graduated college with
all of my idealism and ambition
and I got what was at
the time my dream job.
And that was a job at NASA
in the robotics laboratory.
So I was working in
the robotics laboratory
on actually the motors.
This is Robonaut, which is a robot.
And I was working in the lab on the motors
that control the fingers.
This was like a really
exciting, fun place to be.
Very research focused.
But, you know there was this disconnect
between what I thought I
would be doing as an engineer
and what I was actually doing
at a very large organization.
And so one of the reasons I
really got into engineering
was that scene in Apollo
13, the Tom Hanks movie.
There's this scene where the guys are up
you know, about to die
and they get the engineers in a room
and they're like, you have
to make this square peg
fit into this round hole
with this duct tape.
Whatever it is, I don't
remember the detail.
But it was something like that.
Like you have this time
constrained, really exciting thing,
and it's gonna directly impact the future.
And so that's the kind of thing
I thought I'd be doing as an engineer.
Like solving problems
and publishing that stuff
and putting that stuff out in the world.
And the thing about working
for a very large organization
was I was unprepared for
the level of bureaucracy.
And to be fair I was
there at a very bad time
because Columbia had
crashed within a few years.
So there was just a lot of meetings.
Lots and lots of meetings.
And decision making was very slow.
And it felt like as someone
who wanted to build
something and was excited
it felt very challenging to
really make any progress.
Because you'd do something,
you'd have a great idea
and you'd have to have five meetings
you know, to even get an
okay, you can try doing that.
So my enthusiasm and my idealism
just kind of dimmed a little
bit during my time there.
So let's fast forward to
today, 15 years later.
I'm sure like many of
you, my career has taken
many twists and many turns.
But now I'm a consultant, as I mentioned.
And to me, I'm living my dream again.
So my life has changed
and I have been able to find this career
as a Rails developer that
really fits well into my life.
I'm doing something I love.
I get to do it on my own time
in a remote, flexible environment.
It's great!
But I noticed like about a year ago maybe
I was really having a hard time
tapping into that energy
I had when I was 22.
And you know, maybe
it's 'cause I'm not 22.
But I'd like to believe that
that's not the only reason.
You know life is different
now and it's busier
and I have children.
But man I was just kind
of feeling blah at work.
And I missed that kind of
like idealism, that energy
to really do something.
Like hopefully at some point
in your career or your life
you have been able to tap into that energy
of the possibility of change.
And I just wasn't feeling it.
And I was really missing it.
And I think part of it might just be
the daily monotony a little bit of work.
And the frustration of meetings,
like the annoyance of tech debt.
Or you know, bad code, boring
work and everything else
we have to do sometimes.
You know, they call it work
for a reason, as engineers.
So that got me thinking,
why are so many software
engineers dealing with burnout?
And this is not a talk about burnout.
But I think this is kind of relevant
to our discussion today.
So almost everyone I know in this field
after they've been in
it for a couple years
has dealt with some kind of burnout.
And it appears in different forms
but ultimately I think one of the problems
is a lack of enthusiasm.
Like a lack of creativity
and this lack of ability
to just do something for fun.
In our field we have all of
this pressure to work all day
and then to have a side
project that we monetize
and to have a blog, and
to have a YouTube channel
or whatever it is.
I feel like there's a lot
of pressure in our industry
to work beyond like kind
of a normal working day.
And you know so I do
think some of that stress
is self-created, but it is what it is.
So I was trying to think of a fun way
to fight that and to rekindle that energy.
So I decided that I wanted to
just create something for fun.
No other reason, I'm not gonna sell it,
I'm not gonna do YouTube tutorials on it.
Like it's just gonna be something fun.
Like remember how to have fun?
And so I threw it out to my
kids, I have three children.
They're three, six and eight.
And my eight year old
has shown a real interest
in robotics and programming.
So I threw it out to my children
and my son was like,
hey let's build a robot!
And I was like sure!
Let's first get an LED blinking,
then we'll talk about building a robot!
But the cool thing about children,
if you have children you know this,
if you know children, you know this,
they have this like, sense
of nothing is impossible.
They just create things to create them.
Without feeling the
judgment we as adults feel.
They just build things, they
color things, they're terrible.
They don't care.
They just put it out in the world.
And like that lack of fear of failure
is so inspiring to me.
So we decided we were going
to first get an LED blinking.
But eventually work up to a robot.
And so that sounded like
a really fun idea to me.
I wanted to build it with a Pi.
There are lots of amazing
robotics kits out there.
They're pretty expensive, some of them.
And I'm kind of cheap.
So I was like, mmm, I don't
know if I want to do that.
And I was really looking for like
I didn't want someone
to tell me what to do.
I really wanted to just
do it however I wanted.
And so that's kind of why
we decided not to use a kit.
Course there's nothing wrong with kits,
but that's the approach we took.
So if you want to get
started with a Raspberry Pi
this talk is going to give
you kind of a step by step
guide to getting started
with the Pi on Ruby.
So here's some practical considerations.
I think when you're first starting
you don't even know where to start.
Like you don't even know what you need.
So you're gonna need a Raspberry Pi.
You can purchase those as a kit.
Or you can just purchase
them without a kit.
I have to say, like I bought
one of the really starter kits
and it came with a switch.
Which you can't really
see, but it has a switch
on the power supply.
And that's really nice because
if you're working with kids
it's better than having them
unplug it and plug it in
and you know electrocuting themselves.
So if you're gonna work with kids
I highly recommend the five dollar switch.
You're gonna need an SD card.
You're gonna need various
jumper wires and things
they look like this.
You can see, you can come see after.
But like various jumper
wires, resistors, LEDs.
Alligator to pin clips.
And then the stepper motors
so if you wanna make something
that moves, stepper motors.
And then some breadboards.
And so you can buy all that
stuff in a kit from Adafruit.
You can go to your local electronic store,
however you want to assemble
your things is fine.
But this is a pretty good place to start.
And so the step one, if
you wanna get started
is you gotta flash your
SD card with Raspbian.
If you are scared to flash your SD card
you can actually buy the SD
cards with something called
noobs, N-O-O-B-S, so it's
pre-loaded on the card.
Or like I said, just buy an SD card
you can flash it with Raspbian,
which is the OS for the Raspberry Pi.
Then once you've done that
you've gotta actually install
Ruby on your Raspberry Pi.
It comes pre, several
things come pre-loaded,
one of them being Python.
But Ruby does not.
But it's just a computer.
Like sometimes you forget, you're like,
it's just a computer.
So it's just the way you would install it
on your own computer.
And then I put this up here
don't get distracted
by how cool Scratch is.
If you have children,
Scratch is like a visual
programming language.
And so we got this all set up
and I'm all excited to get
to the electronics portion.
And my kids found Scratch and
that's all they wanted to do
was play with that.
So that is really cool, highly recommend.
But, you know we were trying
to focus a little more on Ruby.
So this is what the download
page looks like for Raspbian
to flash your SD card.
All right, so step two, once
you've purchased your stuff
you've flashed your SD card,
step two would be, as
I said, to install Ruby
and make sure Ruby is working.
And so this was like the
first four loop we did.
The first loop we did I put
all my kids' names in it
and just ran it forever.
And they thought that was really cool.
And so I think they kind of started to see
like there's this relationship between
what I type in the computer
and what it spits back out to me.
So let's talk a little bit
about what we're gonna do next.
So we are gonna use electronics
and I'm gonna give you a
brief intro to electronics
just in case it's been a while
or you've never learned it.
So electronics, current
flows in one direction.
It flows from higher potential,
the plus means higher potential,
to lower potential.
And a circuit is, you
know you have to connect
all of the conductive pieces
so the electricity can flow.
So this
would be a short circuit.
And that's bad.
So if you connect, as you can see here,
now your battery,
it's like how you're
not supposed to connect
the batter terminals to each other,
right 'cause it'll melt your battery.
So that's short circuit.
So when you're working with circuitry
you kind of wanna make
sure you always have
something in line in your circuit
so you don't accidentally
create a short circuit
and a mini fire.
So breadboard, so what is a breadboard?
I have my one breadboard hooked up here.
Kind of looks like that.
I'll show you on the next slide.
So breadboards, so
they're called breadboards
'cause before we had physical breadboards
people used to take wooden breadboards
that looked like that, and
like tape their circuits down
to create circuits.
So that's where the name comes form.
But in electronics, this
is what it looks like.
It's called a solderless breadboard.
And it's called a solderless breadboard
because the connections are
made with out soldering.
And the way these work
is you have a power rail
which is this red rail right here, red!
And you have a ground rail,
which is this blue rail.
And as you can see, so this
picture is what you see
from the front.
And if you took the back
off of your breadboard,
this is what you would see.
And these are electrical connections.
So you have power which goes this way.
Ground which goes this way.
And then you have all of
your other connections
which are going this way.
And that is really nice 'cause that way
you can take your Pi, you
can plug power in here
and then you have that power available
anywhere on that rail to
work with your circuit.
So that's a breadboard.
Let's talk a little bit about LEDs.
I'm sure you're familiar
with the term LED.
LED stands for Light Emitting Diode.
And the reason I told you
which way a current can flow
is because in an LED current
can only flow in one direction.
So current flows from plus to minus,
the way the arrow is pointing.
That's the way current flows.
So the positive terminal
is called the anode
and the negative terminal
is called the cathode.
And for the LED to work properly
you have to put it in the right way.
If you put it in the wrong
way, don't worry about it,
just flip it around.
It's not gonna explode or anything.
But if it's not working,
try flipping it around.
So there's one thing that's missing
if we're gonna hook up an LED
there's still one thing
that's missing in our circuit.
And that's a resistor.
And so a resistor is a device
that resists the flow of current.
So practically, what does that mean?
Basically you are using your resistor
to control the current in your circuit.
And that's important
'cause devices have certain
current ratings that they
should not be exceeding.
So this is Ohm's Law.
And voltage equals
current times resistance.
So that is actually how you can go about
calculating the size of your resistor.
Here's an example of the circuit
we're gonna be creating, which is this.
Which is our current limiting resistor.
Our LED, and our power source.
It's important to know in the Pi,
that you can get 3.3 or five volts.
So just be aware of which pin you're using
'cause some are five and some are 3.3.
So this is how you calculate
the value of the resistor.
And this is like if you're
interested in circuits and math.
If you're not interested
don't worry about it.
It's not that important.
But the way this works is
you have your source voltage
which is VS, which is coming
from your Raspberry Pi.
You have your forward
voltage over your LED.
So you subtract that
and then you divide by
what you want your forward current to be.
Now how do you know what you want
your forward current to be?
You know because your LED is
rated for a specific current.
So the truth is, it doesn't really matter.
Just grab a resistor.
If it starts smoking, like
you've picked the wrong one
and grab another one.
That's how we do it practically.
So that's kind of my brief introductions
to circuitry and circuits.
This is what the Raspberry Pi
pin out actually looks like.
And the way we identify pins is
we go across and down.
So it looks like this.
One, two, three, four, five,
six, seven, eight, nine
all the way down the board.
And there are two different
ways to identify pin outs.
I mean this is the way
I learned 15 years ago
so this is the way I'm gonna do it.
So that's how you know what
pin provides what voltage
and whether it's an input pin or not.
So now that we know all about circuits
and we have kind of an
idea of how to hook it up.
Let's go back to our circuit
diagram one more time.
So we're gonna hook our LED up in series.
This is called series
because they're right next to each other
with our resistor and power supply.
So to do this, if we just did this,
that would turn on our LED.
We want to blink our LED.
So to blink our LED we have to control
something else in the circuit.
And what we're gonna control
is we're gonna control
this voltage right here.
And the way we're gonna do that
is to use something called the GPIO pins.
So if we go back to our pin out,
you can see there are several of these
that are labeled GPIO, GPIO, GPIO.
That stands for general
purpose input output.
That means the pins can be
used for input or output.
And those pins are tied
to the 3.3 volt rail
so when they provide output
they will provide 3.3 volts.
So we're gonna blink an LED.
So this is kind of what
your circuit looks like
and I have it set up here,
I know you can't see it,
but you can take a look
after the talk if you like.
But you're completing your circuit
and in this diagram it's
ground to your resistor
to your LED to a GPIO.
So you can see that this is ground.
And this is the GPIO we're gonna control.
So by switching that GPIO high and low
we're gonna provide power to our LED
then we're gonna turn it off
then we're gonna provide power.
And that will make our LED blink.
So to control a GPIO, I used
a Ruby library called RPIGPIO.
And like an aside if you've used the Pi
you've probably used Python on the Pi.
Python comes preloaded, very popular,
and Python has a lot of libraries
that kind of abstract all of this.
They probably have like
a blink LED library.
Like they just abstract all of this away.
So I really think there's a fun benefit
to learning how to control
the GPIOs on your own.
'Cause you can really
understand the circuitry
and really understand what it's doing.
But it is a little bit more work.
So this is the, oh you
can't see that so well.
Sorry about the red.
This is the code I wrote.
And basically with this
particular library,
and there are other libraries,
you have to set the numbering.
So as I said, we're gonna
go with the board numbering
which is kind of the more
traditional numbering scheme.
So I just set up pin 12 as
output, initialized it low.
And then I set it high,
sleep, set it low, sleep,
and it blinks.
So hopefully you've made it that far
and you're still interested,
you're still having fun with circuits.
And you're blinking an LED, yay!
So let's talk about the second project.
And like I said, I do have these projects
set up so you can always
take a look after the talk.
All right, so let's talk about project two
which was a whoopie
cushion, which is this.
It's connected to my Pi right now,
but I'll try to hold it up.
This is beautiful device
is my whoopie cushion.
And this was fun 'cause this was really,
the LED, like, eh, the kids
weren't too excited about that.
But the whoopie cushion,
everyone was excited about.
And if you look at this,
as I show you how I made it
you'll see that it's really
just a really big button.
So what you need, two paper plates.
I recommend Chinet, so
they expand a little better
and they don't just fall in on each other
and keep your button
pressed the whole time.
Alligator clips, aluminum
foil, that's what we used
for our conductive
surface is aluminum foil.
So if I take this apart, you'll see
it has aluminum foil in the middle.
And then you can put
sponges around the rim here
to give it more bounce.
We tried that and we didn't really find it
to be too effective.
So you're gonna connect one LED,
so as you see I have conductive
surface, conductive surface
and then you can see
there's a conductive surface
coming out right here.
Conductive surface, so
when you put it together,
don't put the conductive
surfaces going out together.
That won't work.
You have to put the conductive
surfaces not touching.
And then you hook up alligator clips
and it just makes like
a really big button.
And so when someone sits
on it or you depress it,
your two surfaces are gonna touch
and you're gonna close the circuit.
And this is the code I used.
I have a folder now called farts.
(audience laughing)
So set up pin 18 as input, I pulled it up.
So there's two ways to do it.
You can start with it
low and pull it high.
Or you can start with
it high and pull it low.
So it was just 'cause I was doing this
all on the same Pi, so
those were the only pins
I had available.
So you can just pull it up
and then you have your farts.
And then, you know when the pin goes low
you play a fart sound.
So this was really fun.
One of the things that's interesting here
that sometimes I think as
software developers we forget
is you have to wait.
'Cause you're responding
to a physical event.
It's not what we're used to.
When I first coded this up, I
didn't have any sleep in there
and it was not syncing up properly
and I couldn't figure
it out, took a while.
But you have to remember,
hardware's slower than we're used to.
So you gotta keep that in
mind as you're making it.
And hopefully this,
that's hard to hear.
Ah well, it makes a good fart sound.
(audience laughing)
So that was a very popular
project at my house.
All right, so I'd like to talk to you
about the third project we worked on.
So if you were doing this with
children or even yourself,
let's talk about managing expectations.
Because kids these days have
like robots at their house.
They have robots at their school.
We went to the library and
our library has this robot
just like 'cause they're awesome.
And you get an iPad and you
just move your finger around
and the robot follows your finger.
It's amazing!
So we go and my son's
like, can we build that?
I was like, not today!
Maybe someday.
But I think one of the cool
things about this project
it really gave my kids some perspective on
things are hard.
You know, these robots are built
by teams and team of people.
So you know, it's interesting
what you can do at home.
So I would just recommend
managing expectations
when you go into that.
Ours will pale a little bit in comparison
to what your children might
be used to seeing at school.
So robot, you gotta be able to move.
So the biggest thing
with movement is motors.
So I used a stepper motor.
Stepper motors are a little bit different
than what you think of as
your traditional DC motors.
'Cause you can program them
to move in tiny increments.
And the reason we chose
to use the stepper motor
is because they were six dollars
and I really didn't know
how this was gonna turn out
when we started this.
So they're super cheap.
They come with their own driver board.
So that's the driver board and
they come packaged together.
And it gives you really precise control.
And I didn't know, had no idea
what we were gonna be doing
for the physical, yet.
So I didn't know if we'd have an axle
connecting the two wheels.
So I thought it was important
to get precise control
so our robot wasn't going off
in all different directions.
So that's why I used a stepper motor.
And I want to talk to you a
little bit about stepping.
So motors, brief, brief
description of motors.
They have a magnetic core.
And then you are sending
an electric current
through a coil.
And when you send an electric
current through a coil
you create a magnetic field.
That's what causes motors to turn.
So if you look at this
this animation, which unfortunately
isn't working at the moment.
There we go, so if you
look at this animation
you can see in this animation,
how a coil is exercised,
okay I don't know why we call it exercised
but we called it exercised
when you send a current through ti.
A coil is exercised, it
creates a magnetic field
and that, your permanent
magnet in the middle turns,
'cause magnets are attracted.
And if you look over
here, you can actually see
the stepping sequence.
This is called half stepping.
There's a few different
ways to do your stepping.
But basically in half stepping,
you turn one on and then you turn two on
and then you turn one on,
see if I can get it to play again, oops.
And then you turn one
on, and you turn two on.
So if you look over here, you can see
high, low, low, low, and then
you high, high, low, low.
So you can kind of see the
pattern if you look over here
of how to do half stepping.
And so what that pattern
actually looks like,
oh, now it's gonna play again.
Okay we can watch it again.
Red means it's on, so now you have two on,
now you have A prime on,
now you have A prime on and B prime on.
B prime on, B prime and A on.
Okay so this is what that
sequence actually looks like.
If you were to put it in an array.
So just like we just saw
in the physical diagram
in the last slide,
it's one, one, one, zero, one, zero, zero
then two on, then this
one on, then these two on.
And you just go in that sequence
and that is gonna cause
your stepper motor to turn.
And each of these four values correspond
to a specific pin on your stepper motor.
That's important.
So your stepper motor when you connect it
it has four pins.
And each of these is gonna
correspond to a specific pin.
So let's look at how this works.
So my suggestion when you
get this up and running
is to first try to get one motor spinning.
And then once you have one motor spinning
you can try to get two motors spinning.
So here's what an initialized
method might look like
for two motors.
So what we have here is I have control pin
and control pin two
because I have two motors.
And these are just GPIO pins
that we were talking about earlier.
These are GPIO pins and we
have eight of them total
because we have four per motor.
And we're just gonna set
those pins up as output pins
initialized low.
And they need to be output
because we are driving
the motors from the Pi.
So if you think of the way
like you're kind of sending.
You're coming from the Pi to your motor.
So you're gonna set them up,
you're gonna initialize them low.
Okay, so two motors, four pins.
So what we're looking at here is we have
for pin zero to three, set pin.
So here's kind of like some
pseudo code for set pin.
And this basically is gonna
take a pin and a value
and set the pin to the value.
And as I said we have four pins
and as you see we have half step
oh yeah, here's a reminder of our sequence
of what our sequence looked like,
what our sequence array looked like.
And here's our half step
sequence again and there's eight.
So if you look back at this you can see
we're doing four half step, zero to seven,
four pin in zero to three.
And we're gonna set
each one of those pins.
And to sleep.
Again with the sleeping,
you don't want to forget the sleeping.
'Cause we are moving a physical device
so we have to wait a little bit of time
to make sure the physical device can move.
Okay so here is what go
forward looks like for me.
And to make one complete revolution
I have to go 512 steps with half stepping.
And that is gonna be
determined based on your motor.
And that will be specked in your motor
so you should be able to
find that information.
And so this is my go forward method.
We go zero to 511 and
then we do our half steps
and then we set each pin
as we go through the loop.
All right so,
so now we have, like if
you think of where we are
we have motors that are
spinning, which is cool.
And we're trying to figure
out how to put this in
a physical device.
And at first we started with Legos
and I'm sure there's a great
way to do it with Legos
but I wanted to glue the
stepper motors to the Legos
and my son was not having that.
So there was no gluing of Legos.
So the Legos didn't really
work 'cause I was having
trouble figuring out how
to get the stepper motor
attached to the Legos.
But we discovered Thingiverse
and this is a super technical crowd
so probably half of you
have your own 3D printers
which is pretty awesome.
We do not.
I have never used a 3D printer in my life.
And I discovered
Thingiverse and it turns out
my local library has a 3D printer.
So we got a design, and we
didn't design this ourselves.
That's like step two of our process.
I'd love to learn how to do it,
but we did not have time for that.
So we got a design and we
printed it at the library
for three dollars, it was amazing!
So that was really, really
exciting for everyone.
And this is our robot, as you can see.
Right here.
And we hope this will play.
Get ready, this is very overwhelming.
Look how fast it goes!
(laughing)
And you'll notice, this is kind of funny
because you'll notice I
still have it plugged in.
So I was running it off
of this battery pack here.
But it just, I mean it was
just destroying the battery
and it's an old battery pack
and I probably should've
sprung for a new one.
So, you know, it's not exactly
an overwhelming amazing experience,
but we built something
ourselves that moved.
And we were really excited.
And the kids were really excited
and it just kind of just felt fun.
So I think that's really cool.
And I hope you learned a
little bit about electronics.
And a little bit about
about the Raspberry Pi.
But like my goal was not
necessarilly to teach you
how to build a robot.
Although I'd love to talk about that.
My goal of this talk
was just to remind you
how to have fun.
And remind you that our heart
most of us are creators.
And sometimes throughout
the course of our lives
and our days and our
adult responsibilities
we forget to have fun
and just create things.
So if you're looking for a fun project
the Raspberry Pi is a really great device
to get you up and started
cheaply and quickly.
And you can create new things!
Thank you very much!
(applause)
(upbeat music)
