Press "Enter" to skip to content

Trying Particle Photon for the first time (Live Mob Programming)


good Monday morning today we are going
to be live coding a life pair
programming like more programming app
chat fixes errors force a particle
photon so that is what you are seeing oh
god no no that is too large that is what
you are seeing down here and in the
lower right corner it’s it’s it’s it’s a
little or do you know like or do you
know compatible device it’s Wi-Fi
connected you can buy one at particle I
oh I really like these people and this
is not a sponsored video is just like
them I’ve used them a couple of years
before and that’s why I have it on the
show and yeah that’s what we’re gonna
play around with today
so you’re seeing this on my desk here
once this is how it looks like this in
size comparison with a banana and David
is going to be the driver that is going
to be programming it so he’s actually
going to deploy code to the cloud which
is then synced down to this thing it’s
pretty amazing this and it’s streaming
setup is it’s so bizarre I’m super
excited about this I’ve no idea if this
is gonna work
so yeah let’s let’s get going I am mpj
and this is David and you are watching
[Music]
okay so this is what is this it’s some
kind of thing that can do what yeah and
what what is part of the particle thing
development it’s for the intent of
things by the Y program okay yeah so you
can go to the particle store they’re
actually yep going and you can see there
is a if you scroll down this should be
unlike an Internet button that is what
we that is on my desk does it do they
even sell it anymore yeah there is an
internal button so this is basically it
has a like a bunch of LEDs around the
edge so you see like I like the code
that is running now it’s just blinking
one of them all right in blue and it
also has four buttons on the on the
bottom here like push buttons so like we
can actually like press here and here
and and here and that will register like
we can listen to those god your
resolution keeps changing what the and
why is it I don’t know why it’s like I
think that you had that same problem
with me and like the live stream as well
really wonky perhaps it’s because we’re
doing both the screen share and no I
don’t think so like we had the same
problem yesterday mm-hmm all right well
it’s not a problem I see it immediately
when it happens so it’s it’s fine okay
so yeah so we have that and what but you
are over there and I’m over here okay
so that’s a problem sort of it’s not
connected to my computer its computer is
that exactly it’s actually not even
connected to my computer
oh it’s connected through the cloud so
you you program these through the cloud
which is very handy because you can like
these can be you can also buy this with
cellular collection so
[Music]
you can for instance like deploy them
just anywhere and have them like
connected to the Internet and then
program run remotely and firmware update
them and stuff if you like for instance
put it on there I know that I have a
couple of friends that use this to
create a little boat that we’re drying
up driving around and the archipelago
was Stockholm mm-hmm and they code it
like live code and that while it was out
at sea yeah that sounds cool and I guess
these are the types of devices that are
being used for like D doses and that
stuff like the attacks these they are
being hacked and then they are using to
like spam servers yeah let’s not do that
okay
so we have that the thing yeah I mean so
yeah so let’s just play around a little
bit with it let’s that’s the screw run
with it
like if you just go to the particle
console yeah there should be a web IDE
here I think that’s the bottom-left
option yeah see if this works
yeah and on the left side here you see
like there’s a current tab there’s some
files as my apps and there’s an app that
only see it I only see the blink and led
it’s not about it’s it’s about that one
there what we see here is that we are
pulling in
the internet button library Oh would
even mmm
what even happen well as soon as I focus
it to remove that sidebar dinging oh
okay
I’m fixing all right cool okay okay okay
I will fix back they all right sorry
screams yeah this is stream biscuit asks
like sorry if you mentioned but it’s
this Java we have no idea what
this is this is a particle thing I think
it’s some is it perhaps and see I would
say that it perhaps see I’m not sure
okay yes
so we have the including that button
here yeah and then we instantiate an
internet button on line seven and then
there is a function called set up which
is ran it’s executed when when the
device starts I suppose I want when the
program starts and then you see here
like there’s a function called loop
yeah biscuit says like he just checked
it’s it’s it seems plus plus and more
Zuber says that like it’s definitely not
C sharp as it doesn’t use C C sharp
doesn’t use header files and Daniel
garden says it’s a fork of C++ created
for Arduino so that’s what we’re looking
at so there’s a func air like a function
here called the you call a method on the
on the button called lead on and I think
that the first argument there is like
the the the like the position of the
lead because there’s 12 around the
muffin so we can actually just go ahead
can I just can I have mold now we’ll
just another letter right yeah sure six
and twelve
perhaps yeah or size zero they’re a good
question I would imagine that it begins
and then we turn it off like that ya
have to have semicolons I guess okay
where do i click now huh yeah I think
you click like the check mark in the
upper left corner I think that verifies
the code no yeah I think yeah yeah I
think you need to you have one in one
argument too little online hey welcome
to the first name yep all right
so did that work and if I just had
checked chat they would have to put me
before I click it probably so okay yeah
it’s ready yeah dr. Robert Vinick as put
that little I lion icon on your chrome
ills like because this is not chrome
right this is brown this is the brave
browser it has like me in ad blockers
and some kind of the thing of giving
people money I don’t know if that works
yo it does
wait we actually get some money from it
yeah so it’s sort of like the platter
idea that buy through usage or like you
can just in put money into brave somehow
and then it will get dispersed to people
having websites and channels and stuff
yeah yeah yeah and el macho I says that
oh with the old Pomodoro button yeah
thank you for remembering that video
I’ve used to develop this in a video
before on the channel okay so how can i
deploy it yeah it’s button above the
verifier can the the lightning one so
actually yeah so I think that we should
just see things starting to happening
when the with my device here hopefully
yes there we go
why not or no nothing changed
so perhaps zero is not a valid valid
let’s do one one speech they are verify
drug on me
welcome to the stream welcome Hume and
I’m a flashing it’s deploying yeah J&F
smile says isn’t the first argument ID
of led yeah I think so
I think so but perhaps the ID start set
yeah it starts it at look works oh yeah
cool
that’s really cool so then what to do
with this Yotam yeah so uh I I have an
this I mean you could we can do anything
you want but like just to get you you
started like I have this I have this
thing then I would like to exist I guess
you’ve seen Simone yeah thing the the
calendar I will assume that Simone Yauch
yeah that one and you have to scrub a
little bit in this video to find the
actual calendar yeah this is the one so
on up on and off lights yeah so it’s
basically like check thing where you
every time you meditate or whatever
habit that you want to do like burpees
in the morning or flossing or whatever
you press a button on the calendar and
it lights up it’s kind of a cool idea
but I don’t like it doesn’t quite
reflect how I build habits and looking
at research like this is very hell bent
on you doing something every single day
which isn’t actually how how habits or
built like you don’t have to do things
every every day for for habit to lock in
and it’s this is just from there I know
that this comes from Jerry Seinfeld of
like do not break the chain but I don’t
like these things because it becomes so
incredibly remote demotivating if you
miss one day because you’re gonna have
like this broken streak in that thing
that looks really good where like the
way she displays it but that’s not how
how your habits is going to look like
you’re gonna have bad days where you you
don’t care and then it’s gonna look bad
so what I want is instead like imagine
like a little sculpture like something
in glass like I don’t know what the
premium brand for glass sculptures in
your country is but in Sweden is Costa
Buddha imagine one of these and then
there is like light from below that
lights the sculpture in different colors
mm-hmm
and you can touch the sculpture as an
input so when you touch the sculpture
the sculpture like makes a little
rewarding sound or something and it goes
green and you can touch this like every
every morning
and if you do this three days in a row
and it turns blue until you until you
miss a day and then it goes green again
and then you have to go go three and if
you if you miss a day that’s fine it’s
still gonna be green but if you miss two
days it’s gonna turn yellow if you miss
three days it’s gonna turn red and if
you miss a fourth day then your streak
is broken and you’ve lost it okay so
it’s cuz I would this work if we were to
do that like the first thing that I mean
the first thing to do I guess is to make
it turn all green yes so by clicking a
button it turns green yeah or is like
just make it green the first thing I
guess our G B okay let’s just turn it it
yeah we’ll just be on let on how many
should we just said like how it’s the
procrastination thing going along oh
it’s already been writing for loops in
it’s just that you have to declare the
type I think int I equals 1 do you what
you do it like this yeah but you have to
yeah say so but like you’re doing it in
wrong order though that’s not how you
write a for loop you need to like the
the check is in the middle and then the
3v3 what’s what’s even the name I don’t
know how to read twitch okay what they
are so cold
does this sound plausible well he’s oh
yeah yeah I think so hey Perry a
that’s really and this is how we always
run things we just deploy them and see
if it works yeah because then we have to
wait and waiting is fun because then we
can speak with chat hawkeye wants a min
lead and max LED variable ah will do we
do it when we need it yeah we actually
do need it I think next so it works yeah
awesome progress yeah because yeah we
don’t need it yet can we like remove all
of these comments yeah okay let’s start
procrastinating by doing things that
aren’t really necessary hey stream is
about removing comments sorry for all
the young ones out there removed all
comments from so we’re telling you to
always remove comments remember that
kids disagreement says isn’t removing
magic numbers value enough reason to use
min and Max variables the thing is like
yes if if we were at a later stage but
the problem is that we we might like if
we start refactoring and improving the
code we might mutt and then end up like
throwing the code away as we are working
further than we have just made
unnecessary work it’s better to wait
with like tidying things up once the
code has stopped mutating
yeah I will do some middle ground here I
will just comment and explain what’s
going on here so then we don’t have to
do they’re LED mean let max okay so now
I have then we improve a like increase
the font size a little bit oops
it’s – yeah I try that but this is brave
oh it’s out there is short cut for zoom
instead of plus okay so this perhaps oh
that’s oh this is a lot better jnf
smiled says bike shedding yep that’s we
could call the stream that just bike
shedding yeah the bike shed hope Homer a
skips is a pure C or R do you see it’s
are doing is arguing you see all right
so let’s figure out how to do this how
can we interact I would like it yeah
okay so what I do you know what I want
yeah no I don’t so when we when we turn
it on yeah we need to have some kind of
timer that counts though it turns off
after a while
good question like we would have to
perhaps like do a time when you when you
press the button and then like just
check in the loop if that time like if
we are like five seconds past that time
you can also delay it as Daniel Gordon
suggests yeah so okay so here’s what I’m
thinking if I understood your goal like
you have the end goal you want to have
like these different colors like you
have any like refill the bucket sort of
yeah so we should probably have some
kind of bucket that is like counting
down and then the let the LEDs reflect
the status of the bucket that’s what I’m
thinking
yeah because if we were just delaying
then it’s just we can’t refill it
because I’m gonna have to yeah the delay
it just makes it that it can’t receive
new input yeah so okay
what I want is can we somehow turn it on
and turn it off how can we interact with
the bottom yeah let’s find out we need
some googling to do that I don’t know
how to do that honestly so it’s
particle-particle internet button api in
linked and led yeah this was example
being all LEDs oh the whole LEDs on okay
Oh awesome you do that instead but we’re
not gonna get stopped ah yes the bottom
when you click the second button oh it’s
you do an ape statement then you check
if button is on yeah yeah oh yeah this
is cool yeah so it’s not an event-driven
it’s everything happens in a loop
yeah this is so unlike jarring when
you’re a JavaScript developer but it’s
like very common for in c and game
programming so let’s set state here yeah
they can point say that like we need a
local state that gets preserved between
loops yeah yeah exactly so state it’s
turned off yeah if you try button B
state is turned on oops semicolons I
okay so if bottom 1/5 state equals zero
then turn it on otherwise you’ll get
nice away but let’s just make it like
the state is on then we should turn them
turn them on yep cool okay yeah so this
is just the first first draft of code
we’re not refactoring it we’ll just see
if this works
yep yeah Alice right so when it showed
to turn off now when it’s uploaded
because if we set the state to zero up
here and then you have to press the
number two button to change the state
yes
all right so it’s flashing why that if
inside if well it’s because we’re
toggling the state so we have to set so
if the state is off when we turn on the
button it should turn on if it was off
otherwise we should turn it off if it
was on but here’s can you try it yeah
let’s do it okay so I wonder which
button is – perhaps this one no no this
one cool but it doesn’t turn off which
else okay I would do there be lead fall
off there is it we have one of those be
let off 3m lets off the I’m refactoring
here sorry all let’s on okay
somebody suggested that we should write
the goal down I think it like we should
at some point have a place where we
write down or write down the goals
dynamically I’m gonna write this in with
stream ideas and feedback somewhere
where we constantly keep yeah that was a
good idea
uber groups just like switch the states
oh no oh hello we lost the call for some
reason alright so where were we
so what I did was I refactor some code
so we changed here so that if we press
the B button the the second button we
just set the state to the other two like
the inverse of the current state so it’s
just idling it oh well it we can just
write here toggle state yeah and this is
deployed to the button now so I should
be able to press it right yeah I think
doesn’t quite work hmm why doesn’t it
work chat
perhaps this in your old check here’s a
hint though if I if I press it and if I
hold down now like it just flashes so
it’s a little I think it’s a little
random I think as oh okay each iteration
in the loop is touching the state so
super fast toggling between the states
and if we’re lucky it ends up on one of
them oh so that’s what’s happening so
how do we solve this deep bounce right
yeah yeah is there any bounce here yeah
I think that now the the bounce doesn’t
work in unknown functional context okay
but if we just delay then we can sort of
expect you to having released the button
yeah is that a nice hack people so just
delay 500 milliseconds yeah makes sense
yeah I would like to do bounce but delay
we lock the CPU
I’m sure it would let’s just try this
yeah like some kind of offset thing
where we like keep tabs on when things
were pressed and then like shake in a
statement but that’s a more complicated
solution than delay and again like if we
decide to do this then we can refactor
to that better solution but at this
point we’re just like playing around
with things so like it doesn’t make
yet Oh like really live yeah 3v1
cow what but is that even even cow
even if evil cow you will cow oh I can
read bleat speak now evil cow says you
can could have a worse button press flag
and reset it when the bus button isn’t
pressed that’s a pretty simple solution
actually okay so let’s check this is
both components the state yeah this
doesn’t quite work okay so yeah
navigator help well it sort of works it
sort of works if if I wait yeah but that
sucks I want it to work well if I hold
like it well if I keep holding its
toggles yes same thing I actually think
that evil cow Ivica has a great solution
they’re having a was button pressed
boolean okay I added that and what do I
do with it
[Music]
good question hang on so if the button
is pressed it says it it sets that data
true and one if I’m pressing them if the
yeah and uh and then if if the button
no don’t sit to see it not pop don’t set
it to see a flop okay
oh yeah no hang on like I’m trying to
like I’m trying to understand somebody
else’s solution but like it it’s only
half made like it don’t quite if there
is a button off if so just check that
yeah that’s a good let’s just see if
okay so let’s let’s think this through
okay yeah let’s skip this yeah that’s
it’s just boom yeah let’s just be calm
here and think we when the button is
would probably like can we just do this
with timing mm-hmm like keeping tabs on
when the button was pressed in like the
millisecond time yeah sure so we need do
so with then does this have like some
kind of time in itself or do we should I
just increment like it’s at a timer and
just say I assumed that it would be at
Davo bird says only change the led state
if the button was pressed and put a
little a after you change the lead state
well we want to avoid delay there are
many suggestions here in chat yeah and
it’s kind of like I think that the
several of them are probably correct but
it’s just like I’m just getting
overwhelmed with the possible solutions
it’s that joe says initialized time and
set up hawkeye says you’re overthinking
it it’s just assignment and checking if
button was pressed this is like I
remember like this is an interesting
thing like I remember this from my
coding interview training like it’s some
your brain just kind of breaks down and
produces like no solutions for you is
kind of like panic so let’s just calm
down figure out so can we just get rid
of these states and what’s button
pressed and and stuff because it’s just
okay let’s just remove everything yeah
all this LEDs are on yeah now everything
so what is it that we want to do like
just like for me it sometimes helps with
just writing it in English yep button is
pressed on the LEDs you know all right
fine so what is the problem we’re like
and that that works the problem with
that is that we don’t have a way of
turning off the let’s yes so how do we
solve that we want to be able to toggle
this so again like if we when we press
the button we want to like toggle the
state to be another state
however we only want to change that once
we are like I think that isn’t the
problem here that if we were doing this
in JavaScript I would be using key up
hmm because the problem here is that we
only have like a key down event yeah so
is there any way for us to yeah so if
right so we’re checking I think that we
should set a variable like button was
pressed and then like button yeah
and when the buttons button is pressed
we set button is pressed and that and
then when we first detect that the
button is no longer being pressed then
we switch this date okay I sort of
started thinking how what was this call
again if B dot bottom pressed
yep – exactly now we set the like a
little variable to keep tabs on that
yeah we have at some point press the
button and that is being set to 1 while
we’re pressing it yeah exactly and now
we also detect so if if the inverse is
true like the else here yeah
now we see here like oh now the button
has released yeah so now we checked if
the button was we don’t know if it’s
been released we only know that button
is not pressed sorry father
Hawkeye says bingo we got it that was so
interesting like it’s so fascinating
like this is a super simple problem but
I just couldn’t figure it out it’s also
it’s also way more difficult when you
feel that there are many people watching
you and you want to perform yep yes
exactly
132 people yes getting used
I understand why people check like
there’s a feature in twitch to hide the
number of viewers and I kind of
understand why people wanted that
feature thank you for not just watching
[Laughter]
all right so so should we just move the
LEDs into here and not you and just skip
the state we can let’s try that and we
also need to turn off the like reset the
button was pressed but perhaps that’s
jumping ahead of us like yes let’s
deploy this thing and see where we’re at
yeah so now it will probably it will be
shut off first and then oops it’s an
error I think I passing that’s November
but impressed okay it’s it’s button on
as people are written that yeah yeah
probably yeah yeah evil cow were ahead
of us I’ve seen that button on in chat
but I was like hmm now they want the new
goober goober says back to MPGs thoughts
on front and with kia there is an old
buttons off to toggle when released well
I think that he that is if we’re doing
something else then okay so is it
flourished yeah I think like it it works
now but we we need to also toggle it and
toggle it so now we have no like
toggling state yeah so how do we
targeted off them yeah like I think that
your initial solution was great to have
like I think gotten it already it was
like just a very local state that was
like on or off and then you just toggle
yeah I think that you need to make that
into a boolean or because you can’t do I
don’t think if there is truly and there
are billions what other yeah it’s in C++
sure okay I’m just guessing but but you
need to actually call exchange the type
to boot instead of int hmm oh yeah of
course
and then we remove the old bot or let’s
on and we put this in a separate if in
the new yeah okay Oh datum says that
logical not course is to of course as
one zero so what you did there was
perfectly legal but it’s not like Google
makes intent better clear all right so
does this feel right everyone judging
judge the code expect Oh where’s on line
19 Luda yeah yeah I agree that it’s
clearly expresses the intent if it’s a
booth yeah do de peso says remember you
that you have three stages pressed while
pressed and not pressed
all right it’s connecting and pressing
it oh it’s okay so what happens is that
it and you see that it’s slashing a lot
hmm interesting why is it that is it
because the old ads on is kind it’s just
kind of triggering uh perhaps like it’s
not expecting that all that song should
be cold all the time but I mean
ostensibly it’s working if I press again
like it just immediately goes goes back
on mmm when do we set button was pressed
back to zero oh we don’t write no or
well I mean shouldn’t that be online in
nineteen as well
uh no I mean isn’t that what you’re
doing now I mean here we set the button
was pressed us to one but we never set
it back to zero button was pressed no no
no no okay yeah I get ya I was confusing
the two variables so when do we press
okay I’m doing a bum Nolet now everybody
says no I like more programming it’s
like you have like a live human compiler
instead it after line 19 ok so just here
is that what you’re saying yeah dude
does that make you sound smart yes yeah
it’s very funny how your mind just your
brain just shuts down
yeah bye and also we also Mattias we’ve
been sitting here since for two and a
half hours and not having had a single
break so it’s also like we should have
had a break by now yeah sure
this is true but yeah I think we’re
doing fine alright so is it flush it’s
not ready it’s just sex that’s all right
so device there we go it it all right
cool now it’s ready so look the little
indicator here is means like when it’s
just glowing it means that it’s
connected so now it’s green and now it’s
okay so who gon that was intense
okay so alright so we have a but we like
it we have can we can we break this out
into a function which part getting
turning the green toggling the labs yeah
I guess
well it’s unnecessary to do that into
function I would rather like to have it
so what would be most fun for me like
right now would be it to sort of fade
out eventually the when we turn it on we
set a time of like five seconds and
during those five seconds its fades out
Oh Express again we refill the timer oh
I love that
so do we want to like fade them to
another color or do we wanna like just
pay it
Suzy row so we just fade it from 255 to
zero that will turn it dark right now
will it can we try that yes to verify or
we like to me that would just be a
different column like if you turn it
Barry okay so I just turn it to zero
zero zero and we’ll see how that looks
because we don’t know yeah now flashing
it yeah it points out that that will be
flashing okay let’s see yeah it’s it’s
it’s completely dark now so isn’t that
good yeah I guess it let’s let’s try it
let’s try the PHA so if we just so we
instead of all let’s off we can just do
all let’s zero zero zero yeah seems like
okay so what we need now is some sort of
countdown or a timer thing yeah that’s
true we we have no idea how many times
this loop is running but exactly I think
that we should start logging the time of
the button press I think that would be
very handy yeah so if the key up the
button was pressed we should do
something log the time so we set time a
button pressed I know this are ya know
yeah exactly yeah I don’t know I like
that that’s perfect like time button was
pressed and what last last last last
button up perhaps last button oh okay
turn up press time now so int you know
yeah and it can just be initial state
could be -1 so that we can check that it
has never been pressed
now what this doesn’t light up is that
even a knife-edge a nap smilin suis
do we need to include the time library
or does this just work I don’t get it
okay I’m yeah Millis it doesn’t look
like it time Emil it’s okay yeah but it
what oh god I keep forgetting this
what does unsigned mean does it mean
that it can’t go to – or does is the
sign that it can go which was which is
it strat
so they google it yeah so sign me yeah
unsigned means no negative yeah okay it
okay this famous says that sound is
minus 170 128 and unsigned is 0 to 255
256 values yep yeah so you get like you
can go higher if you have unsigned
memory spaces those yes – plus alright
so I learned let’s just have like a
fade-out Millis we wanted to pay it out
so I guess that now we should basically
us keep fading this out so you should
figure out how how long had time has
passed of the share of millisecond time
out but you just created so we’ll just
when the button said here we just
compare how long has been oh I think
and where do we put that code I think
like it it’s where we set the color like
we don’t to figure out what is color oh
yeah so this is we basically just want
to calculate the color here there so we
basically we don’t need this if for
using the states basically we’ll just
like always be counting down yeah
yes so let’s just write that count down
– yeah yeah so I guess we’ll just so if
we take the width so we want to fade out
and then if we just do the yeah if us
remove the current milliseconds now the
current mean is yeah what happens then
what does that mean then we have then we
have a minus number right yeah because
time will have passed no right oh okay
sorry I was thinking of something else
vanlowe says that this is a really cool
idea this is flashing over USB or
Internet it’s flushing over the Internet
so this little thing is actually
connected to through Wi-Fi through the
to the particle cloud and it’s not
connected to my computer anything the
USB is just for power and david is
flashing it like it’s logging in through
the ID and editing and flashing it yeah
comment what you want to do Thank You
Lou Depp you see that’s just right here
let’s just write code here what we want
to do we want to ya figure out how much
yeah so first of all let’s just write a
variable let’s take this this varies in
very small increments like let’s create
a variable and not known I apparel not
the global I like just in line that is
how much time has passed since the last
and yeah it’s isn’t it
malaise – last panel yes yeah so now we
have the milliseconds since last but
enough yeah and I want to so percent so
then I want to create a new variable
that is percent of time out or really
mainly like the opacity or something
yeah that’s a cloud strong yeah give me
a good name I’m stuck with no share
share of time out past yeah and I guess
that this is just time since last
button-up / millisecond / the
configuration value the paid out yeah
they don’t know is is that right so if
the PHA it’s like let’s say that it’s
like said let’s say that one male in one
second has passed like a thousand and we
divide that by five thousand mm-hm
what is that 1/5 of that 0.2 yeah this
is correct I think but what happens no
now we need to like go from like use
that go from 0 to 255 yeah
so we do this yeah media engineer figure
it out this is Matthew 255 times that
yeah but I would like a new variable for
this is so that we otherwise we all have
to rename that variable because if you
add that it’s no longer the name is no
green value yeah what is even that what
what is even like that 255 called like
Green Green Valley
I guess green value is it’s pretty
descriptive let’s just do Queen red
value to five five times
share oh I’m out fast yeah green
intensity thank you yeah that’s awesome
Oh naming like and that’s more we don’t
have to green we can just call it
intensity because we can put it for
wherever yeah the only thing like that
won’t this go negative eventually like
the share of time I passed yes so I
guess we need a relic no it won’t go
negative because the last but well it’s
here we go from zero it will be in the
opposite direction so you know if you
click now it will be zero
yeah but then if some time pass yeah oh
I guess not I think that oh sweet they
are pointing out that we’re doing
floating pod math with int variables
we’re JavaScript programmers
here so this should be uploads yeah or
double like I don’t know like what is
the different does float work what is
the double double this more like yes
more numbers right more memory I think
float is fine right okay it’s really on
some kind of map function here for
Arduino let’s check that out because
it’s fun
okay I agree to the cookies I always oh
thank you good suggestion
Arduino oh cool
Rheem UPS a number from one range to
another oh that’s good
mm-hmm okay so how does this work
we are speaker brake no God I’ll eat a
banana
I actually I have bula in the in the
fridge bye
I just push through we have 50 minutes
mm-hmm okay
matheus you are the brains right now
what should we do with map I think that
let’s just figure it out okay so map oh
hang on go back so you can see it it’s
all yeah all right
map so we have a value and from low from
high to low to high I don’t quite get it
from low what from high what’s to low
high no I don’t know like yeah it’s
probably not too complicated but it
feels like I’m trying to hold two lines
of thoughts in my head at the same time
let’s let’s refactor to the map once
we’ve solved the problem ourselves first
panel I don’t think like I don’t have a
clear mental model or the of the problem
yet and then using somebody else’s
solution becomes really really hard
should it be like one – this isn’t there
yes I would use math math min here or
something like just make sure that it
doesn’t go below zero or like no it
or perhaps it’s what I’m saying no okay
so let’s say that lets say that time
since last button-up is six milliseconds
yeah so that would mean like it’s 6/5
yes what is that what does that become
like six divided that is like yeah zero
moment zero some person one at zero
point what they becomes one point two so
that would mean that share of time had
passed so that would mean that the
intensity Oh above 255 which is not a
valid value okay I get it
so I think that Cheryl I we want share
of time out past – I never go above
never go above one yes you’re really
just doing it yeah so it is yeah yes did
do an F then we don’t have to figure out
this in tight like the if there is a
math max now if time since last but not
know it yeah no I mean you share if
share of time or past is above it’s
above one you said it one okay I’m just
now I’m not think I’m feeling I don’t
have a good feeling about this so all
oh I have a good feeling about this I
think that it’s but we now we need to
also use the intensity variable so what
you would just put yeah I think we can
just remove it I’ll entire thing yeah
this is correct yes I think it’s will
increased as well I hope this is we’re
doing it in the wrong order yes yes yes
yes of course this demon says I it’s
absolutely right that it’s going to
increase the intensity over time that’s
true Tweel Orion says please look at map
yeah I know it’s just that I don’t
understand the problem
yeah so I don’t understand like I don’t
know what kind of I just don’t
Darko Davis at the top of the mana
pyramid because look at them airports
high-five buddy we the same that’s funny
yeah can you please try this Matias does
it work yeah all right so now it just
immediately goes to turns itself off
so wait no hang on turn itself back on
and uh-huh after okay I press it then it
goes black and then it immediately goes
to green after five seconds so it’s
fading up and not fading out yeah okay
so now I changed it to that one – this
time since last thingy yeah the share so
we just make it the other way around
so nowadays it food I press it now how
it goes like yeah it completely turns
off after after five seconds can you do
me a favor and hard-code the value to
so I’ve hard coded the value to 125 to
see we can pay less yeah and it works
like it’s the defining definitely work
so it’s our math that is wrong okay so
it’s a final step okay so hang on
Hawkeye says I know why are you doing my
one – on line 30 because if we have done
this correct from the start I thought it
would fix it yeah past is correct it’s
all right hmm okay so we’re changing
back we have that but it’s still not
working
yeah so everyone 55 this doesn’t like
the intensity doesn’t change why doesn’t
it change is that does it have something
ask mr. Anton what division yeah I think
that your division is round and until
it’s one mm-hmm so this intensity should
be afloat perhaps is that the thing
maybe you guys ever listen to twitch
chat but it’s so fun alright so I think
that we need to cost it back though to
before past pasting it in there but
maybe not let’s try it okay so how do I
cast afloat for Kim oh we need to cast
them to float and the share of time our
past is probably like the time because
time since last button up is an int mhm
and fade-out me they are both ins there
so I think we need to cause them to
floats and how do you cost and see how
did you just put yeah I think that yeah
exactly I think do I do it as in here
them each yeah let’s yeah try that I
think now I think that that won’t work
because it can’t you can’t cost I think
you actually need to me do a math in
there but you also need to cost the
other other variable as well in the
share of time out past calculation this
now in the in the calculation of share
our time passed on line 30 that is all
sewn in so is that what you said yeah
expression online yeah let’s let’s try
this if it works I’m I suspect that all
ads on will complain that intensity is
it’s ready all right cool pressing yes
it’s fading its fading up though yeah so
we just do 255 minus the intensity yeah
sure
or we could actually do it on the
intensity that makes most yeah so that
was the one – I was thinking of before
but they put it before we rounded it off
okay thinks that line 30 was fine
without the plot cos and he just need to
cos to cause intensity to an end on line
37 okay mm-hmm what did seem to be
working right yeah I think I think that
we need the flows all right so let’s see
it Oh mmm didn’t quite behave as I
expected but it didn’t work
let’s check check this let’s actually
count one two three four five oh it
works no it works as intended one two
three four five brilliant success very
good work I’m just refactoring here
because I think this makes more sense to
have the 255 before and then do this
within parentheses 1 minus share of
timeout test oh and now we can delete
yeah way to go all right so disk demon
said that cost can be removed to test
their effectiveness once a successful
state have been achieved that’s a good
point actually what does that mean it
means I like we’re not sure if we need
the costs okay so we can now we can try
removing the costs are on line 30 and
take em sez way to go you’re all awesome
and brave for doing this all live thank
you now you’re super nice actually
everybody is like super supportive like
super fun to have everybody helping out
yeah Twitch seems better than like
twitch the people that are engaging on
Twitch just seem nicer but I guess it’s
because when you’re engaging on Twitch
you know that people will listen to you
by but when you’re riding in like a
YouTube comments field you sort of like
yeah you don’t really expect anyone to
read it yeah that’s true it’s like then
you can question like why are we even
riding there but I don’t know yeah like
like comments on YouTube are like
formulated as if I don’t read the
comments like they are directed to other
commenters like they don’t think that
it’s obvious that they don’t think the
real human reads it suis Logan wouldn’t
it fail after a second press on the
bottom it should just light up again
Wiley Wiley still fading fades out right
yeah yeah we definitely needed the
floats okay let’s put them back I would
put them back I just want everything to
be up and running before we turn this
funny how I’m not hungry even though
it’s lunchtime oh yeah I wonder what why
that is hmm doll of QT one of them okay
sure yeah but I think that costing both
give shows intent well dollop QT says
it’s only it’s also probably because the
Science and Technology section does not
get a lot of its troll traction yeah I
would I wouldn’t like no you mean trolls
don’t believe in science that’s funny
that’s right it’s the Union it’s a good
point I’m gonna press it and then acid
face I’m gonna press it again yep bring
burps back to this pretty cool yeah so
now Matthias you can just put this to
like 24 hours or something yeah and then
you can keep that that’s like em some to
that’s that there is yeah that’s pretty
cool that’s pretty cool yeah so I think
we should wrap this up now because yeah
we’re I would have to eat and then I
have to go to this thing yeah but we are
I mean we are exactly at like 90 minutes
from when this beam was announced so I
busy Watson dream just as we’re
finishing off hi Logan I have no idea
what the intent was the idea I don’t
know why we you would do this because we
have different personality he’s more of
a person that needs to set up rules for
himself yeah that’s true like me and
Simon yachts are the same we need like
these feedback things David doesn’t need
yeah and what and the next time this we
probably will get on with a swim way
earlier because now we’ve done this one
time yeah I I think that this was yeah
we had some trouble getting started but
way less than with the depth tips well
and I think that I don’t know got things
going we got something done in 60
minutes and like amazing and of course
yeah as in la geo is saying that we
should have written up the intent so if
someone’s the joy meaning like why we
here started with the Middle East I can
saw something like what are we even
doing yeah but we will do that we can
put that in there overlay or something
next time yeah the question like we need
some kind of it would be cool if we had
like some dynamic overlay that that was
updating from you know miniature or
something no no no we should have like a
small small small web server that’s only
updating for everyone so that chat can’t
change it oh that’s a damn late idea
yeah yeah we need we need chat to to we
have to have work for a chat to always
update it we need to put all these
chatters into work otherwise they will
just sit there and help us instead they
need to have some good do we need like
we need a mob programming plugin for for
twitch so that we can like update in the
overlays and people can vote on things
and because it like a lot of people like
different suggestions
oh so much fun we can view this both in
the chat to update code it were pretty
cool to have like a visual studio code
plugin where people could just inject
code into your stuff yeah okay so yeah
then I’ll just do the outro and we were
done yeah let’s go to cases only and of
course it changed this size again yeah
we need to figure out how to make twitch
stop doing that you have just watched an
episode of fun fun fun pressures
function you have just watched an
episode of fun fun function we release
these an edited version on every Monday
morning Oh 800 GMT and we stream it
during the week on which you will forget
that so subscribe if your new tube or
follow us on Twitch this has been an
episode of fun fun function I am MP J
and this is David until next Monday
morning or when you catch us during the stream stay curious
Please follow and like us: