Categories
Technology

Hector Alcazar | Uncharted 4 A Thief’s End Part 2 | PS5 Playthrough Gameplay Reactions 4K

Hey it’s, sarah, and welcome back to my channel. Okay, guys it’s, time to get started with part two of uncharted 4 and we had such a tremendous start.

We started off with a flashback of nate’s life as a kid how he was part of an orphanage, nothing i’ll save it for confession.

Later on, we found out that he actually had a brother.

I’m not staying out of trouble.

This is an exception nah.

I have a cool brother, nice jump.

Now we have to assume that our parents haven 39, t really been around and that sam has been the only one taking care of us which made it all the more sad when we saw nathan’s face, seeing that sam had to leave him once a Little bit like a year, then we fast forwarded to a time when nate, sam and rafe was in the panama prison on the quest to find the next clue for their treasure fund.

There is a cathedral of saint dismiss in scotland, wait.

The last sighting of avery was in scotland that can’t be a coincidence.

You know i had my doubts about you too. Let’s find vargas, get the hell out of the, but when they were trying to escape sam actually got shot and well that’s where we are now now the writing and the voice acting and uncharted 4 is superb.

No, he’s not dead.

Wasn’t what did it wasn’t he just in the boat with us a while ago, oh god.

No, i do want to mention that i’ve been wanting to post longer videos, however, because of the copyright issues that i’m.

Having with this series, i have to keep them shorter, like to an hour long, because i wouldn’t know how many times i need to re edit and re upload them now.

The copyright is so stingy with this game that it’s actually pretty hilarious.

I want to show you guys what i mean, because i feel like you guys, are gon na get a kick out of it.

Okay, so here you see a list of all the uploaded versions that had copyright issues.

Now i’m gon na click on this particular one.

To give you guys an example, which is the next episode all right, so here you can see that they claim copyright for background music of just 10 seconds now i’m just going to play it here, so you guys can see how picky they’re. Being okay, it’s not even a main thing or a main event: um it’s just a few moments of background, and just for that small clip.

The copyright holder can claim the entire video honestly being demonetized.

Doesn’t bother me as much, but i just find it a little off that these guys get to control all the ads and all the revenue of the entire video for just 10 seconds of background music, but other than that.

It’s not really affecting my enjoyment of the playthrough and i’m having a blast with this amazing game.

So i’m excited.

I hope you’re excited.

Let’s get started with uncharted 4 part tall whoo right made it to the bottom.

Okay, according to your signal, you’re at the coordinates.

No, not yet.

Anyway, you got any pinks from up there pray not all right. I’ll just keep heading downstream copy that keep me posted.

You got it.

I might watch it down to a quarter tank.

You want to come up yeah, i’ll, be fine.

Can’t be far if you don’t find it soon? I’m calling it i’ll, find it all right.

Oh oh treasure, i feel like a little mermaid.

We’re a man brah.

I can’t believe sam’s really dead.

We’re doing the 15 years later thing fit.

I mean fast forward thing yeah. I got something here: no rust right, color, maybe hit the rocks tore off before tumbling.

Hey you,’re mumbling.

Sorry, it looks like a piece of our wreck must be close by you.’re teasing me now.

Drake you’re teasing me dude.

I love this game there you are.

I found it all right, how’s it look that’s beat up but intact.

Okay, where am i supposed to go okay here? What do we got here? All right? I can see the cargo it’s like most of the crates are here.

Can you get an accurate cow? I’m gon na have to go inside for that standby all right here we go there morning, fellas all right.

I’m in yeah looks like a lot of it.’s still strapped down see.

We got one two, three okay, but my count. We’re shy.

Two crates, i’m gon na go round them up hold on how about you come up.

First, get a fresh tank; ah the crate’s got ta be nearby.

I got this yeah.

No, let’s get a tank.

Oh there, it is.

I found one ah crap, the crate’s pinned beneath the trailer.

Tell you what secure the other crate.

First then, we’ll lift the trailer up for you yeah.

You see that’s. Why you get paid the big bucks? Oh there, it is found the other crate one down one to go, secure it in the trailer we’re.

Nearly at your position.

All right see you soon dude.

This is so much fun.

I’m having fun all right that’s, one crate, secure, good timing.

We’re right above you slings on its way down coming down.

Oh okay, let’s get it! Okay, it’s in position hook up the trailer we’ll raise it up a bit for you.

Okay got the cable.

I’m gon na try looping it around one of the axles, all right that’s, one all right! You watch your oxygen.

Now that’s, fine, the gameplay, is so good and that’s, two okay, trailer secure, ready to go all right, get clear. We’ll, lift it up ready when you are and up we go.

Okay.

Is that enough, yeah plenty, just don’t drop it on me.

No promises! Okay, we got the other crate.

I’m gon na strap it in with the others.

For some reason.

I’m scared a zombie’s gon na pop out of nowhere.

There you go: oh boy, all cargo present and accounted for and with five minutes of oxygen to spare jesus hey.

Maybe you should hang out then see if you can find some other treasures down there nah i’m good wan na ride up.

Okay, i’m in position. Get me out of here will ya you got it going up all right.

We’re gon na come to you hang on, hang on it’s, so weird playing a naughty dog game and playing a character that lives in a world that works good to have you back, drake yeah, it’s good to be back toss down.

Your gear here you go thanks.

Nice whoa, this tank’s kind of light.

I’m just making your job easier right, my man, how’d we do.

How do you think full recovery every last bit making the rest of us look bad, making the rest of you look good nice dude, even the nbc’s are so good.

You,’ve earned a break.

No, no thanks.

Take a dive over being at the office any day, yeah either way it’s gon na be a while.

What are you talking about about thursday’s? Job? Oh, come on no got under bid. You got to be kidding me: hey competition,’s! Tough! Let’s see here now care to do the honors, okay, yeah sure thanks wow, look at that.

What is it? We struck? Copper! Oh! Well, you’d be surprised how much this stuff is worth clients paying good money for the full cover.

Sure you don’t want to just melt it down, make some pennies come on.

Let’s go celebrate first round’s on me bar hopping with you guys: no, no! No! Not unless there’s hazard pay yeah it’s.

All the same.

To you, i think i’m just gon na.

Do the paperwork and uh get home and crash a raincheck, though all right suit yourself, hey good work today, thanks nice.

Is he a dad? Now? Is this after uncharted? 1.

2.

3. 15 years after hey nate, hey hold on hey.

What are you doing here? Uh? I got a present for you, president.

What’s this got some news for my contact about that wreck off the coast of malaysia: oh no uh, the ship’s intact, yeah, cargo;’s right for the pagan! You are a persistent one.

I’ll give you that and all the money came through for the equipment too.

We are all set except uh, my best guy, the guy.

I trust for the job, the only one he he’s got cold feet.

My feet were never warm to begin with and tell me this contact.

Yours did you get the permits? No, he did not get.

The permits.

Can’t, no one get the damn permits, but nate don’t. You see that works in our favor.

No permits means no competition, the ship is ours.

No permits means no go.

Hmm that’s.

True, that’s, true no pyramids would mean no go permit money for the both of us.

Okay, i don’t know about you, but i don’t want to be working salvage.

When i’m 60, Do you sure beats prison? Listen.

I have to pass and trust me.

So should you okay, just take it with you.

Humor me. I’m not gon na change my mind.

Well then, don’t hurt to sleep on it.

Does it say hi to carla and the kids for me all right, no pressure, nate but think about it.

I want to see if nate has babies with elena.

You really did your homework on this one.

Oh okay, narrow down the search area.

It would make a hell of a fine.

I can’t read your penmanships are too pretty.

I can’t read it son of a no no, no way you are going with the others, okay.

Well, what’s gon na make me wan na go climbed your big brother, some years back. I think this was an uncharted show.

I remember that one of the stranger things i’ve collected along the years.

We have all of the treasures we got from the old games.

This is so cool spanish doubloon found in a german, u boat in the middle of a jungle who would have thunk? Oh, i remember i remember i remember that, but this is probably the treasure i didn’t get to get you remember, sir.

Francis drake takes a bullet for sully.

Look at us charted one noise, okay, wherever this is on my old camera, it’s hot.

You’d, like it.

How have it found this on my old guitar? You’re like that, like she, your wife bro.

Well, i we already know that you married her, but oh wait.

Let’s go don’t tell me. I’m single shambala, oh chloe.

Where did we find the time to take a photo or maybe at the end of the game when everything was fixed francis and his elaborate puzzles? I remember this one all too clearly g lawrence.

What’s this now this was a crazy ride.

Um this was probably the first.

How are things living up to my head? Another lifetime chloe? Oh, it’s chloe nothing, but enough to keep the heat on the wine stock caught one end of something that sounded right up here.

Should you ever give me a yell? I’m always on time for a quick, getaway, love chloe.

I wonder if she’s, i think she is gon na make an appearance.

I think she was on the cover of this game, even not really my style anymore.

Hmm they come take cover surrounded.

What no way are we practicing bullseye don’t like your nate. This is so cute.

Oh, he misses the action adventure all right, take that and that eat plastic eat plastic! Look for ammo, because, okay, this is pretty cute.

This is pretty cute back in business.

This is such a clever way of getting us back into shape for the gameplay.

I love it.

Yeah bring it like.

Oh nice yeah, i’ll be right there.

So long.

We’re still married to the lane yeah my time’s over oops.

I didn’t mean to do that. I thought i was out of ammo.

I didn’t want to go down just yet man.

I wanted to keep playing wow.

Can you imagine if nate was your dad and that’s so cool? If it was your dad and uh wait, you know what the cover and dive is so much smoother like.

I could do this all day anyway, as i was saying, wouldn’t it be much funny much funny it wouldn’t be funny.

If nathan was your dad and he went up and he saw him rolling around the attic that’d be cute, i’d love it.

If i saw my dad like that anyway, let’s go on left playing for now.

Ooh, our home is pretty good.

They have a pretty good home.

It’s messy, very messy. Oh, was this our second wedding? Oh, we look so cute together.

Now that is a good one.

Wow all the little details are so great.

It makes it feel like a real home.

I mean it’s so messy, but it i mean that this is what a house looks like.

Sometimes i love it so realistic.

There’s even a loofah that’s so cool wow.

It’s.

The office the home office – oh, is this what you’re working on a travel guide? Oh wow! We really need to go on another vacation wow that’s.

So nice look at the details. Oh it’s been too long.

Okay, wow! There’s.

Only three photos: okay, it’s, so different.

It’s like night and day with exploring houses, and the last of us, like this house, is full of stuff from the real world.

I love it.

You were up there a long time.

Well, i was researching something: oh.

Is that what we’re calling it these days, i was hey.

Would you mind grabbing the food? I’m just wrapping up here.

Oh yeah, sure thing. Thanks nice, where’s the food? Oh there you go.

I love our home, it’s, so cozy finish it yeah.

You know it’s, probably too long and full of typos, but that’s what editors are for right god, i’m starving.

It looks good mm, hmm joe.

How was your day there? What huh got none of that? Oh, i’m.

Sorry, i’m.

Sorry how was your day? Oh, it was fine mm.

Hmm typical day in paradise, uh huh, i um.

I got to pull a bunch of garbage out of a river um.

Yes, at least you got to go for a swim. Did you find any exciting garbage? Oh some, brilliant stuff.

It was a um early 21st century truck.

We got, apparently the natives called it a semi.

Our dear lawyer, so boring stuff.

Tell me about the article.

Well, it started out as this fluff piece about tourism in bangkok, but i don’t think the magazine is gon na, like the angle that i’m taking, because everyone immediately commented about how rude the smog was, that it was like shocked to the lungs.

Like the second that you got off the planet, he’s, not listening.

Oh wow, look at their faces the details, they love it.

Ah, what? Where are you? Where are you here being stabbed with a fork? Oh really, what just keep going that’s? So crazy, it was interesting.

Um, oh interesting! What’s my article about what this one? Oh um! Oh all! Right! Let’s just go for the last city of bangkok. What about you know the uh lost city of bangkok, not not of bangkok, lost city near bangkok, in or about the city limits of bangkok, wow, all right, i’m, sorry, no! It was valiant.

I was in the ballpark right in a different state, but yeah you were in a ballpark.

Jameson asked you about that malaysia job again, jameson always asked me about the malaysia job look nate.

I really think that you should take it.

You know what i don’t want.

It really i mean he doesn’t have the permits and we, you do have one day they kind of work anymore.

It’s just not worth it it it.

Doesn’t sound that risky all right.

If it’s just a permit, no way, you could call sullivan you haven,’t seen him in two years.

Could we please drop this okay? I just don’t want you to not take it because of me. I’m not taking it because of me.

Okay, i appreciate the gesture it’s.

Just wait.

Are we in bad times it’s, like i,’m gon na go ahead and do the dishes just stop.

I’ll do them? No, you did them last night.

No, you cooked, i cleaned it.’s, fine! I mean at least at least uh.

Let me let me try to earn it or something.

Let me um play you for it.

You’ll play me for it.

Yeah yeah yeah your little tv game thing. I bet i can beat your high score.

You think that you can beat my high score on my tv game thing yeah.

I think you’re scared.

Now you don’t even know what it’s called.

I don’t need to know what it’s called.

I’ve seen you play it’s jumping and running, and i have a natural talent for that.

So what do you say chicken? Is it a bet? Oh wow, wow? Oh, is that a playstation one? Oh, i’m learning.

Alright, oh that sound that sound is so good.

It has to load load.

Yes, this is taking a really long time. You have no patience.

You have no money turn something on.

You expect it to okay.

Let’s crash crash manico.

This was naughty dog’s, first game; no, that did.

That was always first game.

How do you uh they make it go? Oh wow that’s so smart of them.

Okay, i love how nathan is not a gamer.

It’s so hard.

Oh wait! Oh my god! I’m actually playing it. Oh, my goodness, i’m actually playing it.

This is very nostalgic.

This is very nostalgic for me.

Right now, okay run away from the boulder.

Why is the boulder chasing me? Just run away from it, i did nothing to this boulder.

I didn’t use your spin attack whoa.

I used to play this all the time i didn’t think this was the one guys abandoned makes sense.

It’s like a fox and jeans.

Okay smash the boxes, what is a fox smashing crates and that’s just what he does and it’s not very realistic.

These graphics are pretty good perfect by the way foxes can’t do this. It’s a bandicoot that doesn’t look anything like a bandicoot.

Have you ever seen a bandicoot? No, but i’m sure they don’t wear sneakers.

Okay, grab the fruits, wait a barnacle! It’s a real animation, nice, okay, good! No! I didn’t beat.

Oh may it be her.

What is that it? You asked for it.

Oh wow, he’s so good totally had it.

You can give it another shot, come on double or nothing.

My car could really use a good cleaning really going to start the smack talk there’s, this mode called easy mode.

I just switch it wow it’s way easier on you.

Just keep talking keep talking. What are you going to do? I’m warning: what are you going to do in real life? What can you do show me? What can you enjoy? What do you think about that? Oh it’s so sweet.

I want to punch them.

Are you happy yeah? Of course you um um really come here.

You know, i think he’s totally turning down the job for her.

You know he just loves her so much so she doesn’t want him.

She doesn’t want her to worry, but he is totally turning that job for her.

But oh, he loves her, not open yet dude.

I love how it’s.

Like i’m, watching a movie, we’re closed, come on man all right.

I’m coming coming yeah. Can i help you yeah? I’m uh, looking for my little brother, it’s about your heights, a little bit leaner, definitely less gray in the temples sam.

It’s good, to see you again nathan, all right all right.

Take it easy.

How i thought you i saw you get shot.

Yes, you did right there, jesus the doctors, they doctors, they patched me up and they tossed me right back into the cell yeah, but i i made calls i checked everywhere.

Everything i heard everything i found it all confirmed.

You were dead, okay, so they wanted to see me rotten, that sell for the rest of my life and i nearly did he’s a semi man.

If i had known i i swear to you, i would have come back.

I know nathan.

No it’s. Important.

Now, though, is that i’m out: hey hey you still with me wow.

I love the needs of there.

Dude wait.

Is this a ghost? Am i hallucinating you’re not gon na pass out on me or nothing are you? I just might it’s a lot to digest.

You know it is a lot today, kids, what did you get out yeah? How did you get out there? There did you even get here find me all right, slow down, hey have a seat.

Are you gon na have a flashback? Are you gon na me yeah? What’s the tell well call some of your contacts tell me some pretty crazy ass story.

Crazy stories got shot hanging from a derailed train in the himalayas.

Oh yeah, that actually happened come on man.

What did i miss sam? Where do i start start with the best part or shambhala? Okay? Um, a few years back, i got roped into uh uh breaking into this turkish museum to steal his oil lamp, okay, oil. It was an artifact from marco polo’s lost treasure, fleet, kubla khan 39, s treasure yeah, yeah and, as it turns out, it was a whole hell of a lot more on those ships than just treasure.

I mean what can i say: another lost city destroyed and uh.

We made it out alive.

Would it matter what i picked, though unbelievable yeah yeah it was.

We should have been there.

No, it’s literally unbelievable.

You you tell me you stumble upon yet another archaeological gold, mine and somehow you managed to walk away with nothing.

Well, it’s a story of my life.

I guess, but you know i managed to grab a few trinkets here and there paid off the car.

The house engagement ring the engagement ring i’m married. I can’t belie elena from the stories that’s, my wife you got ta come meet her tonight dinner.

At my place you’re coming to dinner.

I can tell her all about you.

I got to tell her all about you nathan, i’m in a lot of trouble here.

What happened? What are you talking about? What kind of trouble? What’s the name hector alcazar ring about with you yeah? He’s, the the drug, lord butcher of panama, right, why it’s a funny story, but uh last year he was my cell mate.

So this is how i got out of prison.

No, what happened? Well, you’re not reading the night samuel come here, lisa the guards they’re singing.

Well, they’re, probably drunk perhaps, but they are content.

How can they be contained with their small lives, their miserable jobs? I mean they have wives to go home to what do we got no offense, we have ambition, bro and when we get out of here that ambition will take us to places.

These idiots cannot. Even imagine yeah well amen to your optimism.

What will you do when you get out samuel that’s? If i get out of here, i’m sure you can imagine i can, but i want to hear you say it.

I will find the greatest pirate treasure of all time, which i’m sure you are sick of hearing about by now.

Oh no, the tale of henry avery and his 400 million in jules and gold has become a sweet lullaby for me.

Do you really think you can find it given the opportunity, absolutely ambition? What is that avery quote? I am a man of fortune and i must seek my fortune.

I like how he thinks the hell was that the opportunity of a lifetime samuel.

Are you ready to seek your fortune? How long have you had this plant since the moment i set food in this place? Samuel keep up.

We’re going to have to move quickly holy that’s a lot of dead bodies.

These men are sadistic.

We’re doing the world a favor huh here you’ll need this. Oh, my goodness, you remember how to use it.

Yeah it’ll, come back to me hector.

You do that and you’ll start a goddamn riot exactly energy.

This is crazy.

My bad, you see the blood’s working yeah.

I see that looks so good is everyone another position.

I think that’s what he’s, trying to say what? Why just do it? It’s gon na explode.

Oh my goodness, yeah yeah, i’m fine.

You see i kind of guessed that right, but i still got shocked that’s.

How you know this is a good caveat. Oh my goodness, dude! I love.

I love it.

Oh samuel take cover: where are we going? Oh there, okay in a minute, we will either be free all day.

Are you ready? Oh samuel, stay back.

Okay, i’m just gon na get some ammo, while y’all get ready, hmm yeah! I think i like this one, what the hell do we do.

Oh, i’m pinned down.

Oh nice, oh foreign scratch! Your back! You scratch mine! Oh well, here tell me! Oh no! I know i’m good.

I’m better than good.

Actually, you’re dehydrated.

So what’s next for samuel, drake jesus? What is next uh? I take a bath. I’m gon na sleep in a real bed, maybe find a nice warm body to sleep next to me, uh track.

My brother down seems like a pretty good start: yeah.

It is so um.

How long do you think it will take for you to retrieve every stranger i don’t know i mean i get back to the states.

I can resume my search hello.

It’s kind of hard to say until i get started.

You said you know what i think yeah uh.

I do.

Okay, but listen it’s not like avery, left some map with a big red x on it.

Okay, but i’ve, i’ve, i’ve got some berries. Oh okay, just just wait a minute.

Take take hey yo, oh my goodness.

I knew it.

I like you samuel! More importantly, i believed you.

That is why you were here.

I can get it okay, i just need some time damian, you see.

The problem is i’m.

Having all of these doubts into my mind, hector listen to me.

I will find it.

I swear how long six months people are lazy. They always ask for more time than they actually need three months, three months, three months, half the treasure, can you do it? It three months have the treasure now, if you run but try to hide the treasure or do something really stupid like go to the authorities.

Oh no and when you least expect it i will be there at that point.

Death is not a mercy.

I will grant you dude.

You should have just left me in the prison.

This is some ball here.

Come on.

No, the nearest town is 10 kilometers.

In that direction towards the sunrise it’s been a while, since we’ve seen these sunrise outside huh almost when i find it, then what don’t worry when the time comes, i’ll be there to collect.

When i swear to samuel alcazar lets me go, and here we are. This is bad.

Let me just pick up the trail where we left off and wait trail sam.

There’s no trail after rafe, and i escaped he took his parents fortune and bought up all the land around st dismas cathedral.

We comb that place for weeks.

Avery’s treasure isn’t there not that that stopped rafe warren’s been digging for years still, hasn’t turned up squad, not really surprised.

What does that mean? He doesn’t know where to look.

Well.

I just you know, happened to do a little digging of my own and uh.

I bet your rafe doesn’t have this: it’s, really amazing what you can find on the internet these days, just the saint dismiss cross.

Oh, is it because the one we found was broken and hollow? Remember holy crap, it’s still intact, avery made more than one cross. So what i was missing from the one in panama is probably still inside this one all right, but where is this? Oh, this exquisite piece is going up for auction in three days at the rossi estate, the rossi estate.

Oh, you know it uh yeah, and how do you plan on securing an invite to an exclusive, heavily guarded black market auction? Don’t necessarily need an invitation per se huh yeah, and where are you gon na get the money to output all the high rollers? I could take a second mortgage out on my house and it still wouldn’t be enough to yeah.

You’re gon na, try and steal it huh.

We are oh, no.

Oh man, listen! I’m.

I can’t.

I’m.

I’m out what no besides there are plenty other guys that are much more equipped to handle this kind of thing like who um, i don’t know like uh anybody, charlie cutter.

No, no, he’s my go to guy.

For this. Absolutely not! I don’t trust, charlie or anybody else that you’ve got on that phone with my life.

Okay, i need you on this one.

It’s like he,’s, really my brother and i don’t know how to say no, not with the time i got left, certainly not with alcazar, hey hun it’s me how uh listen.

You’re, not gon na believe this jamison just walked in here with the permits yeah.

I can’t even tell her about my brother.

It’s, like i,’m gon na, take that malaysia job after all, see anything yet just a bunch of high class low life criminals, all cleaned up for prom and no sign from sullivan.

Yet well, there’s still plenty of time like the storage room’s in the building behind the manor.

You see it from up there, just the very top of it.

Oh, i wonder what they got tucked away in there.

Let’s just focus on avery’s cross. Okay! No, you sure you don’t want to pick up something for the wife that’s cute just keep it simple right, simple and it’ll be a whole lot simpler.

If it was just the two of us sam, we could be inside already not cleanly.

Have you even thought about a backup plan in case uh sullivan gets cold feet? No, because he won’t or if he got caught sam.

He knows the people running the auction.

He’s gon na schmooze.

His way right through that party get upstairs unlock the window and we’re in it.’s a solid plan, uh huh, all right, fine, good, say it.

What if he stole the cross for himself, not in a million years, that’s so cute that we’re talking about reports? He’s double crossed people in the past, but not us, no, not you! I know you two have never seen eye to eye huge understanding, but i trust him all right.

He’s, family! No! No! No! No! I just need you to trust him too.

Fine bye, he’ll come through for us.

He will. I trust actually come on.

You have to at least just for one second, consider the possibility see trust just try to keep the ducks clean yeah.

I love i i miss my sister.

Oh, my oh, my honestly, i feel like this game is just gon na keep getting better and better um.

I’m happy.

I forgot about the start of the game and that i didn’t.

I forgot that it was sam that made all the more that made me all the more happy or surprised, pleasantly surprised that sam was still alive um.

I am, however, i’m, not a.

I don’t blame him for the decision that he made to, of course escape, but i already kind of knew deep down that it wasn’t gon na go well, obviously because he was telling the story of how he was in trouble.

But my heart, my heart, i i don’t know like i can already feel how this game is gon na break my heart and how i’m gon na be sad, but i still don’t know ball is up in the air. I don’t know if sam would really be a bad guy if he’s, gon na get betrayed and everything, but i’m just really hoping that i’m gon na have a happy ending like with the previous games because they’ve.

All been happy ending, so i hope i’m gon na get one um with nathan lying to elena, though about the permit.

I kind of wonder why he did that.

I’m worried um, but it might make it seem, like you know, that might make for a good story, though so i’m excited to see how that’s gon na pan out.

I’m also excited to see sullivan again because it’s been two years since they last talked, and i wonder why that is, but my favorite part has got to be the playstation one when they showed that and then they showed crash bandicoot, like i Didn’t know that crash bandicoot was naughty dog or it seems like it’s the first game ever that they even even that they even made.

So that was a pleasant surprise, because i used to play crash bandicoot, but yeah.

This is just overall.

I can understand why this is everyone:’s, favorite, uncharted it’s, so fun it’s like very nostalgic, but especially the little treasures that we had in the attic.

Just so many nice things to say, and i’m excited to see the rest of the game – i’m happy.

I’m very, very happy anyway, as always, if you guys like this video, do give me a thumbs up and leave a comment down below, and i’ll see you guys next time bye, you .

Categories
Technology

IoT Full Course – Learn IoT In 4 Hours | Internet Of Things | IoT Tutorial For Beginners | Edureka

The Internet of Things
is the giant network of interconnected devices from these devices are capable
of making decisions without any human intervention. Edureka welcome you to the full course session
on the internet of things and what follows is a series of fundamental concepts
on the internet of things which will help you
get started with IoT. But before we begin let's look at our agenda for today.
so we can start out with introducing you
to the concept of iot. We are going to discuss. Why do you need I will take what is iot of you benefits
of iot for biofuel features and finally the very important five layer
architecture of authority.

Then you're going to discuss
Raspberry Pi in this section. We are going to talk
about why you need Raspberry Pi what does Raspberry Pi
of you Hardware specifications and the installation
of Rosman fire also, This module. We have a few demos
including the Raspberry Pi a few cents hats and
Raspberry Pi camera module. Next. We are going to discuss
the top seven projects in iot in this section.

We're going to talk
about the best projects that we found in Rog next. We will talk about iot devices are going to talk
about various devices which came into Inception after the concept
of iot was introduced then we want to talk
about iot applications in this Section we
are going to discuss practical applications of iot in various domains such as Healthcare
security traffic governance. So on and so forth and finally
we are going to discuss all things career in Ironton. They're going to talk
about the job market the opportunity the salary
in different geographies and experience so on
and so forth, but that we come to the end of our agenda also going to take
up this time to subscribe to us and don't forget to hit that
Bell icon to double missile. Update from The Edge
Arabia YouTube channel.

So without Much Ado, let's get started
what is internet of things now to help you understand
what is internet of things? Let's look at an example
of a mobile phones Forest. Okay. Our mobile phones
has GPS tracking. It also has mobile gyroscope
you have adaptive brightness, which gets adjusted based on the light falling on it
you have voice recognition. And you also have face detection which identifies who is
the user now again iPhone x is coming with face detection. So again, these are
a lot of features that are coming pre-built on the mobile asset and most of these have a common
interaction between them because let's say
one application can use all of these features. I can also have these features in itself being interacting
with each other. Let's say based
on a GPS location. My brightness could be adjusted
or based on the direction. My phone is being held
the brightness in itself can also The adjusted as well. So there are a lot of features but when they interact
with each other these features come together to bring
in a better system that anything that they can
provide individually as such that's what internet of things is it
basically is a platform where we can connect
every day things which are embedded
with either Electronics software or sensors to the internet and this in turn enables us
to collect as well as exchange between these things.

Now when I say things it
can be anything and Nothing, let's say I have
an internet platform where and I can connect these things if I take the example
of my house, I can connect my lock. I can connect my AC. I can connect my light and all this can be managed
on the same platform since I have a platform so I can also connect
my car to this. I can keep a track
of my fuel meter. I can keep a track
of my speed limit. I can also keep track
of the location of the car as well. Now if there is
a collective platform where all of these are connected
wouldn't it be great because I would love to Of the AC on and set
a cool temperature at my home by the time
I reach back from office if I have a platform that knows my preference and
that keeps track of where I am and where I'm going
to then it can also identify that I'm going from work back to Hope
and my preference suggest that it would be best if there was an easy
temperature of about 22 or 23 degree centigrade
and this is something that is definitely possible
through internet of things.

Now, this is just one
of the examples now, let's say tomorrow
you come back. Home, it would be great. If I wouldn't even need
a key to unlock my door my home system should be aware that I have come home
and should unlock all the doors that are needed. And now this can be done if my mobile and my home
devices are connected onto the same platform based
on the location of my mobile. It can identify that I am at my hope
so it will automatically unlock the door and let
me come in as well.

These are some
of the real world implications of Internet of Things. These are something
that are already happening but going forward what Need to understand is that when I have
a specific component with me, which can do a lot individually
wouldn't it be great if I can collaborate
this complaint with my system of different components
and build up at a system. This is what internet
of things is helping us to okay, you provide a platform to which
all these things are connected through the internet. So internet becomes the medium
through which you're connecting all these components were
things to a platform. Moving forward let's
try to understand. Why do we need internet of things now to help
you understand why let's look at an example. This is a patient at home.

Okay, he's on constant
life-support wearing. His status is being checked to a health monitoring system
present on the cloud. Let's say at a point
there is certain issue with respect to his health. Let's say there's some
irregularity with his heartbeat or his blood pressure is low. There's some fluid being
developed or so far now what? Offenses since the system
on the cloud is connected to a hospital as well. This information would
get passed on to the hospital as well. They're in what would happen is that they would get
the complete details with respect to the patient and the important
information with respect to the current situation
of the patient as well. We made it aware with respect
to what issue exactly is the patient facing
as well as enable them to dispatch an ambulance immediately to bring the patient
back to the hospital as well.

Now meanwhile, once the patient
has been picked up and brought back to the hospital
there could be prescriptions. There could be medicine. They could also be
an operating theater made ready in case of an emergency
situation as well. There'd be doctors on standby who have the complete
history of the patient who have the complete details of the present condition
of the patient as well. So this in turn brings
in a lot of transparency and reduces a lot of effort and time involved with respect
to this same thing. Let's take in today's scenario. There has to be someone
wandering this patient's health. If there's a fluctuation they
need to call the hospital they need to call request
for an ambulance.

And meanwhile,
once the ambulance is here. They take the patient
and their back into the hospital then again there needs
to be a lot of checkups that need to be done because the doctors are
not fully aware again. There is a lot of tests
that need to be run and this in turn leads
a lot of delay as well in certain emergency cases as such if a system can do
this then this is exactly where our future lies in and what we have to definitely
move forward to to now Internet of Things basically
is expanding the interdependence of humans to interact contribute and collaborate with
things around us. Now. What do I mean by
interdependence of human see how we depend on each other like how I'm explaining
this concept to do if you're not clear you
would reach back to me. You would request me for help. Okay, this becomes
an interdependence between us when I'm giving you knowledge when you're not here
you're coming back to me and you're helping
similarly tomorrow if there's something
that you can do for me, I would reach out to you.

We all are interdependent
on each other for something or the other if we can expand this interdependence
to interact collaborate and contribute with respect to
the different things around us. Then we would be building
a proper Internet of Things environment. This would be a much more
safer secure effortless and time-saving environment
into existence moving forward. Let's Talk about the various
benefits of Internet of things. Now. The first thing that would be as a benefit of having an Internet
of Things platform would that you could efficiently
utilize the resources that are available if I have a smart system
which can interact with everything if it has
enough computational power if it has enough understanding of how things work
between each other.

I'm quite sure the usage of the resources available
will be more efficient as well. This resource could be
in terms of monetary. It could be in terms
of natural resource it. Also be an input taken up by the thing as
an input and so far. Okay. So all this can
be more efficient if I have a platform which is more smarter
and interconnected as well apart from this it minimizes
the human effort involved if my system is smart enough
to interact it to filter smart enough to do things that I do need to get involved with then my interaction
is always going to be minimum.

This is same with everyone and
that's one of the major reasons why Internet of Things
has become popular today. The and the concept of smart home is always growing
as well in the same perspective because if the system in itself
is able to do most of my work at hope then I don't need
to put in much effort. I can relax at home without
having to worry about anything. Okay, the next benefit
would be it saves time. If it rains my human effort
definitely it is going to save my time. Okay apart from that if the resources are utilized
more efficiently then again, it is going to save
a lot more time as well. All-in-all any benefit
of Internet of things will in turn help you save
a lot of time as well. Okay. So time is one
of the major factor that can be saved on an Internet
of Things platform. Now if I have an artificial
intelligence platform through which all
of this is managed and maintained then
the personalization and the human touch also
comes into the picture.

Now today most of us have had a level of interaction
with an artificial intelligence or a virtual
intelligence as well. This could be
a personal assistant like see Hurry, or it could be
an assistance application like Google assist now if I have system where all these components and things are interconnected then in turn all
the security present on each of these things
is going to get multiplied and it's going to build a much
more secure system apart from that the level of security that we would be integrating to the platform in itself
is going to be quite huge.

So the overall security
booth respect to everything is going to increase
multiple times as well. Now let's look at some
of the major features of Internet of things. Now any technology that is available
today has not reached its hundred percent capabilities
and it always has that Gap to grow Internet
of Things is one of the major Technologies
in the world today that can help any other
technology reach its true and complete potential as well. Now there are mainly three
aspects to Internet of Things.

Things as to how it works first
is the connect aspect here. Basically, what you need
to work on is you need to ensure that there is a connectivity
between all the things around you all the necessary
things to The Internet of Things platform. Okay, then comes analyze now,
I have my things around me. They each are going
to generate some amount of data now this data
needs to be collected and it needs to be
analyzed to build a business intelligence solution if I have a good insight, The data that is gathered
from all of this then definitely I can call
my system as a smart system. Finally what happens is
in order to improvise and improve your system. You need to integrate it with various models to improve
the users experience as well.

Let's say there's
a personalization module that is there or let's say
there's going to be an aspect when I can directly
connect to my providers. Now. This provider could be Amazon. It could be Flipkart. It could also be my retail store
that is next to me. Let's say I'm out of milk to retail store
will get a notification and he would send
milk right away and the same thing can be done. Let's say I have my coffee
machine requires special beans and this be isn't is
almost complete then what my system could do
is it could go online to Amazon and purchase
these beans for me as well. So there are a lot
of things that I can do when I integrate this
with respect to various models and improve the overall
experience to a single user or a group of users
on the world itself such. Okay. Now, let's talk
about each one of One by one let's start with connect.

Now. The first stage of connect
is device virtualization because what you
need to First do is that you need to standardize
the integration of the device to the Enterprise platform, which is present on the flower. Okay. Now, it could be present
on a cloud it could be present on a so, but again, it's all going to be connected
through the internet. So what I need to do is
that I need to ensure that certain level of standard
is present on the device so that it can go on and connect to my Internet
of Things platform. Now to help you
understand this better, there could be a standard
power plug and there could be a power block which has
an inbuilt Wi-Fi support so that it can
connect to my lap. No to build a smart home system. I need the second power point because there only I would have
the access to control it over the internet and my system could integrate
with respect to the same. Okay. Now if I take the first
standard PowerPoint then what would happen is that I need to manually
switch it on and switch it on how in the second case
I could send a signal to it and In don't we'll switch it on
and switch it off.

So there's supposed to be
a level of standardization through which I can integrate
all of these devices to my platform. Next comes high-speed messaging. So now what I have done is that I have connected all
these devices to my platform but these devices in turn
generate a lot of data and this data is what is going to help
us understand better on how we can improve
the overall system and help and provide the user
with better experience. So for that we need
to To have high-speed messaging. Okay. This basically means that there needs to be
a reliable secure and a bidirectional
communication Channel between the devices and the platform not the purpose
of it being bidirectional is because you need to control
each one of them as well.

Let's say I want to switch
on the AC then the signal would be going on
from the cloud platform to the device. So this is how it works on. Okay. So every communication needs to be reliable
it needs to be secure and it needs to be
bi-directional as well. Moving on to the third point of connect you need
to have endpoint management. If I don't have
an endpoint manager, I have established a way through which all my devices
can connect to my platform. I also ensured that the data
is going to be sent from the device to the cloud and the cloud can send back
to the device as well through a secure Channel, but if I don't actually identify from which device
which data is coming and how this data
has to be processed.

Then it becomes a failure
of the system. This is where Management comes into picture endpoint management
basically helps you in managing the devices
endpoint identity the metadata and the overall life cycle
involved with respect to these things are such. Okay, so to put it quite simply
it basically helps you identify from which device
which data is coming and what needs to be done
with this data as well. Now coming on to the next
feature is analyzed and the first thing that you
need to do for analysis, is this reprocessing now if the data coming from the
device Not on a real-time basis, then my system
is often Williams.

There's no use if I tell my system to switch
on the AC at my home. And by the time I reach there if the AC is not even
turned on then it's a failure on my system. Okay, so real-time analysis of the incoming and outgoing
data and must be done. I have with respect
to different aggregations it filtering correlations
processing and so far. Okay now apart from this
what you need to do is that this is raw data that is being streamed
from all the things you need. Need to identify which is contextually
important information which is going
to be taken forward. So once I have
the irrelevant information, then I can even generate
composite streams of information which can be taken ahead
for future analysis and understanding as well. This is what your data
enrichment process does. Then you have events
to now in events to basically any information that you want can be queried and visualized from
the vast amount of data which is present on my cloud. Okay. Now this in turn
can also help me get a better insight and Analysis if I have all the enriched data
present on my cloud platform.

I have a tool which helps me identify
what is needed help me analyze. This data helps me visualize
it then definitely it becomes more useful as well. And when I have data coming from different things as such
this in turn can also lead to being a collection
of big data now when I talk about Big Data, it's not just a few GB of data as it's going to be
terabytes of data because because the data generated
from the things around us is that was and if you doing it
over a period of time then definitely it is going to grow
into a big data domain as well.

Now coming to the third feature of Internet of Things
comes Enterprise connectivity. So this is what I
was basically telling you about. Let's say I have a requirement from my retailer or even
an Enterprise organization which is present. It could be Amazon. It could be flipcard anything as
as any Enterprise organization which provides me a service. If I can connect to them
through this platform, then definitely My
overall process also becomes easier as well. Let's say this is
service provider. Okay, let's say there is
a leakage in my Plumbing or let's say there's some issue
with respect to my electricity.

Then it can contact to the
corresponding service provider. It can send them a detail and corresponding they
would be dispatched. This would in turn
reduce my effort of having to check the problem
having to call someone wait for them to come back all that gets reduced to minimum
required effort as well. Well, now how does
this communication happen? So for that we have rest API. Okay. Once I've integrated
my rest API with respect to the cloud application and my internet of things
then communication between the Enterprise communication
between the platform and the communication
between the things around us can be made more efficient and can be more easy as per the third aspect
is command and control if I don't have command and control on my platform
then it's awful noise.

Yes, I built a very great. Table something that's
quite extraordinary. But if you cannot command it if I cannot control it as
per my requirement, then the system
in itself is not useful if I cannot tell my door
in a smart home to unlock when I want it then it
becomes failure on my part. If I cannot control the AC
on my horse motto then again, it's a failure. So always the major aspect when you integrate
with respect to these things. The major thing is that you need to ensure there's
a huge control on system and you're able to Um and it as per your requirement
now this command could either be through a voice
based recognition. It could also be a message that you can send
through your mobile application and so forth as well when we come down
to the iot ecosystem.

There's no single
consensus or again. There's no singles
architectural design that's out there
which is agreed universally because each company
each organization each user for that matter has
different requirements and We look down to it. We can break it down to a simple
three level architecture where and we have
a perception layer where centers actually
gather the information from the environment around it. Okay. Once this is done
I'm going to use I'm going to pass this information
to the network layer the network layer in itself
takes up the responsibility of transferring this data from the sensors
to the next layer, which is the application layer
now here the main objective of the responsibility
is the application in itself delivers
this information to the end user or the When platform for
that matter this architecture can also be expanded
to a five layer architecture. Now when I talk
about a five layer architecture, it's quite similar here.

It's a the difference mostly
comes around with respect to the transport layer
the processing layer and the business
layer mostly here when we had three layers
doing the earlier task. We've just broken this down so that we have
an easier operation or a smoother system
for that matter. Now again, the perception
layer remains same when it gathers the information
from the sensors, but the transport layer
actually Transports the data between the sensor
to the processing center.

Now, this could be
through a wireless system. It could be through Bluetooth. It could be two RFID
3G NFC or any medium that I choose to once. The information has been
transmitted the processing layer comes into picture which actually stores the
relevant information analyzes this and again processes it as
per the users requirement. Now again, this could
employ various databases Cloud Computing Services as well as big data
processing modules to store this information as as well as process
it for that matter. Once this is done. I give the information
to the application layer, which is actually responsible for delivering Superior Services
to the end user for that matter on top of all of this stands your business lamp now
any device for that matter when it is working
on a large-scale environment a business layer
is usually used here. Now, let's say I'm working
in an organization where we using multiple pumps for different views features
in different locations for that matter a business layer
here actually monitors the complete functioning
of these parts.

You can also have these
in various cars as well. So what do I would note here is if a car is going to break
down then I also get an awareness with respect
to that individual car and it also helps me enable or help me reach out to
the closest customer care center so that it can assist
the user coming down to how I can process it again. This can be divided
into two segments. I have my cloud computing
based processing. We're in here. It's quite simple
once I have the information. I pass it on
to the cloud platform which then in turn also. Processes it and also has
various applications to deal with this process information
for that matter.

Now again, this is something
that I can do on a system which does not require
any immediate action and requires a large amount
of processing for that segment. But let's say I am in a system where I need immediate
response in those cases, I can go with my for computing now again
for computing is something that represents a layered
approach wherein we actually insert monitoring pre processing and storage with
the security layer. Between the physical
and the transport lab. Let me just go back
a few slides here to help you understand this. Now. If you actually look my for composedly comes
between these two layers when I add four new layers
for that matter. Now again, this is used in order
to make a system quite smarter or effective with respect to it
now between my physical layer and my transport lab, I have a monitoring layer. I have a pre-processing layer
a storage layer and a security line now to help
you understand this. Let's take in real-world
example out them.

Let's say I have
a complete traffic system. Which is built
on my internet of things. Now, let's say at one point. There is an ambulance that has come to a first signal
I detect this and what I do is that I allow the ambulance
to move from this traffic signal by giving it a green line, but what you need
to understand is if I'm using a cloud computing this message has
to be passed on to the cloud. This information has
to be then process and then correspondingly a map
has all stood to be created at the same time when I use a fog approach
what happens is that all the pre-processing and the storage happens
on the Gateway level itself. The information from the sensor
goes all the way to the Gateway there and it actually processes this
stores the relevant information and sends this back to the discourage
ponding sensors as well.

So let's say if there's
an immediate track that I can create
to the closest hospital. I would highlight all
the traffic signals to be green so that the ambulance can move
smoothly as well now security here is very essential because if I implement
this tomorrow anyone can actually try to manipulate this
for their requirements as well. Imagine there is a high High
Speed police chase happening and the culprit uses this in order to move fast
from the traffic signal. So this is something
that is really Ascension. Although there is a pro to this. There's also a con and this is how we try to overcome
this issue now talking about each one
of these new layers when I come
to the monitoring layer. What it actually does is it
monitors the power consumption it monitors each of these resources as
well as their response and the services that are running
on these resources. Now this in turn
helps me monitor or gives me a complete idea. Of which other services are which are the sensors
which are working? Where are the challenges? What is the power consumption
and how it works with respect to that same now once I have information
from these sensors what you need to understand is that usually you work with thousands of sensors
in a real-world environment.

Now, I need to understand which
are the necessary information. So I'm going to do a level of filtering I'm going
to do a level of processing and then I'm going
to apply a level of analytics to understand what is needed and what is not from
these information as well now. Now the temporary storage area
is something that I use in case I want to store
any relevant information. Let's say I'm creating a route
today for an ambulance as well. And this is going to be stored
in my temporary storage area. But this also needs to be used
in future scenarios. So once I am done
with this usage, I can also push it
onto the next transport layer which can send it
to any other storage system that has part of my environment. Now as I said security plays
a very important role, although my for
computing is something that makes my system faster.

It should not be easily. Inaudible now in
a cloud-based system. I have the assurance that it's not really easy
to break down the security. It's quite hard where there are
various layers of security which are part of the system. But when I have a fork system, it's essential that
this factor or the security which deals with the encryption which deals with the privacy
of the information. The Integrity of this
information is maintained. Now, there's also a very
interesting variation of this which is called an edge
Computing system wherein rather than doing all
these operations are After I have gathered
this on the Gateway, I can do it
on the individual notes or individual sensors as well
with respect to it.

So where I have edges
these becomes point for me to perform
operations on the data that is being collected. So that's the slide variation of our for computing system
is such next let's talk about the various
taxonomy associated with internet of the X. Now. These are the key Concepts
or these are the key layers which are present with respect
to most architectures. That's out there. As I said, this is a general
guide ER e Person on each system that's out.

There requires its own level
of customization requires its own level of approach
to solve that problem. But these always remain
the fundamental layers which are included in all the architectures
out there first. We have the perception layer, which is usually the layer where we gather the information
from the various sensors that's out there or we
use the various sensors which are required as
part of our system. Then we have
the processing layer where in we perform filtration.

We summarize the data
we again do a level of analytics on This data before we decide to send
this relevant data to the system that's above this. Now. Then I have a communication line of communications layer
is very simple as in here will
Define the protocols and standards as
well as the medium through which the information
has to be passed from my sensors to my main system as well middleware is something
that's quite essential here. What it does is that it creates
an abstraction as well as it makes my system work
much more smoother. Now what you need
to understand is that there are various
components in what hear me? That really helps me integrate the information
coming out from each of these sensors or each
of these individual systems.

Once it's present that I can pass it on
to my application layer where and I have various applications which help to improve
the overall experience of the user as well as provide much more accuracy and
efficiency to the information that's present now coming down. Let's talk about each layer
one by one now before I talk about
the perception layer what you need to understand is that one of the most
important aspects of Annette of things is context awareness. That is what you need
to understand with respect to the change of environment
is very important. And this is extremely impossible
without the usage of sensors as such now sensors in themselves are
very small in size. They again cost you very little and at the same time they
consume very little power again.

There are various constraints with respect to the factors
as the battery capacity and the ease
of deployment as well, but let's not go
into them as such. Now when I talk
about sensors again, we have various types of sensors as such one of
the easiest example of sensors that can be seen
on a daily basis is the sensors which are part of your mobile. You have a location sensor you
have movement sensor camera in itself is actually another sensor your microphone
your light sensor. These are all various important
aspects of your mobile that we use on a daily basis apart from this neural
sensors medical sensors, like the fitness bands
that we use Healthcare bands, which are used
for heart patients. In environmental sensors, which check the temperatures
around the environment make you aware of the changes
chemical or biosensors which are very useful
on a daily basis as 12 again infrared
sensors are something that's quite common as well. When we talk about RFID. This is something
that's really important or not. This is something that really gathers a lot
of attention with respect to it RFID stands for radio frequency
identification now unlike a traditional barcode.

It does not actually require
a line of sight of communication between the tags. And the reader
and can identify itself from a distance without even
a human intervention or a human operation for that matter RFID
is are technically of two types you have active
and passive active tags actually have some amount of power source
associated with it and passive sources do not have
anything related to it. And when we talk about
the RFID Technologies as well, there's near and far and near RFID reader uses
a coil through which we actually pass AC current
and Create a magnetic field. Now when we generate
a magnetic field anything that comes in its vicinity it
registers with respect to it. Now when I talk about afar
RFID it basically is a dipole antenna in a reader. Now this again propagates
an electromagnetic waves and tax themselves also have
a dipole antenna now again, these are something that's used
in various applications. That's out there. Now one key factor, which is associated with the perception layer
is an actuator now when I talk about an actual It
actually is a device which can affect a change
in the environment by converting any sort
of energy into another now.

This could be a motor
which is generating electricity. This could be a windmill which is converting
the wind outside to you to of electric form as
well in these are just some of the examples that's out there and actuators themselves
play a very essential role in the perception lab now, the next layer that we have
is the pre-processing layer. But before I really talk
about the pre-processing layer, let's actually try to And the limitations of trying
it to process everything that we have
on the cloud system, which is part of our ecosystem. Now when I talk
about this one of the key or one of the biggest challenges
for me is mobility. Let's say my sensors are on devices which are
in constant motion. Then it becomes
a really high challenge for me to pass this information continuously
to my cloud environment again, this could be true the challenge
of Transport layer.

This could also be due
to the challenge of power consumption
associated with it when my Smart device or when my sensors
for that matter are in constant motion
run constant Mobility. Then it cannot completely pass
all the relevant information on to the cloud. Now. This intern actually
causes a challenge for me to have some latency. This could also lead
to early 10 C with respect to real time processing
of the information that it gets as well.

Now if I'm working
on a critical system, then real-time information is
something that I will highly depend on and that becomes
a challenge as well now. Now if I really want to scale up if I want to use a lot
of devices then my cloud computing system
also needs to scale but there's always a chance
to increase the latency because I'm working
with multiple sensors or multiple devices. That's out there. Imagine today. I have a system with just
includes thousands answers, but let's say in a smart
home system There is close to about 10 to 20 thousand
sensors associated with it. So this is just
one small system. Imagine if I'm trying to build
a smart city in that case.

Is going to be hundreds of
thousands millions of sensors that's out there if my cloud computing system
cannot process this on a real-time. Then there's going
to be a high challenge with respect to that sick. And this is exactly where the usage of smart
gateways comes into a picture. This layer actually helps
me process my data on real type. It also helps me filter the data
on based on the priority or the requirement and creates a local copy
of whatever is needed or whatever needs
to be taken forward. Word now when I come
to the pre-processing layer or when I come to the features of for computing
for this matter, there's a very low latency because the information
does not have to go to the cloud system wherein the processing
needs to be taken up.

It always is done
on the Gateway level itself. This information really
is faster as we've seen in the previous example
about the ambulance now, I can also use distributed nodes where in the information
does not have to be other processing has to be on one single node
for that matter when I'm using Distributed notes
then I can also distribute the effort or the work that is needed as well when I'm on a mobile
environment as well. These Smart Systems
can communicate with the gateways present
in its closest proximity. It does not have to connect
to just one single Gateway.

If I'm setting up gateways
across multiple points in my city, then it makes it quite faster
and more efficient and this in turn can also lead
to a real-time response from the Gateway
for that matter. Once I have
a real-time response, then it is big. Taking my system faster and as in the previous example rather
than just clearing one signal. I can clear an entire path
for the ambulance as such now once I have relevant
information those which are necessary or those
which are really something that I need to ponder or I need to analyze can be sent
to the cloud system as and when as it's needed as such
so this is something that really makes my pre-processing layer
important and efficient and effective coming
to the next layer, which is the
most important layer.

It's out that which is
my communication lab now as your Internet of Things
environment actually grows. This is a compromise or this is a combination
of various heterogeneous devices which are connected
to the internet. What you need to understand is that these devices
in then self need to pass these informations
and some of the challenges that the communication layer
should actually address is with respect to let's say
first start off with addressing and identifying of each of these informations
wherein I know which Each device is sending
me the information. What is that device if I want to communicate back
to that device as well. How do I do that again? When it comes down
to the communication in itself? This should also not cost me
a huge amount of consumption with respect to power because if I save up a lot of energy with respect to
how the information is gathered, but I waste a lot of energy
in transmitting this information then I don't have a smart system
again information itself, which comes should
use various route.

Protocols which actually
require very low memory and should be very efficient
for that matter. If the information
itself needs to be bounced around different layers going
from different segments of your Echo System, then it needs to use
very less memory and this itself should be
very fast as well as seamless for that matter. Now when I come down to each of these components
for that segment, let's talk about NFC
or the near field communication.

Now NFC is actually a very short-range
Wireless communication. Technology through which usually
mobiles interact with each other or a distance of a few
centimeters for that matter. Now all the type of data
can actually be transmitted between two NFC enabled devices in seconds by bringing
them close to each other. Now this in turn is actually
based on the RFID concept and it uses a variation of the magnetic field
to communicate data between two NFC enabled devices. If again, we go down into slide specifications and FC
usually works The frequency band of Thirteen point
five six megahertz. But again, this is very similar
to high frequency RF. Id I'm not going to bore
you more with respect to the technical details will
talk about the next segment, which is your RFID and wsn
integration for smart objects. Now again, many a times what you need to
understand is the data from one single sensor is actually not useful
for monitoring large areas and complex activities now here what you're going to use is that you're going to use
various sensor nodes to it.

Interact with each other in this
also has to happen wirelessly. Now the disadvantage of a non IP technology such as
RFID NFC or Bluetooth is that it's range is very small, so they cannot be used in many applications wherein
large area needs to be monitored through many sensor nodes
deployed in various locations for that matter a wsn or a wireless sensor Network
consists of 10. Mm sensor nodes connected
using a wireless technology. They collect the data
about the environment and communicated to
the Gateway to Ice and relay the information to the cloud infrastructure
over the internet as such now when I come down to the iot network protocol
for that matter, usually what you
need to understand is that the IP for protocols
themselves can only be used for communication
of close to 20,000 device.

Now again, the internet
protocols used by these devices is something that's quite a challenge as well
because when you look at it, the predicted amount of devices that's going to be available
by 2020 in The Internet of Things domain is
Close to 40 billion imagine 40 billion devices
communicating with each other. Now if I don't have
a smart system or if I don't have
an effective low power system, then I cannot communicate or I cannot gather
the information from this now usually are low-power IPv6
is used for these Network on these communication which helps you in passing of
information from these sensors onto your processing or onto your Cloud
infrastructure now again, when I come down to the low
energy technology my main, With respect to communication
is always to ensure that low energy technology
is most probably used in this segment. We have your
Bluetooth low energy, which is usually
referred to as a ble and this was actually developed by the Bluetooth
special interest group.

Now what you need
to understand is that it actually has a shorter
range for communication and consumes lower energy as compared to
its Computing protocol. Now the BL a protocol stack
is actually quite similar to the stack used
in classic Bluetooth technology, however it As two parts, it has a controller
and it has a host as well. Now the physical and the link layer are
implemented in the controller and the controller
is typically an SOC or a system on chip
with a radio for communication.

Now the functionality of the upper layers again
are included in the host and BLS actually not compatible
with classic Bluetooth. Now, the next is a low-power. Y5. Now. Again, the Wi-Fi Alliance has
recently developed a Wi-Fi Halo, which is based
on your IEEE 802.11. It had standards this
in turn consumes, very less power than compared
to your standard. Wi-Fi devices also
has a longer range. Now this exactly is why it is
most suitable for The Internet of Things applications
for that segment. Now any device that supports Wi-Fi also
supports IP connectivity, which is very important
for an iot application for that matter now. The last is ZB ZB is also based on the IEEE
802.15.4 Station protocol and is used mostly in
personal area networks or pan. Now again, the range for zigbee devices to communicate is very small
usually between 10 200 meters and the details of the network
and the application layers are also specified
by zigbee standards as such unlike the ble
the network layer which is part of the zigbee provides
for multi hopping routing the when I come down to more details
about this agree Network.

I have three tabs which is an ffd full
functional device and RF. Reduce function device and
one zigbee coordinator as well. Now with this. I just hope you have
a simple understanding of how communication
is essential for The Internet of Things architecture and the various ways that you can implement
the communication between the devices as well. Now the next concept
or the next layer with respect to the iot architecture is
the middleware segment.

Now when I come down
to the Middle where one of the key challenges and one
of the key issues that comes into the picture
is the interoperability. Operate ability as well as
the program abstraction imagine. I have 40,000 devices
communicating with each other 40,000 devices may not all use
the same programming language or may not pass the information
in the same way as well. I need to build or I need
to have something that ensures that these devices
communicate with each other and there is
an abstraction maintained between the information pass
from these as well. Now if I have
multiple devices also what I need to ensure is that these devices
Independently discoverable and I can manage
each of them today. I need to be aware. If one single sensor
also breaks down because the information
coming from the sensor is extremely important as well when it comes
down to scalability. It is extremely useful because when I need to grow
my ecosystem this middleware really comes into picture if I can replace
an existing middleware with something I
can help me scale up, then I don't have to completely
V8 my entire ecosystem as well with respect to it
usually When I use a highly capable middleware, then it also lets me perform
big data analytics and Implement security
and privacy as well and this in turn usually
helps me communicate with my cloud computing and also context
detection the again when you come down
to the middleware segment, you need to understand with respect to
the various specifications of the application.

Which kind of database
is it oriented. What is the semantics
it's based on what kind of events can process and what kind of service
can it process or White ass but these are some aspects that you need to keep in mind while you're selecting
your middleware for your architecture. Now the last layer is
your application lab Now application is something
that really is what your end user gets or is what usually maintains or helps process
your information to the best that's out there. Now this in turn can be used
in different domains. It can help you achieve
different things. It can help you have
a smarter lifestyle it can help you have a smarter environment
your entire home system can be Managed with respect to an application
your car management can be done using application. You can build
an entire social life and entertainment system based
on a smart application now, although the end user
usually only looks at the application layer. This actually is the front face
of your entire architecture. Now with this. I hope you at least
have gotten an idea of what the entire skeleton of your iot architecture
comprises of now what we have discussed
here is just the skeleton.

It's always up
to the user to add. Muscles to it and complete
it with a skin as per your requirement Raspberry
Pi today has become so common that you can find it across
most households as well today. It has become one
of the most cheapest and common Computing device that can be found
almost everywhere, but let's actually go back
to understand the ideology which bought Raspberry Pi
into development itself.

Now Raspberry Pi basically was bought by the Raspberry
Pi Foundation to Introduced or to bring in the information
technology back to the schools where in students can learn how to program
from scratch the growth of technology today
has grown to such a level that everyone today has ease of access to do
anything on a computer but back in the early and late 90s and 2000 for using
a computer you needed to know how to program and how to work around
with respect to it. So this in turn have to build a very strong foundation
for programming knowledge And with the growth of UI
everything has become so easy that today you don't need
to learn programming to do much. But at the same time
this has made it harder for people to identify and understand good programmers
from those who are not. So in order to
build a generation which starts with a very
strong programming foundation and fundamentals. The main ideology
was to introduce or take back it to the basics and make it accessible
across every school as well.

Again, as I said, it was introduced by
the Raspberry Pi foundation in 2012 as watching. The moving forward what
exactly is Raspberry Pi now. This is one of the questions
most of you would have a cross your mind as well because you
might have heard about Raspberry Pi body
might still not have a Clarity. So let me help you clarify
that right away. Now as per the definition
Raspberry Pi basically is a series of very
small single board computers, which actually have
additional features as Bluetooth Wi-Fi USB capabilities
General input Output ports and so forth now it basically is a very small
low-cost credit card computer which has actually
can be plugged into any monitor as well as
you can include a keyboard and mouse and it
increases the opportunity for people to explore
learn and understand how to program as well.

Now the latest version of Raspberry Pi
is Raspberry Pi 3, which was released
in February 2016 as well. Now Raspberry Pi
basically is a combination of raspberry operating And Pike which basically stands
for Python programming language. But before we move forward, let me just show you
a very simple video which Raspberry Pi has put out so that you can understand the ideology of Raspberry
Pi Foundation as well. This is a Raspberry Pi it's
a credit card sized computer that costs around 25 pounds designed to teach
young people's program and is capable
of doing all kinds of wonderful things
back in the 80s kids had to learn
how to code computer too.

You use them and as
a result these kids grew up with an inbuilt understanding
of how computers work. Now, we need more programmers than ever before so to deal
with this problem. Some clever people came up with the Raspberry Pi
to reignite the spark. It runs minutes
a free operating system from an SD card just like
the one in your digital camera and it's powered by
USB phone charger. You just plug in a mouse
and the keyboard. To a TV or Monitor and you're ready
to go in schools. Not only is best berry pie a great way to learn programming
skills as part of ICT. There are also dozens of cross-curricular applications
next science and music and all over the world. People are experimenting with Raspberry Pi's and
attending raspberry jam events where people of
all ages are learning what can be done
with a Raspberry Pi since the first
Raspberry Pi was ship. We've seen examples of people
using the pipe in a variety of amazing interesting projects taking advantage of its size
portability cost programmability and connect ability.

And whether you want to learn
to make games build robot or even teach a bath parachute with Raspberry Pi
the sky's the limit. So I hope you guys had
a great learning experience with respect to that. That was basically the ideology
of the Raspberry Pi foundation on introducing Raspberry Pi
into the market as well moving on some
of the capabilities that Raspberry Pi
enables you to do is that it helps you to browse
the internet as well as what complete HD videos
on the same device as well.

So all you need to have
is a HD supported display as such now apart from that even basic operations
like making spreadsheets. Creating words presentation
all these can be done on Raspberry Pi and you
have a huge set of games that are available which can be played
on Raspberry Pi making it quite interesting and easy as well for people
to enjoy the component as well. Then you have various
add-on capabilities, like infrared cameras
and security system, which can be built
keeping Raspberry Pi as the core Hardware as well. Then you can also use
many music machines as well as detection
of weather stations, which we actually had done
in our previous session.

On as well. Now. These are just some
of the top capabilities that I have picked up
from the list Raspberry Pi today has become one
of the biggest component that has enabled
users to achieve and create a lot as well today. The capability of Raspberry Pi
is restricted just to your imagination whatever you
can imagine can be done using Raspberry Pi given the amount
of effort put into that. Mmm now moving on let's look
The Raspberry Pi Hardware as well before that. Let me show you how I would be using
a Raspberry Pi as part of this tutorial session. So let me just give
you a simple overview of the component as such now
what you basically see is that the Raspberry Pi Hardware. So let me just switch over the camera and let me show
you the Raspberry Pi now here what you're seeing is the
Raspberry Pi 3 Hardware as such and this is your processor
and system on chip, which is an adrenal
a few P3 processor.

Now two important ports
here is the CSI. Which is the
camera serial interface where you can connect camera
directly to the Raspberry Pi and the DSi Port which is
the display serial input Port. Okay. Now, let me just flip
this over slightly. And if you see this
is a 2.5 M. M– micro USB connector. So your standard mobile charger
can be used to charge the Raspberry Pi and this is a standard
HDMI port for display. So your standard
TVs and monitors which have an HDMI support
can be used to become a video interface for that. Then you have an audio jack, which is used to connect
your audio input now, let me just flip the slightly
over and let me zoom out a bit.

Now if you see we have
an Ethernet connector following which there are
four USB slots as well. So when you see here, there's a 40 pin General
input output pin present here. So this is something that's quite interesting and configurable from
your Raspberry Pi a software where you can configure for what
each purpose pins can be used which will be silly little head. Now the final thing that I
want to show you is behind here when you flip backside, so there is a micro
USB slot present here. This is mainly to insert
your memory card. And when I say memory card, I would generally recommend
at least a 16 GB memory card.

This is mainly because the Operating system
and itself is about 4 GB and if you use an AGP, then what happens is there is
very Less storage space for your operating system
to work on as well. So 16 GB memory card
would be really helpful. And one thing that you want to see is
this is an Evo class, which is something similar
to a class 10 memory card. So if you get a memory card, make sure it's at least a Class
A Door class 10 memory card so that you can have
high disk read and write processing
now coming back. Now bow your head let's just
skim through the various changes that has happened
over the hardware of Raspberry Pi now.

We are not going to devote
too much time into this because this is a completely
in detail session how I would be stopping
at these slides for 10 seconds. So if you wish to know more
you can pause the video and get a complete look as well. talking about the processor
the first generation of Raspberry Pi initially came with a broad
Camby CM 2 8 3 5 SOC and it basically was similar to the first
generation smartphone chips and the architecture that was used also was
an armv6 architecture now the over the years
Raspberry Pi 3 has grown a lot and today it has a capability
of 1.2 gigahertz which basically is
because of the a arm cortex a53 64-bit processor it is
considered to be 10 times faster in comparison to Raspberry Pi wow now I'm talking
about the change in raspberry pi over the years as you can see here the various
models have been listed and the architecture change has also been mentioned
here as well so in case if you are interested in Rome
or you can pause the video and take a look at this now when you come to the memory
the first model of Raspberry Pi came with a 256 MB RAM and which basically
were shared by the GPU but today with Raspberry
Pi Version 2 and 3 you have four times that you have about 1GB of ram which again is shared
by the GPU as well.

Now the default split was at hundred and ninety-two MB RAM
for the CPU basically, which was more than
enough to play a full HD that is 1080p video
or perform simple 3D operations, but again, not too
complicated operations as well. Now moving forward when you look at the networking
capabilities in terms of networking capabilities, the Model A of Raspberry Pi
did not have any such features, but from model B
of version 1 itself, you had an ethernet port which was introduced here
and from version 3.

You also have Wi-Fi and Bluetooth capabilities
introduced here as well. Now talking about
the peripherals in Raspberry Pi there are basically
four USB ports. Now, this has been introduced in
model B version 1 plus onwards and today you have a lot more that you can do with respect to
that even audio input ports and audio output ports
have not Over the years but the on-board storage has changed a lot
with respect director. Now again, when you look at the video
capabilities video controllers, basically here you
can watch complete HD videos but Raspberry Pi does not have
a hatch 256 decoding Harbor but the CPU in itself is
way more capable and helps you in decoding
the h26 included videos through software operations now in terms of GPU the GPU in Raspberry Pi 3 runs
at a higher clock frequency, which is about 300 or 400 in comparison
to the previous versions which is at about
250 six megahertz.

Now in terms of video input
you have a 15 put CSI connector that has always been present
with the Raspberry Pi and we output has changed
over the years. You have a HDMI port
you have a DSi port and now you also have
a 3.5 mmm trrs Jack as well. Now in terms
of the connector capabilities. There are 17 pins of the gpio port switch
can be configured as per your requirements as well. No, moving forward. These are the various
details with respect to the general input output pin. This data has been
taken from Wikipedia. So in case if you're looking
for more information, you can definitely
check out wiki space or the official Raspberry
Pi documentation as well now coming down. Let's begin the Raspberry Pi
installation process here.

But first, let me help you understand
the different operating systems that are available at present. Okay Raspberry Pi
in itself supports. Has multiple operating systems
as such but we will mainly be working on raspbian. Okay. So these are some of the most
popular operating systems supported on Raspberry Pi so you have risc OS you have
FreeBSD operating system. You have net BSD operating
system Plan 9 is again from Bell Labs as well as
Windows has its own Windows 10 of iot version. Okay. So for this session, we're not going to go
into the Windows 10 will stick to the core Raspberry
Pi operating system now for downloading
the operating system. You can go on
to the original site. That is Raspberry Pi Dot o– r– g– And there in the downloads tab, you can download
the operating system. Let me just show it to you. Okay. So this is the Raspberry Pi
home page and here if you go on to the download section, you can download
the operating system.

Now if you are starting off
with Raspberry Pi an Internet of Things trust me. This is the best place
that you can find a lot of informations
with respect to it. Okay, most people actually published their details
with respect to the projects that they're working
many popular projects are also available. You can find a lot of help as
well as good information here. Okay. So this is definitely
the place to go to if you go on to the download section
here, okay this I'll show you 2 options you
have nodes or you have raspbian. I would recommend
that you go with notes because this is a complete
package with respect to the different operating
systems as such so here again, you have noobs and Loops like so
my recommendation would be you download notes and make sure you using a 32 GB memory card with this
would be really helpful because it gives a lot of memory
for your operating system.

So in case if you're going for a 16gb or below I
would recommend you go with the nope slide, but make sure you keep the bare
minimum of 16 GB in case if you working with Raspberry Pi
but do not mistake me. When I say use
a 16 GB memory card. You can install it
on an 8GB as well. But again, the operating system
has less memory to work. So at least go for 16 or higher 32 is
what I would recommend. So once you download
this ZIP file, or you can even download
it by a torrent. Okay, but I would recommend
download it as a zip file. Let me show you the file. So this is the noobs file. Let me extract this. Okay, it may take some time. It's about a 1.5 GB file. Okay, the lights were seen as
slightly lower in comparison, but this is something
that I would recommend in case if you're working
with Raspberry Pi.

Okay, so I have
my noobs folder here. So what you need to do is that you need to copy everything
inside the nude photos and then paste it
inside the SD card. Okay, make sure you are
not directly copy pasting the folder
that you have extract. So what happens is
if you do that, it does not actually recognize
the operating system as part of the Raspberry Pi
so copy everything that you've extracted
and then directly paste it inside the SD card. Now again, this
is why I recommend that you use a high
speed memory card because in case if you are not using it then what happens is
But it takes a lot of time with respect
to fetching the data. Okay. Now as I had mentioned if you're going for a memory card
for your Raspberry Pi you can use something
like a 16gb at least and make sure it has
a high transfer speed.

So this in turn will give you
a lot of memory area to work around with as well. As I would recommend
you take something like a class 10 memory card that is available
in the market today. So these have a very good read
and write speed ratio. So definitely this is something
that you should consider while you're getting a memory
card for your operating system. Okay now Once you're done
copying with this, let's go on to install
this memory card onto a Raspberry Pi and let's
begin the installation process. Okay, so now we've
successfully copied all that is needed
for our operating system.

So safely remove this make
sure you rejecting it safely because sometimes
what happens is if you do not see if rejected the
files get corrupted before you load it
into your Raspberry Pi this is certain issue with respect
to the memory cards. So just eject this. Okay. So this is my Raspberry Pi and
if you actually flip it over. This is the slot where you
have to insert the memory card. Now, we've copied
the noobs folder into this memory card.

Okay, let me just insert this
into this and let's begin with respect to
the installation process. Let's begin installing
this memory card onto my Raspberry Pi
and start with the setup. So, let me just turn the
on my Raspberry Pi. Okay, so this is a screen. I'm getting by default. Now what happens is the
installation steps initializes. So the Raspberry Pi
is getting loaded. Now there are
two operating systems that are present here by default
and we want raspbian. So let me just select
raspbian and click on install option present here. If you see here it
basically is telling me that it requires 4.5 GPA. So this is why I was recommending you
to get at least 16 GB or more because if I have an 8 GB memory card if 4.5 GB goes off with
the operating system itself, then there's not
much memory left for me to work around with now.

Let me just click on install. Just before I do that in case if you are using
a different language, or if you want to use
a different keyboard as well, you make sure you're
specifying that okay. So there are written language
is present here. So choose the
corresponding language as per your requirement. Once you selected
that description install and this is just
basically going to ask you whether you want
to format your data and install the operating system
on top of this. So click on yes, and the installation process has
begun now it may take some time. So I request you
to be a bit patient because this is an Operating
system installation process, so please be a bit patient
and hope you have fun mean wire. So now as you can see the
operating system installation has completed successfully
once you hit on okay, it's going to ask me whether I want to reboot or it
automatically reboot as well.

Okay. So yeah, it's automatically
rebooting at this point. Okay. Now as you can see the Raspberry
Pi operating system has successfully been installed. Okay. So this is what your Raspberry
Pi operating system would be looking like okay. So this is raspbian
as such so there are different operating systems
that are available today for you to install that we
have discussed already now that we've installed
raspbian on our system. Let's look at some
of the accessories which can be used
with Raspberry Pi now one of the most popular and interesting accessory to
Raspberry Pi is the sense hat. Okay, so that basically is
a hardware attached on top.

There are various hearts that are available
but censored is the most popular because you have various
onboard sensors present here. You have a temperature humidity and pressure sensor present here
as well as a gyroscope and a joystick also present
here apart from this. The reason that it
is quite popular is because it has an 8 cross
8 LED Matrix display that is present to him. So let me just switch over and show you the sense
hat component as well. And okay. So here you can see
the sensor know how it is slightly different from
the the other accessories is because it's got an 8 cross
Aid LED Matrix present here, which can be used
for displaying various things and we will also be seeing
how you can display this as well now coming on
to the other components here. Now if you see here, it's already got
multiple sensors here. It's got an accelerometer and the gyroscope
meter present here.

It's also got we just
this part the axe low and gyrometer present here. So you can see it's got
labeling as well. Then you have
a humidity pressure and temperature sensor
on board with respect to this and it's quite interesting
and useful as well. Now one of the easiest things
with respect to this is that it can directly
be placed on top of the Raspberry Pi's gpio pins and thereby making it quite easy
to assemble it as well. So it directly sits on top
of the gpio pins as well.

So this is something which makes the entire Raspberry
Pi ecosystem quite easy and effective one other
interesting key point or factor that makes the sensor
quite interesting is that it's gotten
on board joystick as well. So in case if you are a gamer
and you want to try out the games on Raspberry Pi you
can use this choice to catch. As such now another additional
component that most people use with Raspberry Pi is the camera
now in 2013 itself one year after Raspberry Pi
1 was launched. It had introduced
the Raspberry Pi camera along with the firmware
update as well. Now the r a spy cam is
basically an 8 megapixel camera and can directly be connected to the Cs airport present
on the Raspberry Pi itself.

Now, it's also very interesting and can record up to
thousand ATP videos as well. So moving forward. Let's also look
at the infrared camera. So this is a very
interesting thing. So this was something that helps you capture
video in infrared mode and is called pine oil. Okay. So again, these components
can be bought online and is one of the most easily by now the final accessori
announce the most interesting and essential accessory
to the Raspberry Pi is the Gert board. Basically it is used
for educational purposes and it helps you expand
the operations done using the general
input output pins here, so, Using this you
can connect to various LEDs which is Analog Devices sensors
and much more.

This also helps you connect to Audrey know which is also
another DYI Hardware device which has gained a lot
of popularity but in comparison to Raspberry Pi order, no is still growing
Stitch moving on. Let's begin with
our sensor tutorial and what we'll be doing is we'll be exploring five
different demos to understand how the sense had component
can be used effectively. Now the first thing
that we'll be doing is we'll Implementing
a very simple code and we'll be trying
to display a certain letter on top of the sensor. Okay, so I'm going
to display p&d but the value of that color is going
to be generated by random.

Okay, so let me just run
you through the code that's present here. So the first line is
from censored import sense. So what it basically is doing is that it's helping
you import sense at and establish a connection
to the censored component. We're going to use time
for mainly sleeve function. Oh and random for generating
a random integer. Now. What I'm doing is that I'm initializing
the censored which is sense equal to sense at basically initializes it then
what I'm doing is that I'm generating
a random integer between the range of 0
to 255 now for those of you who would have guessed
why I'm doing this.

Definitely this is because the RGB value
lies in this range, so it's somewhere
between 0 to 255 then what I'm using is that I'm using
a censored function which is show later and then I'm specifying
which It means to show and I'm going to specify
the color combination. So this is the RGB
values present here. Okay, so it's going to show
the letter e and it's going to create a random input
with respect to that same.

Okay, then it's going to sleep for one second again
generate a new random integer and then it is going to show D. Okay. So again, it will sleep
and then it's going to clear. So let me just show you
this to you practically. So now what I'm going to do is that I'm going to connect
to my Raspberry Pi. Using VNC Network. So it's virtual Network, which I'm connecting it to
because it's not quite easy for me to record the video on the Raspberry Pi so I'm going
to use VNC server for that and I'll just give you
a simple idea of how you can connect to VNC server
to your Raspberry Pi as well. Now one essential thing that if you are connecting
to the VNC server, then you both need to be
on the same network.

Okay. So what I've done is
I have used a hotspot connected both my Raspberry Pi
and my laptop to the Network so in case you are wondering how to connect to your Raspberry
Pi y remote server, this is how you do it. Just go to your settings
go to preferences. You have Raspberry
Pi configuration here. Now in your interfaces make sure
that VNC is enable. Once you've done this then
VNC server gets enabled and onto your system
just download VNC server and VNC viewer and
you can connect your Raspberry Pi quite easily. Okay. So let me just show you the code which we're going
to be executing now, it's the same that we
have seen earlier. So, let me just make
a small modification to this. So this is awkward again as we have seen we are first
initializing the censored with sense equal to censored then we're generating
a random integer and then we showing a letter e on that so let me
just change this. Let me just set it to 0 and let
me just copy this once more and I'll also show a third
combination here as well.

So I'm just generating
a random value between 0 to 255 and I'm displaying
based on that color. Letter e d and f okay, so let me just save this once
so let me show you the output that is going to be
displayed on the sense that as well. So so let me just
execute the program. Okay. Now let me just switch
over to the censored so that you can see the output.

It's a ready green d
and a blue f as well. So this is what So based on the inputs that I
have given it has displayed a certain letter on the censored
LED display as well. So let's go back
to our presentation and look at the next program
that is involved here. So the next program basically
is going to display an image. Now what it does here is that it basically is going
to display an image that Gives you a complete idea of the various color
combinations possible on the sense at as well. So what I have basically done is that I have identified the RGB colors red orange
yellow green blue indigo violet and E stands for empty, which is null. Okay and based on this.

I've created a
random Matrix here, but each of these values defines
for a pixel of the sensor now as I have mentioned
to you earlier, this is an Eight cross
it led Matrix. So each of these values is for one of the
individual pixels themself and with respect to how they
start the numbering starts from left top position. So accordingly it goes
in a row by row, man. Okay, so let me just show you
the output for this as well. So this is our program
and let me execute this and show it to you. And now let me just switch over
to the Raspberry Pi. To here you can see
the different color combinations that are present
on the Raspberry Pi sensor. The first row was
left completely empty. The next row has
to our values present here. So this is how it
has been defined. If you notice the code here, there are two are following
by three empty spaces.

And before that. Also, if you can consider
three empty spaces that is one rule. So every specific
value is pertaining to one specific row as such now
coming back to our presentation. And so the third one
is quite interesting. What we're basically
going to do here is that we're going to rotate a letter based on the different
orientation of the screen. So let me show you how this is done rather
than just tell it to you. So what we basically
going to do here is that we're going
to rotate a letter J on different angles as well. So we've defined
the different angle 0 90 180 270 and these
are the various angles which is going to rotate for. Okay. I'm going to run a for Loop where it rotates
the same on different. Angles as well. So let me just show you
that so just let me add since dot here here. Now. The reason I'm doing
that is mainly to ensure that the sense that is cleared
after the rotation process.

So let's execute this. Let me switch over
to the Raspberry Pi and if you see here
A Jay has been displayed and it's rotating. Okay, it has stopped. So let me just rerun
this once again. So what is happening here is that I'm rotating
the letter J by 90 degrees and it's completing to complete
circles on the Raspberry Pi. Okay, so it's a very
simple thing but it's important that you understand
how this is done because what we're
basically doing is that we are setting
the rotation using the sensor. Okay, and then we're sleeping at point zero five
milliseconds as well. Again, you can increase
the delay here. You can change the letter here. You can even change
the angle to understand how it works as well. So this is something that you
should definitely explore about and get a better
understanding with coming down the next and most basic thing that you can do. Using sensor is that you can measure the temperature
pressure and humidity. So we've already
tried to do this in our previous session as well where we've measured
the temperature the pressure and the humidity now here
I'm just rounding it off and based on a specific value.

I'm going to ensure whether the display
is going to be red or green as well. So let me come back to my senses
at let me just open the code and we will modify this on the go to get
a better understanding. Let me explain. In the code once again, so first I'm establishing
a connection to the censored then I'm running
an infinite Loop where I'm getting the temperature the
pressure the humidity. I'm rounding it off and
if the temperature is about 36, so this is just a value that I have set then
the background color should be green and the color of the text
should be complete wide. Okay. So this is a simple modification
I have made else in normal situation if it is less than 36 degrees
then what it should be.

Is that it should have
a background color of blue and the text color
should be yellow. So this is basically to help me
identify the different ranges. Then I am creating
a message variable which is storing
the following format where temperature is equal to temperature value pressure
is equal to pressure value and humidity is equal
to the humidity values. Finally. I'm going to show
this message on my sense at LED display screen. So let's just see how this works
and execute the program. So let me just execute
the program and let me also switch over
to the Raspberry Pi. So here let's begin
with the execution of the code.

So now you can see by default. It is having a blue background and the text is
actually in yellow. Okay, so if you would have
noticed the temperature is about 34 degrees Centigrade. So to this letter or Scroll once more
let's just validate the value of temperature. You can also print
this into the screen. You can also send it
via an API and much more. So if you can see, it's thirty four point
two degree Centigrade now to this what I'm going
to do basically is that I'm just going
to introduce a hot water source.

Okay, so I'm just trying
to raise the temperature here. So let me just shift
a little bit and please keep a note
on the temperature value. So the temperature
has started Rising. So it is taking some time. I think the water
has cooled down a bit. All right, so it's started
now the color background color has changed from blue to green and the text color has changed
from yellow to white as one now. These can be used in critical
measure environments as well. So let's say you are
in a situation or an environment where you need to have
a constant Monitor and constantly be aware with respect to the environment
change in example, like space or any other environment
that you're working with.

Definitely. These are certain things
that can really be important and helpful as well. So Coming back. Lets us. Look at the last program
of the sensors tutorial, which is basically detecting
the motion of the sense that now what I'm basically
going to do here is that I am going to rotate
my science at and I'm going to identify the value of
pitch roll and yaw on basically, these are the orientation
with respect to the x axis y axis and Z axis and this is just from
the orientation of the sense that as well. Now this is mainly done
using the gyroscope but to get a better
understanding and more precise. Value will also try to include and incorporate
the accelerometer as well. So let me come here. Let me just show
you the program.

So this is the program as well. So let me just stop
the execution here. So as I had mentioned this is going to run
infinite number of times because the while statement
here is indefinite. So let me just stop
this and let me just run the orientation program and Let's just see
the default values of pitch yarn and roll first. So now by default if you see pictures
about zero role is about 96 and Ian is about 0 itself. Now, let me just switch
over to the sense at and what I'm going
to do parallely is that let me try radiating
the value of the sensor as well or let me try rotating
the sensor to give you a better understanding of
how it works simultaneously.

You can also see the change
in Pitch Ian and road. So if you see Here
I'm slightly lifting it and the value of which
has risen from zero to six role also has changed
Ian also has changed. I'm going to try tilting
it same pitch roll and yaw on also has changed. So I'm just filling it with respect to various accesses
and you can see the change here. You notice the changes I
definitely hope you do. Okay. So now let us actually stop
the execution of this program because this is also
an infinite Loop and to same orientation program. Let us actually
try to incorporate the accelerometer and understand how more precise we can make now instead of just
taking the pitch roll and yaw on I'm here going
to directly take the value of acceleration here.

We have taken the value
of orientation and here we're going to take
the Of Aksum duration, okay how basically the first is with respect
to the gravitational force that acts on this. So now let me just show
you the code here. Now again, what you need
to understand the difference between gyro measure
and Axle row measure is just that its senses
both the static as well as Dynamic change
with respect to that but your gyroscope
many measures the rotation of a specific device as such.

Okay, so let me just execute
this program as well. so let me just first begin
by clearing the screen and then we'll execute
the code once again, so let's just execute
the acceleration code to get a better understanding
and simultaneously what I'll do is that I'll just show you
how the change with respect to the axis is or how you if you change the Raspberry Pi how the value will also
change so by default if you can see
the value of x is 0 the value of y is also 0
and Z is 1 so now what To do is that let me Begin by slightly
rotating the Raspberry Pi now if I change the Raspberry Pi into a vertical
position like this. Okay, so it's a perfectly
vertical position. But if you notice the value
of x it is become minus 1, okay, why has become 0
and Z has become 0 same time. If I rotate it in such a manner. I'm just keeping it
on different axis the value of x becomes plus 1 instead of
minus 1 same with respect to Y if I change it in such
a horizontal way it is minus 1 and if I change it in such a manner then
it becomes plus one.

Okay. If you flip it completely
over then the value of Z becomes minus one as well. So if this is the vertical
position then the value of Z remains one, I hope this is clear
for you guys. So again, these are
all different parameters today what I have done
as part of this is that I've just
help you understand how you can explore
the various parameters and various components that are associated to the Raspberry Pi
censored as well. Now what how you use it and what you use it
for is completely left you these are just some
of the basic things that you can do
using Raspberry Pi the limitation of
Raspberry Pi stops where your imagination stops. Okay, now that we've installed
raspbian on Raspberry Pi it's time we begin with the demo
for this session. Now, what we're trying to do is that we're trying to build
a weather detection system to get the real
time weather analysis when we talked
with real term analysis.

It basically is the pressure
temperature and humidity. And what we want to do is that we want to get a live
mobile notification for this. So for that will be first
using censored board which will help us measure
the various metrics like temperature humidity
and pressure. Iran to a Raspberry Pi then
we'll use Raspberry Pi to transfer this data
and display it on the sense that as well. So we'll just be displaying
the temperature as of now on the set. And finally we'll be
using insta push API and Python program through which
we can send this notification across the Internet
to our mobile application. So let's begin
this demo part first. Let me show you
what's and satis and how you can assemble sense
at on Raspberry Pi. Okay. So this is my Raspberry Pi unit and this is That's what
I was referring to.

This is sunset boat. Okay. Now if you see this is
a simple additional board that you can add on top
of your Raspberry Pi. Okay. Now it's quite simple, but how it's different is that in comparison
to your Raspberry Pi there is a neat cross 8 digital
LED display present here. So you can use this for various different purposes
as per your requirement. Okay. Now, it's simply sits
on top of the Raspberry Pi. Okay, just make sure
the alignment is correct.

And once you've done
with that just push it on top. And the pins would
merge accordingly. Once you do that you
can just place the four screws across the different ends
and tighten it up. And once you're done with this, you can integrate
and use the censored for various different purposes. We will use sensor to measure
the temperature the pressure as well as the humidity
across in this room that is present. Okay, so this has
different sensors present on it and we'll be using them
for today's demo. Okay. So let me just put this up
and once it's all set up.

Let's go back to our demo and let's begin
with understanding the programs before we begin the execution. Okay. So moving on now that you've understood
about Raspberry Pi's and Saturn V. We also install
raspbian on our Bye, let's move forward and start with respect
to today's demo part. So again going back
just to remind you. We trying to create
a better control system wherein we try to measure
the temperature the pressure and the humidity
around the sensor as such. Okay. So the first thing we're going
to do is I let me just connect to my Raspberry Pi. Okay. So this is
my Raspberry Pi interface. Now. Let me just show you
the program as well. So I've divided the actual
program into three parts so that it's easier for you to understand how this program
works as such now, the first program that we are going to execute
is the sensing environment.

So this is a simple program that's going to sense
the environment variables. That is the temperature
pressure and humidity. And then it's going
to correspondingly display these values on the censored
LED display panel. Now, let me explain this program
to you one by one now firstly we need to import the He boosts
the values on the censored. So for that we're going
to use this line from sense underscore hat import sense
at so this will give me the corresponding values from the sensor
to my Raspberry Pi interface. Then I'm also importing type. Now. The main objective of time is to help me keep
a log of all the values that are measuring. Okay, so that will be
seeing little ahead.

After that. I'm going to assign
the censored values to a variable known as sense. Okay, so through this variable. I'm going to correspondingly
relate to all the values coming. From the sense at okay
moving forward we have written a while loop
and this is an infinite while it's going to continuously measure the temperature
pressure and humidity and is going to correspondingly
be displayed on the sense that as well. Okay. So let me help you understand how the temperature humidity
and pressure are measured. Okay. So what you need to do
to measure the temperature is used the function sense dot
get underscore temperature. So this function that is get underscore
temperature will give me the temperature value measured by the sensor
in degree centigrade.

It and hear what I'm
basically doing is that I'm just converting
it into fahrenheit. Okay, so the value in degree Centigrade into
1 Point 8 plus 32 is just a Fahrenheit representation
of the current temperature. I'm using a round
function to round of the corresponding value. I don't need any decimal
point values here. I want a whole number. So what I'm doing is that I'm using a round function
and once I have the temperature then I'm going to be storing it
inside a temp variable. Okay. Similarly. We are going to use
sense not get humidity and sense dot get
pressure to get both. The humidity as well as pressure and store it in humidity
and pressure variables are such. So basically I have
all my three variables that are needed now. What I'll do is I'll create
a string called message. Okay into which I'm going to
store the temperature humidity and pressure with
a specific notation.

So T is going to be equal to the temperature H is going
to be equal to the humidity and P is going to be equal
to the pressure. Now comes the part where have to display this value
onto my sensor display screen. Okay, so here I'm going
to use the function. Sense dot show
underscore message. So this is basically
a call through which I can send any message to
my sensor display screen. Okay. Now here I am just passing
the message with respect to the temperature humidity and pressure variable and then I'm also
defining a scroll speed.

Now. This is something that
you can play around with if you want to have
a fastest-growing you can modify it. I have chosen a 0.08 scroll
speed then the other two factors are the font color
and the background color. Okay. Another text color I
have set as 200 240. Tea and 200 now
if you can guess these are basically the RGB values for
the corresponding text color. So this is something
that I have said as per my requirement you
can play around as well as background color is something that I have set to 0 0 and 0. Okay. So you have complete freedom to modify this as
per your interest. I would definitely recommend
that you try playing around with this to get a better feel
of how it works. Okay. Now what I'm doing is that I'm putting my system
to sleep for four seconds.

This is basically to introduce a delay between the
measurement carried out. On the sensor now, if I don't do this since it's a continuously
running infinite loop it's going to keep measuring
at one after the other. So I want a simple delay
between the measurement. So I'm putting the system
to sleep for four seconds. After that.

What I'm doing is
that I'm opening a file called weather dot txt now here. I am going to create
the log into this file. I'll take the present time and
then pass the message as well. So these both with respect
to the present time as well as the message are going
to be stored in form of a law.

Okay, so in case in future if I want Want to refer
to the measurement, this is something
that will be really helpful. Finally. I'm also going to print
message on my console. Now. This is something just
for our understanding as well. We'll be seeing it
on different places will see it on the console will see it on the sensor as well as we
will be seeing it inside the log file as well. Finally. I'm closing the log and then I'm putting my system
to sleep for 5 seconds. So these sleep delays
are just to ensure that the consistent values
are being measured in regular interval and there is no hindrance
with respect to Okay.

I hope you guys
are clear with this because I'm going to go on
to execute this program. So let me open my console. Okay here let me write
the command for executing a Python program
and it's very simple. It's just python followed
by the filename. Okay. Now in our case
it's sensing environment. Okay, so let me execute this. And now if you see
the values are being computed and on the sense that the values are being shown as well so you can see here
the change with respect to that. Okay, firstly it showed me
all the temperature humidity and pressure and now
it's already come on the console as well. Similarly the going to have
a simple delay and then you can Already it showing me
the next values on my sensor and it's going to be
stored in a log file.

And then it's going
to come onto my console. So very interesting. Right? So definitely you can play
around with respect to the font. You can play around with respect
to the background color as well as if you are interested, you can try bringing
different temperature items near the sensor to see
the variation with respect to that as well. Let's say if you have
a glass of hot water and you bring it near the sensor the temperature value will
correspondingly change as well. Okay. So this is something that
you can really Experiment on and have a good understanding
of how things work.

So let me just close this program and let's
see the log file. Okay. So this is my weather
dot txt file. So I have taken different
temperature measure variables. It's been log from a long time that we've been
trying this out on. So definitely there are
a lot of values here. Okay. So let me just show
you the latest value. So this is a range of values that I had just tried
out some time back. So all the log
all the temperature and pressure log are being
stored here continuously. Okay when you feel comfortable.

This is the latest log that we have just created with
respect to the three values. This is the current
status as such. Okay. So again, this is something
that you can experiment on. I am just told it because of
my future reference as well. Okay. So I hope you guys have got
a simple understanding of how you can connect to your sense at measure
the temperature pressure and humidity and also display it on the console as
well as on your sex act.

Now coming on to the second part second part
is the slightly Advanced version of the same program here. We're trying to do something
a little more apart from just seeing it on the screen. Okay. Now I want to send an email
with respect to all the logs that I have or let us say
at a regular interval. I want to have an email which notifies me with respect
to the present temperature and the current
pressure and humidity.

Now, this is something
that you can definitely use while you're working
on a social experiment as such usually
in the Laboratories. It's important that you
always keep Check on the temperature
pressure and humidity. So this is something
that you can try out. So let me show you the code. Alright, so here I am just including something new as well
apart from our previous code. Okay. Now if you see our previous code
is still present here. I'm taking the temperature. I'm taking the pressure humidity
storing into a message and then I'm also
printing that message but apart from that
I'm using a few libraries which are very essential
for mailing me this detail.

Okay. So for that, I'm going to use
first SMTP Library. Okay, because your I'm
wailing Protocols are SMTP based protocols. So these are something
that I will be using in case I need to send a mail
with respect to all the details as such so these
are standard protocols through which I be communicated. Okay. Now coming down with respect to what Mi Ami is
a Miami basically is an extension or multi-purpose
internet mail extension. Okay through which
I can send emails which support text characters non text characters audio
video images and so forth. So sending a mail. Is an essential important
Library as such? Okay moving on forward. Let me explain you the code now here we
are repeating the same thing. We are also importing the time function and then we
are establishing a communication between the sense
at and the program.

Okay. So here first you need
to specify the from address that is from Coos mail ID
you're sending this. So I have created
to test Melodies one is a durocher test 11 at gmail.com. So from this address
the mail is going to be sent and the address
which is going to be receiving. This is a deal-breaker. A Raspberry Pi. Okay. So from this email-id
I'm going to send a log with respect to the data that is measured from I
censored Raspberry Pi. Okay, then I'm going to use my Mi Ami multi-part
function from here.

I'm going to distribute my mail
into multiple parts. So this is what your Mi Ami multi-part function
will help you to that. So in my message part the from
is going to be the from address that is from whom it
is going the two is going to be the to address
and the subject. I am defining it as temperature
Raspberry Pi so temperature Then I'm measuring
all the temperature as well as the pressure and humidity and storing it
inside a message variable. So here what I'm doing is that I'm basically going
to attach the message in a plane format
to my message variable, which is going
to be the details of the temperature and pressure.

Okay. Now, let me come down and help you understand
this part of the code. Now. I'm going to establish
a connection to my server. So I'm going to use
your server variable where and I'm establishing
an SMTP protocol do Google. Okay. That is your or
smtp.gmail.com sensor. This is a standard
mail protocol SMTP for Gmail. It is smtp.gmail.com
other meals you can just replace the corresponding me and then
you have the port number. So again with respect to SMTP. This is a standard Port that you would be using
for communication. That is 25. Okay, then I'm going
to start my server. So that is server dot start TLS. Okay, once I start this then I'm going to specify
the login credentials. This is basically
for authentication Factor. So server DOT log in you have to provide
the Username and password. So my from address is
my username and my editor a kpi is the password
for this email-id. Okay once have specified
this then what I'm doing is that I'm converting
the message as a string.

Okay, sometimes what happens is while you are trying
to send this. It may not get sent as such because it has
values also associated with it some directly converting
it completely to a string. Okay, and then storing it
inside a variable known as text. Then I'm calling
the function sin. Email through which I'm
specifying from which address is going to which address
it should go and the text which is part of it. Finally. I'm quitting the connection
between the server. I hope you've understood
till here with respect to the program now, it's time we
execute this program. Okay, so let me call
python email dot p y okay. So now what it has done now,
it's connecting to my server. That's the delay here. Okay, its measured
the temperature its measured the humidity as well as
measured the pressure and then it's going
to send the mail. So let me show you
this meal ideas were so as you can see here. I've already received a mail from anyway car test lab
it's called temp rasp that we had set and it's given me
the corresponding value of temperature humidity
and pressure.

Uh sure so this is what
I was referring for so you can do this across to let
me show you my sent box as well. Okay. Now if you see a new Sandbox, I can actually see that this male has been said
so there are two ways for me to verify this as well. So this is something
that is really helpful for me now coming back to my Raspberry Pi let us
now see the final program in which we want
to incorporate this and do a little more. So let me explain you the code
little more better here. There are few things do here. So first you have pikul and Jason being imported
now pikul, basically, Is going to help you establish
a connection between your API. So we're going to use an API through which I'm going
to pass my data. So for that I'm including
bikers here apart from that you have string IO, which is a standard string
input output management package and you have
your our PI dot gpio. So that is Raspberry Pi's
General input output. I am just referring
to it as gpio.

Okay, so moving forward
whenever you see gpio it is the general input output
from the Raspberry Pi and then you have the similar
function you have sense. Go hat from censored
and time function and I'm establishing
a connection here as we have done earlier
between my sensor and my application and I am clearing
the screen on sensor. Now. What happens is sometimes if you've executed
a program before and you've stopped the execution
of the program then what happens is the display will still have the remaining
data present on it.

It stays stuck on the sensor. So before we move on
to with respect to our program, we will clear the data out. Okay, so that's what
sense dot cleared us now here. Two things that are present
here hot and cold. Okay now why they're
being used I'll come back to that a little ahead. Okay apart from that. There's also a new variable
known as push message. So we'll be talking
about this also when we come down later and you'll understand what
the push message is used for. Now. Let's try to understand the code which will help me
display numbers on my sensor. Now, you might be wondering if I have already displayed
number and data on my sensor. Why do I need a separate
part of the score because here we're trying
to do something different.

And from what we
have already done, so here firstly what we're doing
is that we're setting an offset from the left and the top. Let me go back
to my presentation here. Okay. Now here this is the standard program that
we are talking about. But let's see. This is what we need. Okay. So this is what we're going
to explode ahead. Now. This is my actual sense at okay. This is a neat cross
8 LED display function. Okay. So here what I'm going to do
that I'm going to eliminate the First Column and the first two rows
from the top. Okay, so this We will give me a 6 cross 7 Matrix area
remaining with me.

Okay, this is where I'm going to do all
my operations from now onwards. So this is something interesting
and I'll help you understand why I am taking this region. Now before we move on let's take
a simple look with respect to the core present here. Okay. Now before I do that, let me try to help
you understand why I have taken a 6 cross 7 Matrix area. Now. This was the remaining area. I have divided this remaining
area into two parts. Okay. Okay, I'm just going
to give a gap of one column between these two and the left hand side is going
to represent the temperature or the value in tens place and the right hand side segment
is going to give me the value in once place.

So this basically is
a 3 cross 5 Matrix where and I have 15 positions
to play around with boom. But this number again, this is 15 areas that
I can play around with in a 3 cross Phi Matrix. Now, let's go back
to our code now. Let me help you understand
how it works now. I have basically
10 numbers with me. Okay. So each one is going to have
a specific way of representing in a 3 cross five Matrix. So that's what I
have written here in this number Matrix as such. Okay. So each of the line
is a representation of a corresponding number
in a 3 cross 5 Matrix and this one and zero
basically is a configuration for the LED to be either turned
on or turned off. So normally when we
write 0 the first line will always be full. The first three numbers are one. Okay, then you have 1 0 1. Okay again 1 0 1 1 0 1 and my last three
numbers will be again one so as and when you represent
zero in a normal form, this is how you do that so it may not be so clear
to you right now.

Okay. So what I would recommend is before you try to understand how each of the numbers
are displayed set an offset on your sensor there
try playing around with respect to different
values to understand how you can represent each of the numbers once Made
two or three mistakes, then you'll get a clear-cut
understanding of how each of the numbers can be displayed. Now. This is for a 3 cross
Phi Matrix tomorrow. You want to try it across the
across it you can do that as well. So definitely make sure to try out make mistakes only
then will you learn? Okay.

So each of the line is
a representation for a digit in a 3 cross Phi Matrix. Now, let's try to understand how we can display
a single digit for that. I'm going to define a function
called show digit, okay. Okay. So this is the function it
takes a value as an input. Okay. It takes a value for x d OK XD is the x-coordinate
for where the digit has to be present yd is
the again the y-coordinate as to where the digit
has to be represented and the last is a simple
RGB value present here. Now first thing
what I'm going to understand is that I'm going to compute
the offset position. Okay. Why do I need to
compute an offset? Because each of the
numbers are present in different rows of the call. So I Need to understand
which is the present number and which value do I
need so for that what I'll do is the incoming
value into 15 will always put me at the start of that room. Let's say the value is 3, okay. So 3 into 15 tells me that I need to
move 45 positions.

So as I said
each row has 15 so 15. Okay, then I have 30
in the next row. Okay, and once I'm done with
the 45th transfer then I'm here. This is the standard
representation for three. 3 so I have this complete row
at my disposal presently. I am pointing to the start
of three value. Okay. So this is something
important to remember. So this is why we
are Computing an offset by multiplying the value in 250. So I have the complete
access to this row. Okay now we'll try to execute a for Loop through which
I'll place these values into the different parts
of the LED display. Okay. Now see I have
three cross 15 area. So I need to identify
in which area should which Look up that is
which led should be turned on. I have three rows and 5 columns. So I need to identify this. Let's go back. Now. The first thing that I'm going to do is
that I'm going to compute x t OK XD basically is going
to be the value of p modulo 3.

Okay. This basically is going
to give me value of 0 1 or 2. Okay. So if you go back
to our presentation, it's either going to start
from this 0th position or it is going to be in the first position or in
the second position. Okay, similarly in
the left hand side. Also, it could be
this 0th position first position or second position. So basically we are
dividing this that's what you need to understand. Okay coming back. Let me just remove this. Okay. Similarly. I'm going to compute my y of T by have to basically
is to help me understand which value should I take
from this complete row, so this will basically start
from zero and go all the way till 14 as such.

Okay, so it will basically
represent which column value should I take So I
hope you understand from this which column value
should I keep taking for my next value. Once I have this then what I'll do is I
am going to call the sense dot set pixel Rumba
how we had called sense – roh message so there and we had sent
a complete message. Now, what we're doing is
that we just sent to each of the pixels
individually as such. Okay, so we're going
to use the x coordinate.

Okay, which is going
to be my x t plus XD. Okay. Remember this? Okay. We'll Define X. Still it'll add but just
keep this in mind XT plus XD is going to give
me the x coordinate y t + yd is going to give
me the y coordinate and then basically
my RGB number comes so here I have just done
a multiplication of P into R. So whichever I want I'll
just convert it accordingly. Okay. Now comes the choice of when you have to display
two digit number. So instead of going back
to the same function. F defined a new function, which is called show number now show number is
The original function that will be caught because the temperature measured is most often
a two digit number. So this is where the actual code
was going to start from. Okay. So number takes four values. It takes a variable called while which is
the present temperature. I have my RGB value as well as
I'm going to begin the function here firstly I'll begin by taking the absolute value
of the given input.

Okay, when I say absolute value, I am basically trying
to identify the number present in the tens place. He's okay. So this is what absolute value will be whatever the digit
is present in the tens place. I'm going to store it
in my abs underscore value so that I'm just
providing it here to the tens place then
let me also identify what is in units place and this
is simple mathematical operation where I divide
the number by 10, I'm going to get a remainder and that's what I want. So I'm going to use
a modular douche. So my absolute value divided by 10 is going to give me
the unit's place as well.

Now, what I'll do is I'll run. If condition so here
what I'm going to do if the value is greater than 9 then I'm going to call
the show digit function which I had defined earlier and I'm going to pass
the tents value. Okay, the value present
in the tens place. So and then I'm going
to also pass the XD n yd. In this case x d + yd
is going to be the offset left and offset top why let
me help you understand here.

My offset top is going to be
with respect to this position. It's going to start from here. Okay, so it will point
to the third row. Okay my offset. Left will point
to Second column here. So I know that this is
where my tens place has to come. So that's why
I'm passing it here. Okay. I also am going to pass
the standard RGB value that I have got input here then
for a second time.

I'm going to call the show
digit function where and I will pass the unit's place, but with an offset
of additional four spaces. Okay. So this coming back
to our segmentation. This is going to be
four positions from our left. So offset left is going to give
me the first place but offset, Plus four is going
to be the start place where I have defined
for my units place when I say from top it's worth
going to be the same because I'm not separating with
respect to different levels. So I'm just going to change
with respect to my offset left. Okay. So that's the only difference
present here now coming down. We are Computing the basic
temperature the humidity and pressure and then storing it into a message string
now comes the place where I need to do
my actual implementation now if you remember
our problem statement, We have to send
the pressure temperature and humidity as a notification
on our mobile device. Okay, so for that I'm going
to use in stop push which is an application
through which I can send notifications across my mobile.

So my python application that is the final application
will communicate to install push and that will
in turn communicate to my mobile application that on which I
have configured it. Okay. So the notification
will be received on my mobile application
now coming down. Me remind you again
why we are using this in a real world scenario. This is something
that is being used by NASA. Okay, they're they're using
it to identify if the exterior temperature is
falling between a specific range or even let's say if there's a change
in the pressure inside the cabin or if the humidity is too high, so all this can be measured and you can get notified
with respect to any change that you want. Okay now coming back
to our program. This is why I have defined
a range of cold and hot If it falls below 37 degrees, I want a notification
if it goes beyond 40, I want a notification. So this is my range by value. It should either be
only 38 or 39. Okay. So this is why I am using
cold and hot variables now. Let me help you understand how the in stock push
application is working for that.

Let me open my browser
and show you how you can configure in stock push for
your Raspberry Pi application. Okay. So this is
my insta push homepage. Okay now first. Seeing what you need to do is that you need to begin
by creating a user ID credential here and it is very important. When you logging
into your application, you use the same credentials. So make sure you
do not lose this because it's very important only if you use the same
credential will you get this notification so remember that so you have an option
to sign up for free as well? Okay. All you need to do is
provide your username provide your email address
and then specify a password now, let me just log in. Okay, so I'm just logged in. Okay now here you can see
there's already a timeline because I have already
configured this application. Let me help you understand how you can do this now
in my application. I already have a temp
notify application. Okay, which will be using as
part of our understanding. Okay, firstly let me click
on ADD application now once I do this I need
to specify a name.

So let me just call it sample. Once I click on Sample once I press add
application sample gets created now it is asking me
to add event here. So click on add event. So let me call this temp rasp. Okay, and then tracker
would be message. Make sure you create a tab here
after you specify whatever it is that you specify and here push
message will be message. So make sure it's present
inside curly braces. What are we are specifying here. Once this is done just click on add event and this event
is going to get added. Okay, so the event
has been added now it's time. I helped you understand
why I had specified message there so rumor let me go back.

To my code. Remember we had defined
something known as push message. So this is why I
have defined message here. So this is what is going to be sent between
my final program application and my insta push application. So this is why we had defined
this variable earlier as well. Okay now coming down
with respect to this. Let me go back to my insta push
and let me help you understand. What all do you need
before you move ahead? Okay, just go to the basic info Tab and here there are
two things that you need. Okay first. First you need
your application ID and then you need
the application secret. So this is very similar to how
you have a user ID and password. So this is what you're going
to use in case you're working with an application. Okay. So make sure you note
this application ID and the corresponding
application password. Now if you come back
to my program you can already see I have mentioned
the application ID as well as the application secret and here the push event is
to my temp notify. So this was the previous event
that was already set.

So I will be reviewing. Bring to that as well. Now, what you need to do is that you need to use Curl
to post whatever data that you have
to the insta push API. So for that you're going
to use biker dot curl function. Okay, and this in turn
will help you communicate between your application
and insta Porsche. Okay. So all the communication
is going to be through a variable called
C. Now C dot set up. Okay here what I
am going to specify is that I'm going to specify
the URL first, okay. The URL is going to be HTTP colon slash slash
a pi dot insta pushed IM / version 1 / post. Okay. There's also another
alternative URL which is HTTP colon slash slash
a pi dot insta pushed IM / post itself now in case the other is not working you
can use this or vice versa.

Okay, moving forward. I need to set up
the customer headers basically for my authentication
and content type specification. Okay. So for that you're going to use
the command C dot set of forward by C dot HTTP header. Then I'm going to specify x – install push –
a pi D plus my app ID, which I have specified earlier. So this will help
me identify to which up. This has to be pushed. Okay. The next is going to be x –
insta push – app secret. So basically the app secret
your your password in this case.

Okay, then comes
the content type. That is what What type
of content I go to pass so this is going to be
application dot Json. So I'm basically going
to pass a Json file to my API. Okay. So I hope you guys
are clear till here. Okay. Now what I'm going to do is that I'm going to
define the function through which the message
is going to be passed. Okay. So here what I'm going
to do first is that I'm going to use
a dictionary structure for passing the data as Json
in my post function. So Jason – field is going to
create a dictionary and in through that
I'm going to send this data. Okay. Now what I have to do is that I have to specify
the field values.

So first comes the event, okay, which is basically
what event I need to relate to then comes my tracker. I'm not specified any tracker
as such then comes my message where and I'm going to pass
the push message push message basically is the
temperature the pressure and the humidity as such now if you want you can print this but I am not going
to print it here. Finally. I'm going to use Json dot dump
to make a Json file and going to assign it
to post Fields variable. Okay. So post field is the variable which I am going
to pass to my APA. Okay next to send your Json file with post use the following
command C dot set-top. Okay inside which you're going
to specify CDOT post field and you're going
to pass this post field, which is the Json file as such then if you wish
to capture the response, then you can capture
it inside a buffer. So for that I am also going to
use a buffer to write operation and this can Done
with the following command C dot set up inside which I'm going
to write C dot right function and buffer, right? That is the right back
has to be into my buffer.

Okay. Now if you want to be updated whether the post
has been sent then you can use the following command that is C dot set top followed
by C of C were Burrows. So this will make sure that I am getting posted
on my terminal with respect to the communication finally
comes our operation of checking the temperature. This is very similar
to what we have. I've done earlier where we are running
an infinite Loop. I'm measuring my temperature
in degree Centigrade. I'm measuring my humidity
measuring my pressure storing this value
inside a message variable and then putting it
to sleep simultaneously. I am also writing
into a log file and this is going
to be stored with respect to the present time. Okay, so till here I
hope you guys are clear now comes the part where I
have identified my temperature.

I'm just making sure
it's an integer and then I'm going to call
my show number function. But if we had defined a function based on which it
is going to be displayed on my Raspberry Pi so this
is a call to that function. Okay, once I
have done with this, I'm going to store it into temp
1 then I will make sure that I am writing it
into my file and then comes the interesting part if my present temperature is
either greater than or equal to the hot message or if it is lesser than or equal
to a cold temperature that we have defined rumor
the two variables.

We had defined earlier. This is where they
are being used. Used. Okay, the push message
will start with either if it's hot or if it's code following that would be
the present values. Okay, the pressure the
temperature and the humidity. Okay, then what I'm doing is that I'm going to pass this push
message to my P function that I have just defined.

So basically it will first
convert the push message into a Json data and then it will pass it
through the communication. So this is
what is happening here. Okay. Same thing will happen in case
it is the temperature Falls below the cold rain. Guess what? Okay, then I'm going
to create a Json file and then call CDOT perform. So this basically will initiate
the curl operation to start finally to capture
the response from the server. You can actually
use the buffer rage. Okay. So with this we have come
to a conclusion. Let me just show you
the final part of this. Okay, so make sure that you're closing
the communication through curl. So you see door closed. Okay. This will ensure that the communication done
through curl is closed as well as you ensure that the General purpose
input output is cleaned up so that new values
are being taken.

So now let's execute
the final program. That's python final
program dot P by okay. Now as you see on
the Raspberry Pi it showing me that it's presently
35 degrees Centigrade, okay. Okay, I've started getting
notifications on my phone. Let me just share
this phone screen with you. Okay, and you can see there's
a variation with respect to the temperature shown
on the Raspberry Pi as well. Okay, let me show you
first my phone screen. Now. If you see here it's actually showing multiple
notifications being generated. Okay, it's showing me
that it's cold presently. And here's the complete list of
the temperature notifications.

So I'm getting a constant
notification with respect to the change in temperature. So you can see it's continuously
being Generated here as well. So this is something
that is really helpful when you're working
around with respect to a real-time scenario. So like I said NASA
extensively uses this for their own purposes of measuring the
temperature pressure both in their scientific research
area as well as the shuttles and space stations
that the user. Okay. So with this we come
to a conclusion of our demo session Raspberry Pi
has become the heart. Of The Internet of Things domain and camera is one
of the most interesting modules that you can add onto this
interesting Hardware as well.

Now, let's begin by exploring
the pie camera for that matter. Now the pie camera was one of the best additions
to the Raspberry Pi component because this module has helped
the users to use the perspective of camera into one
of the smallest and the most effective combination
of the internet of things. Now the main objective of the by camera module is
to help you capture images. It's capture videos time-lapses
even slow motions as well. Now apart from this
the pie camera also helps you capture videos in full HD
at 30 frames HD at 60 frames and even Vijay videos
at 90 frames as well. Now there are two versions
of my camera that are out there. Now the latest version being
the camera module version 2, which was introduced
in 2060 now, although there's not much
of a difference between both these cameras. There has been a slight increase in the resolution wherein
you had five megapixels for the first module you have a It's not and even the sensor
on board has been swapped out where in there was omnivision
for the first version now, it has been replaced by
a Sony sensor as well.

Now talking about the by camera. You need to be quite careful while you're working out
with the by camera. So let me help you understand how you can set up by camera
with your Raspberry Pi as well. Now, there are five different
stages on setting up by camera will be looking at each one
of them one by one first. Let me help you understand
how to connect your pie camera to the Raspberry Pi now
this Is very important because we've used
three camera modules and we managed to burn
out two of them. So please be careful because this is
a very delicate ribbon and this is also
a very delicate module as such so let me
help you understand how you can attach the CSI cable
to the Raspberry Pi and then I'll also
help you understand. Once you've done this how to enable the camera as part
of your Raspberry Pi as well. So this is
my Raspberry Pi camera, and this is the version
2 of the camera now if you notice this is the camera
that you can see and this is something
that's really difficult.

It gets a piece be careful. Now one thing that I really want you to notice
here is the connector here. So this is called The Sunny Side
Up and this is called the silver and now you need
to be really careful when you're plugging this so, let me just bring in
my Raspberry Pi here as well. So here we have
our Raspberry Pi 3, and I'll just show you
how to connect this. There are mainly two precautions
that you really need to consider while you're working
with the Raspberry Pi camera. One thing is just please ensure that the Raspberry Pi is
Switched Off or disconnected before you connect
the Raspberry Pi. Camera as well. The this actually leads to a high chance
of blowing up your camera. We've already successfully
managed to do that once so, please ensure firstly that the Raspberry Pi is
Switched Off and also that the connection is correct. If you notice the silver
side present here, this should be facing
the HDMI port that is present here.

Now in order to connect this
let me just slightly push it off and this slot needs
to be slightly raised up. You insert it like this. Okay. Please be very careful. Once you've successfully
inserted it then just push down the hinge as well. This will lock it. So make sure the silver side is
towards the HDMI and the Sunnyside is
to your 3.5. Mm Jack side as well. Now. It's recommended that you get
a case wherein you can also support the camera because it's slightly
challenging because there are rubber in itself is delicate. So when you get a case, which has the camera support,
it will be really useful to you as well. So it is a very delicate items. So please be careful
while you're working. Thing with the Raspberry
Pi camera module moving on. Let's look at how to go
into the interface and enable the Raspberry Pi camera module
for your Raspberry Pi as well.

So now that we
have successfully connected to our Raspberry Pi
let me show you how to connect or enable
the Raspberry Pi camera on your Raspberry Pi as well. Now, what I have done is that I have established
a remote connection between my Raspberry Pi and my system using
VNC viewer as well. So this makes it quite easy
for me to show you what I'm doing
on my Raspberry Pi. So once you have successfully
connected and turn down your Raspberry Pi you
can go into the menu and then go to the preference
section here going. To the Raspberry
Pi configuration. And what you need to do is go
into the interface section here. Once you're here make sure that you have enabled the camera
option as well by default. This would be disabled. Now. I have any able most of these
for different purposes so you can just enable
the camera option as well. Once you're done with this then
we'll go on to the next stage, which is understanding how you can capture images
from the Raspberry Pi camera and how to capture video
from Raspberry Pi camera as well now rasp eyes still
is actually a shell command.

Which lets you Is
the camera module and capture an image now, the command for capturing
an image is rasp. I still – oh and name of the image that
you want to store it as now – oh is basically
to open the camera and capture the image
and at the same time if you want to rotate the image
vertically or horizontally, you just need to pass
the parameter – VF or – Hatcher now both of this
will either flip it vertically or flip it horizontally
and when you pass both of them, it will completely
flip it around as well now apart from this if you wish to capture a video from the Raspberry Pi
you can use the command r a spy with doing
this will help you again capture the video
from the camera module. Now, this is something
that gets stored by default as a h.264 video as well. If you wish to convert this you
can use the following command, which is sudo
apt-get install – why g-pack now? This video will actually
help you install MP4 box onto your machine and help you convert
your h.264 videos into MP4 format as well.

Now once you have it
in MP4 format then Quite easy to play this video
and check it out as well. Now again, if you want to run it
for a fixed duration, then what you can do is
that you can also pass the duration as part
of the parameters while you're specifying
a spy with as well. Now one thing that you
need to keep in mind while you're doing this is that the timeframe that you're passing
here is in milliseconds. So please be careful
while you're doing this now, although I am specifying 10,000. It's only for 10 seconds that the video is going
to be captured as well. Now, let me help you understand
how you can do all this. By using a python function
rather than a shell command as well for that.

What you need to do is that you need to install
a package called by camera. Once you've done this
then you can easily access or you can easily perform
all the operations as part of your Python program using
the pike Ram module as well. Now, what you need to do is that first you need to update
all the packages that you want. Then you need to install the python by camera
package that's present.

Now if you have two versions
of python on your machine that I would recommend
that you run both these commands that is python – by camera and by In 3 – bye camera this
in turn will ensure that you have the 2.7 and version as well as
the three-point X version of Pi camera present
on your machine as well. You can also install Pi camera
using pip install as well.

So the command is pseudo pip
install Pi camera as such moving on let's talk about how you
can actually create a program or how you can use
a Python program to record the videos
for the same 10 seconds. Now earlier. What I had done is that I had just mentioned
that run for 10 seconds using the Shell command r a spy
with but Technically speaking. This does not really account
for all the challenges that may come across while you're actually
capturing a camera now that is where you use a Python program
to help you ensure that even if an exception is come across then
you can handle it and due to that will
be actually using the with statement here firstly what I would like to do. I would like to import
the time package of now importing the time package
also helps me access to the pi camera module and the by camera function
will in itself connect to the pie camera module
and the data that comes With them
not when I'm using with function here this in turn will actually help me
in handling all the exceptions and encapsulating
the proper tasks and cleaning up
the tasks as well.

So basically becomes
a best practice while you're using the by camera or while writing any codes
for that matter. So most of us programmers
would like to consider all the scenarios
and take care of it. And in this case python
has given as the with statement to it take care of it as well. Now if I use the command
camera dot start with you, what is going to happen is that it's going to give me
a Review of what my camera is C and I call a sleeve
for 10 seconds this in turn will ensure
that for the next 10 seconds.

The camera preview is
on once that's done. I'm going to stop the preview. So what I have here is a preview of what my camera is seeing
for 10 seconds as well. But this is not
where it restricts. There are various other commands
that my pie camera brings in as well talking
about these commands when I use the command
camera dot capture. It captures an image
and Camera dot start recording and stop recording
will in turn help me. Did a video as well if I go back
to my previous program here here I can also
write camera to capture in order to capture the image
between the 10 seconds or what I can also do is that I can also start recording
at the same time as well.

So I started recording Let
it wait for 10 seconds, and then I stop
the recording as well. So these are different commands that you usually use
together apart from this if you want to capture a stream, then you can use camera to capture my streams followed
by what type of stream that you want to store
it as well now if you wish To stream the video that is coming from your
Raspberry Pi then you can use the command camera dot captures
followed by my stream and the type of stream that you wish to store. Now again, this also can be recorded wearing you use
camera dot start record. It captures the stream
and you specify the quantization that is needed to this as well. Again, if you wish to play
with some of these properties of the camera as well, you can play around
with the brightness. You can change the resolution and you can even add a weight
with respect to it. Similarly as you have a timer function in
your standard cameras the same. Be used here as well.

So let's say I want to start
the recording after 5 seconds. I can do that as well. Now with this, let's come to the demo
of this session. Now, this is a slightly
interesting demo. I'm quite sure most
of you are looking forward to this as well. Then we'll try to
help you understand how you can actually set
up a security camera at your home as well. Now talking about the overall
system here now here, what I would like to do is that I would like to capture
the image of anyone who comes to my door.

Once that's done I would check if this person is a recognized
person or is it someone that already has
access to the house? If not, I can always
prompt my user and And give access to it. If not, I can deny access to it. Now to those of you actually see
in our iot projects video. You would have noticed
that in Mark Zuckerberg section. He had actually
allowed his parents. Now, I do not want
to manually have to do this when I just automatically allow
people to do this as well. That's a smart system
or that's an enhanced system that we really would love
to achieve as well. So we would not be
completely able to achieve it but we will take
our tiny steps towards it and we can all enhance it as
per our requirements as well.

So firstly what
We're going to do is that we're going
to detect the face. We're going to gather this data. We're going to compare it and then we're going to start
recognizing data as well. Now again, this is
a learning process that takes place. This is something
that involves a lot of understanding and this
slightly gets interesting for most of you as well. Now when we talk
about face detection now, the first stage of face detection is
Verena program actually decide whether an image has a face
or it does not and this stage in itself is called
a classifier as well. In order to achieve this opencv
actually provides us with to pre trained and ready to use
face detection classifiers, which are part of it. We have the half classifier and we have the LBP
classifier as well. Now one thing that you
need to notice or one thing that you need to keep in mind while you're working
with this is that the classifiers
themselves process the image while they are in grayscale
as well because it gives the machine quite Clarity on whether to classify it
or not as such now when I talk about each
of the classifiers whether I talk about
the heart classifier or the LBP classifier, Each has its pros and cons.

So let's actually try
to understand this. Now the concept of phase
detection is not something that's quite alien to most
of you and I'm quite sure you've all seen it be it
in our Facebook applications Snapchat. Some of us have also seen it
on the ATM machines as well. We're in Phase
detection is incorporated. And if you wish the most
simplest methodology or if you want to see
the most common example that's out there
for face detection or face recognition. You can see it in most of the phones today
as well again here. What happens is
that The two algorithms that are most widely used are
the higher classifier and the LBP classifier as well. So again, both of these classify are mostly processing
the images in grayscale because we don't actually need the color related
information to decide if there is a face
or not now again, there are going to be
two classifications present here the computer program
which actually decide whether there is
a positive aspect where in the phase is present or the negative aspect where
the face is not present or so.

So this is how you
decide or this is what you Call a classifier
for that matter now in opencv as we have seen. There are two
different classifiers, which is the higher classifier
and the LBP classifier as well. Now again, when you talk
about the higher class where it is actually
a machine learning approach that we take a and this was created by
Paul y Le and Michael Jones wherein they are trained
many positive images and negative images
without faces as well.

Now this intern actually
started helping them understand that extracting feature
takes quite some time and if you consider
both What segments when you consider higher and LBP had actually takes
up slightly more time. But at the same time it gives you a slightly more
precise solution as well. Now what it actually does
is it actually considers the adjacent pixels
to the region where the face is protected and then it actually
sums up the intensity of these pixels in each
of these regions as well. Once it's done. It actually calculates the
difference between these sums and then it uses
them to differentiate between the section and the subsection
of the Ages as well now when it comes to the LBP
section of this here, it creates a 3 cross 3 window
at the time of image as well.

Then what happens is that it starts comparing
from the Centre pixel with all the other pixels which are greater
or equal to the value which is set as 1
or 0 as well then again, it goes on to read
the binary value in a counterclockwise order
and converts it to decimal which are Center values
of the pixel as well. Now what happens is that this process is completely
repeated one after the other and you An easier or a smarter
solution to this as well. Now again, as we have discussed both
of them have an advantage and a disadvantage as we are talking
about the half classifier there. It has a very high accuracy
when it comes to detection of face and there's quite
minimalistic false positive. But the challenge is that the computational time
that it takes is quite slow. And again, the training time that it takes is quite long as
well and even in dark segments, it's not quite accurate as well
because it fires High Clarity with respect to the images
or the scanning area that it takes in the picture.

But at the same time when you look at LBP
classifier its computation and training time is actually
quite fast and shorter when you compare
to the hard classified as well now it is quite robust when to any elevation changes that is when there's
a change in lighting. It's still comfortable
and capable of handling this but at the same time
it's not quite accurate or it's not on the same level
at the same time has a high chance of false
positive fatigue as well now. Move on forehead. Let me just show you about
these packages slightly better. Now. If you come into
your opencv package now, I would recommend that you download the opencv
library from GitHub itself. And if you come
inside the segment and you go inside data what you can see here are
the different hard classifiers and LBP Castle path. Now, if you go inside
the hair Cascade section here, you can find different
XML files present here, which will help you understand or help you recognize
different aspects of a body it can start from I you
can start go to I classes And then sue forward as but now
what will mainly be using is that we'll be using
the frontal face segment here.

Okay. And again, these are XML files. So even if you open them
and if you see them you would not perfectly
get a clear-cut idea but this is something that we have to use as part
of our program as well. Meanwhile while this is opening. Let me go back. Let me show you
the lpp segment as well. Okay. Now what you see here
are different values that are associated in these are different values
to help you identify or help you understand how the face recognition
should take place as such. Okay. No again. It's a very huge document. So what they're trying to do is that it again going to try
to restructure it again. I think you've got
a simple idea at this point.

So let me just close
this and let me go back now if you check the LBP Cascade segment as well here
you have different segments. So again, what we'll be using is that we'll be using the frontal
face segment as such. So what I've done is that I've just created
a separate folder where I've kept my program and these two opencv files
for different algorithms as well now coming back we've done with our
detecting the face. Let's talk about Using our faces as well now till here
what I have done is that I have detected my face, but I need to start
recognizing this face as well. So face recognition mainly can be classified into
three different steps first. I've actually dealing with the data Gathering stage
now in the stage, what you're mostly
going to do is that you're going to gather
any relevant information with respect to that face. So usually this is done
when you have multiple photos of a person and then
you start identifying or you start training
your machine on this face and then it starts recognizing
the Face every time that it comes up with an image
of the same as well.

Now there are
three different functions that opencv provides us to do this and let me give you
a brief idea on each of them so that you know, which to use well now first
comes the Eugene faces now Eugene freezes actually
takes all the images at once looks for all the important and useful
components in these phases which are known
as principal features and then passes it
on now one key factor that makes or one key challenge
with respect to the Eugene. Phase function is that it requires a good
amount of Illumination.

But at the same time when you have your fish your
face here individually images or individually features
are extracted rather than extracting one by one and this in turn actually does not have a challenge
with the illumination segment as such third is your lbph, which is your low
binary pattern histogram and this is very similar
to your LBP as but but what happens here is that you create a binary Matrix
and convert into decimal factor and then you actually Not
a histogram with respect to it. So what happens here is
actually a comparison with respect to the histograms
that are present. So each phase will
have a correspondingly different histogram and I just compare
these histograms to in order to identify which phase
it is belonging to now. Let me come back to my place where you buy and
before I go forward as we said this segment
actually deals with two parts first is actually
capturing the detection and the second is
with the recognition part.

So let me first show you
how you can detect it now. We've already discussed above. About detection or how to
capture any intrusion detection in our Raspberry Pi 3 tutorial where we actually capture
someone opening the door and coming in as well. Once I've captured this image. Then I need to start
recognizing now first. Let me show you
this program here.

If you want more details on how it works out then
you can definitely check out our Raspberry Pi
3 tutorial as well. Now if I use the following code,
let me just expand this a bit so that I think you
may not be visible to you. We just increase the font size. Yeah, I know. I think you can all see
my code as well. Now again, we're using
different packages here you using user Library CV
to the time and numpy as well. Now, I'm first going to set the first frame
then I'm going to decide whether there's any
detection as well.

Okay. Now for this as we have mentioned
in our Raspberry Pi 3 tutorial, you can use the IP
camera application which is an Android application and you get an IP address
as well or a URL which have specified here. Now, let me just run
this and show you what I'm seeing at this moment. Now what it's going
to do also is that it's going
to capture the last image that the camera sees as well. So any change
with respect to it? It's going to overwrite until I quit or I exit
from the program as such so let me just run this. I just zoom in a bit. So let me go back to my desktop and I'll run
the camera application. Now what it's doing is that it's connecting
to my phone camera and it's going to create or show
you what I'm seeing or what. My phone is seeing
at the moment.

So what you see in is
my Raspberry Pi set up here as you can see, it's set up on a curve
because it's slightly tends to get heated up, but you can see it's
a separate device as well. So this is my first frame
and what I'm going to do is that I'm going to put my hand
in front of it and I'm going to make this as my last frame
as well while this remains. I'm going to press
Q to quit from this. And it also has created an image called test
dot jpg here as well.

Let me just open this and if you see it's my hand
that has been captured. So what happens here is that it captures the last
in frame as well. So if you want to get
a better understanding of which image it captures
will rerun this but before that, let me just remove this file. Okay. So let me just send
it to the waste bin. And then what we'll do is we
just re execute this program. I'll start by keeping my hand in
the front of the camera itself.

So this is my first frame, okay. And any change to this
let me I'll just move it off completely. So this is going
to be my last frame and I press Q to quit from this and let's
just recheck the image as well. So you can see it
has captured the last frame as such with respect to this. So it's a very interesting thing
for capturing this and now let's actually come
now into our program which talks about
face recognition and face detection as well.

So this is the program that will help me detect
the face train my application and also understand which face
belongs to whom as well. So I have imported my opencv
to because that is where my face detection
and face recognition. Algorithms are present. I'm going to use
the OS module here as well because I need access to the drives our the path where these images are going
to be stored as well and numpy is one of the very
Key Programs of is one of the very key modules, which is required for any face
detection recognition as well.

Because the information that you're going to be using
would be stored as a numpy array for that matter. Now again, what I'm going to do is
that I'm going to actually identify the face
of three people. Okay. I'm going to identify
whether the image that I'm passing is of Ronaldo
is of messy or is off Robin. Okay. Our if it does not fall
into either of these three, it's going to give
it as null as well. Now our first program
or the first function that we're going to be
working is with respect to detecting the fixed. Now, as I said, all the images are going
to be converted into grayscale. So that's what I'm
going to be using. C V2 dot CVT color
to grayscale conversion. Once this is done. I'm going to create a face
Cascade for that matter. Now C V2 dot Cascade classifier
actually specifies which kind of classifier to be used.

Now for this program. We're going to be using
the LBP classifier. Okay. And as you see it's
for the frontal face as well. We've seen there are different
aspects but we're going to be using LBP frontal
face classifier as such now this phase is going to store
the list of all the faces that I'm going to be detecting
or I'm going to be identifying. Okay. So for this what I'm
going to do is is that I'm going to specify
face underscore casket and then I'm going
to ask it to detect in multi scale parameter. So I'm going to say it has
to identify in grayscale. The scaling factor of the image is set as 1 Point
2 and the minimum number of pixels that it
should consider is 5 okay. Now if no faces are detected
from the images that I pass then it has
to pass the parameter as none.

But if it is detected then I
want all the four coordinates with respect to
the X and y-axis, which I'm going to be storing
in XY W and Okay, X Y width and height
with respect to smarter or I'm going to specify
which part of the image does the face actually contain. So I'm going to specify with
respect to the four coordinates that I'm going to be passing. Once this is done. Then I'm going to define
the next function which is to prepare my data now as we've seen first comes
detection then comes preparing when it comes to it. I need to specify the path from where it has to pick up
the images for that matter. So let me come back. Let me show you
where the images are. Isn't now when you see
inside training data folder. Okay, I have actually
three folders present here, which is my S 1 S 2 and S 3
if I go inside as one you can see there is
a Ronaldo's photos. If I go back
into S 2 you can see that is Messi's photos. And if you see inside S3, this Robbins photos
present here now.

Let me come back
to the core now here. What I'm doing is
that I'm passing the path then I'm calling the phase function
as well as the labels. Now again, the phase is going
to hold the sub phases of all the subjects
and labels actually. Help me identify which
it belongs to as well. Now what it's going to do is that it's going to run a for
Loop wherein it goes through. Each of the images
is present in the path. Now again, what we have decided
or what we have started with the naming convention
is with s 1 2 3. So what it's going to do is
that it's going to check if the folder name starts with s because usually there are
system photos separately. So it is going to check
if the folder name starts with s if it does not then it's going
to go into the next Loop. But if it does it will check
that folder as well. Then what is going to do is that it's going to create
the label for it or it's gonna identify
which folder I'm presented.

If you actually go back inside
back to my training data, you can see I have specified
1 2 3 after this so it's just to help me identify which label
it belongs to as well. You can use any different
naming conventions that you want as such then
what I'm going to do is that I'm going to specify
where the folder or where the images is present, which is actually
one level inside this so I'm going to go
into the next directory. And then what I'm going to do is that I'm going to run a for
Loop for all the images. Are present in this if an image or a file
for that matter starts with DOT because system files
usually start with DOT.

So those are going to be ignored but others are going
to be recognized using my opencv where and I'm going
to read the image first. I'm going to show you a message
that says training on the data. I'm going to resize
the image to a size that is comfortable for me, which is 400 pixel
to find a picture. Okay, and then I'm going to wait
four hundred milliseconds for that matter. Now what you can see here is that I'm calling
to detect phase function which is present earlier. Yeah, so this again is a call
back to the previous function where it goes up and it actually
calls the previous function that we have created
to detect the face as well. Once that is done. It's also going to revert with me the position
as well as the face or the ID which it
belongs to as well.

Now if a phase is present
then I'm going to append it to my face list and I'm also going to add
a label to this face as well. Once this is done. I'm going to
destroy these windows because again opencv
creates a lot of windows, so I'm going to ensure that it's destroyed
by doing it twice as well. This is done. I'm going to return the This which I have and the labels
correspondingly as well. Now what you need
to understand is that here the faces here are
of different players as well. So each of the phases present in each of these images
is going to be segregated.

It's going to store
this into a location and it's going to start
raining on them as well. Then what I'm going to do is that I'm going to prepare
the training data. Now this again is something that is becoming a recursive
function for that matter. It's going to be
calling itself again where it goes back it
goes to one level up and it's going to
keep calling itself until I have trained
on all the folders which are present and all the images present
inside that folder as well. So once this is done what happens is
that it prints me that data has been prepared.

And then it also tells me
the total number of faces and the total number
of labels also present here as such finally
what I'm going to do is that I'm going to create
our LVH be faced a cognizer. So for this I'm going
to call the lbs be faced a cognizer function. So if you remember
we had discussed about three different
phase secondary functions, we're going to be using
the LBH be faced a cognizer function figure. The function has been defined then I'm going
to pass these faces so that my machine can learn and train itself to identify
these phases in future. Now, what I'm going to do is that I'm going to just create
a rectangle across their faces. So that becomes
a differentiating factor for them or helps them separate
where the faces with respect where and once
this is defined or once I have created a rectangle
across their face again, these XY heads that are the different
coordinates of the face, and I'm just going to draw
a rectangle across them.

And again, I'm going
to specify which color so this is your RGB value. So it's going to be
a green color box that's going to be defined
and I'm also going to print the name
of the person present here. So what it's going to do is that it's going to identify
which person it belongs to and it's going to print
it in hen seaplane. Okay. And what is going to do is that it's going to be printed
again in green color as well.

Now what I comes or now the most
important function comes which is prediction. Now in production, what I'm going to do is
that I'm going to pass an image the image copy
is going to be created. As we do not want to manipulate
or work on a single copy of an image because in case
of any challenge or any issues, we do not want to overwrite or lose the image
for that matter. Once this is done then
what I'm going to do is that I'm going to call
the detect phase function which in turn will help me
identify who the person is then what is going to do is that it's going to predict the
image using our face a cognizer and then it's also going
to print the confidence or how sure it is that this face matches.

Now what I want you
to understand here is that if my confidence
is low 30 that is if I'm not sure that this person's
image is correct or the phrase is detected then
what happens is if it is greater than 30
is going to draw a rectangle and then it's going to write
who the person belongs to and it's going to return
this image for me on the screen as well. Now why have two images that I'm going
to be passing here? If I just go onto my desktop images show
you first is abc dot jpg, and the second is wrong dot
one dot jpeg as well. So let me just show
you the images. So you can see here. I have drawn dot
one dot jpeg, which is an image of Ronaldo.

And I'm also going
to pass a b c dot jpeg which is an image of messy. Okay. So these are the two images
I want to identify and I will be passing
this to my program. Let me just run this program so that you get a full
fledged understanding of what we have written here. And you understand
how this works out as well. Okay. So once I've passed this image, then I'm going to call
the predict function so that it predicts whose face that this belongs to Two
or who's this face is as well. Once that's done. I'm going to destroy this now. I hope you've got
a simple understanding of this. If you are interested
in the code, please give us your mail ID.

We will be happy to share
the code with you as well. Now. Let me just execute this so that you get a clearer
understanding of this. Now, let me just zoom in
so that you know, so you can see it has started picking up
the faces for recognition. So you can see it starting
to prepare the data. It's checking out
all the images. It's reading the faces is trying
to detect the fuses for itself. Now you can see total faces are 22 wherein
it has identified 22 images and it also has started
to predict it and it's given me the confidence
of the face detection that it has taken place as well. Now the prediction
has completed for Ronaldo. It has successfully
predicted the face and it also has put in the text
and if you see for Messi also, it has done the same
but the text is very small here because the image has been
resized for that matter.

Okay, so it has successfully
predicted this it has detected. It also has recognized
it as well now. Has also told me who
this face belongs to as such for that matter. So this is how our face recognition
system works completed. Now, this is just one of a very my new door one of
the basics examples of this and if you want to create
a complete full fledged system, let me give you an idea
on that same as well. Now if you wish to have a very
great system out of something that's really effective
out there something that's not too hard
to build then this is something that you should really
consider place your camera, which is a wireless camera
on top of your door. Okay, use the Raspberry Pi
to detect the motion. What will happen here? Is that every time there is
a detection Raspberry Pi would detect this happens and then it would pass
on this information onto the cloud the reason
for doing this is that it becomes quite fast and it's way more effective in that matter as
well here the phase would be detected recognition
would happen all the information regarding these phases would
be present on the cloud itself.

And once it has identified that this is a valid
user then correspondingly. It will allow the door
to be opened as well. But what you need
to understand here is At this in turn can also be configured for you to have an application or a notification sent on
to your mobile application from the cloud as well. Because most of the mobile
application Epi is for pushing information is
very easily accessible and configurable on the cloud as such the Raspberry Pi has
become the most popular platform for exploring the no House
of Internet of Things.

It is redefining
the nuances for a new era of minimal operating software. And if it's
about operating systems, you can be sure to find Microsoft Windows just
around the corner. So we'll be talking
about the Windows 10 today, but not the one
on your desktops or laptops. In fact, not even the one
on your smartphones this Windows operating software
runs devices even smaller than any of those now, if you've been tinkering
with the Raspberry Pi you must try installing
the Windows 10 iot core on it and know the operating systems that come as a part
of the Windows 10 iot windows that is fairly popular amongst operating systems is
now available for Internet of Things is actually a revamp of the old operating
system Windows embedded but with iot taking the World by
storm the Windows 10 iot is now it's official operating
software for all everything's and systems.

Now the windows for Internet of Things comes
in three packages the Windows 10 iot Enterprise comes
for the embedded systems that draw more power
and require more resources like the bulkier systems
in high grade or industrial grade Machinery the Windows iot
mobile Enterprise comes for more minimal systems
like the ones in our televisions or handled it. Vices and the Windows 10 iot core comes for
the smallest embedded systems in iot like even minut
combinations of microcontrollers and microprocessors. So you can scale up or scale down these options
according to iot devices and the requirement now the Windows 10 iot code
is the smallest of the three operating systems
launched by windows for The Internet
of Things it in fact is the smallest operating system that Windows has ever had
and you will be happy to know that this one comes
for free now this windows for small devices is so minimal.

It's interface is unlike any of the other
Windows operating systems and it is almost like that
of a bear Windows kernel but it is just about enough to
power the things in iot run all of its applications and ensure the seamless flow
of data to and from the cloud. It also supports many other
words used in iot development, but we be focusing
on its installation on the Raspberry Pi today. Now, it's minimal interface is
for better convenience as whenever an application
gets deployed to run on the Windows iot core the
windows interface will disappear and all you'll be left
with is the application. Running on it. Now this is because the Windows
10 iot has been designed to run both headed and headless which essentially means
with and without a display.

So your device becoming the application
will reduce confusion while running headless. This also means that we can have only one active
application running at a time while there could be
other background applications running all that said
I think it's finally time. We went over the installation
of the Windows 10 iot core on the Raspberry Pi so I have a Raspberry Pi
3 here with me already and a class 10 SD card of 16GB upon which Be flashing
our operating system. And please make sure that you SD card is at least
class 10 and has a capacity of at least 8 GB without these you
might face compatibility issues with the windows iot
core operating system.

Now the Samsung Evo or the SanDisk Ultra
would be your best choices. So the first thing to do is
to format the SD card. I recommend using
the SD card format or software that is available
for free online. You could also use the default
format on your system, but I'd avoid using it as it
does not optimize the partition. Required by the operating system
and the storage on SD card and it compromises
on the entire capacity that is available. So go on with the SD
card for matter, so it is really easy to get
we start by opening a browser and typing SD card for matter
into it and hit enter so you can go to the first link.

And scroll down
once the website opens so you can see SD memory
card format a download for Windows and Mac since we need the Windows
operating system to flash the windows iot core or to
the Raspberry Pi will be going for the windows version of it. So click on it and you
download should be initiated. So once you download
is done find the setup file and install SD card format
Iran to system. I've already done that
so I will straight away go and open the app. And here it is. So you'll have to know which Drive is your SD card
mounted on for that. We can go to my PC or this PC. So in my case,
it is the F drive.

So I'll make sure that the card is wanting
to the F drive and I'll click on format. It will give you an alert saying that it is all data
on this card hit. Yes. There we go. Now we are ready for the windows
iot core download. So we go back to the browser
and we type windows iot. So the first website
is the official website for Windows 10 iot core. Once the web page loads go
to the download section and you can see there's
a download link saying download the Windows
10 iot core dashboard. So this is
what will be downloading. So we'll be installing
the operating system through this dashboard itself. Let's go to the download
folder find the setup file double-click on it. And click install.

So it's a 58 Point 1 MB file. So it is getting downloaded
on the Windows 10 iot core dashboard from
where we will be installing and flashing it
onto our SD card. So once the setup is done, the windows iot dashboard
should pop up automatically if it is not you can search it
on your system as iot dashboard and open it. So now with the dashboard
in our system, we can start installing
the windows iot core onto our SD card.

We can do that by setting
up a new device. Let's click on setup new device. So once you do that,
you can see a few columns that you will have to fill so
the first is device type. So I'm using a Raspberry Pi 3. So I'll choose Raspberry Pi 3. What? Was Bill do I want well, I want the Windows 10 iot core. So I'll click on that
which Drive is my SD card on its on the F drive. That's correct. And you can rename
your device from here. Let's say I'm gonna name it men win RPI and you'll have
to set a password for it. So I'm going to go
with our PI 3 win 10 have to repeat the same. Our PI 3 2010. So now that the passwords are
in place accept the license agreement and click
on download and installed.

So I'll give you a pop-up
about erasing the SD card click on continue. So you downloading has now
started so you might get another pop-up which is
the iot utilities trying to install on your system, press yes, then you should get
a command line window where the OS will be flashed
upon your SD card. So with that done, we finally have the operating
system on our SD card. There will be another prompt
asking you to format disk. Please hit cancel. This is very important to not
hit for my disc it on cancel. That's it. It says you guys
d card is ready. So go back to your mypcc. Make sure you eject
your SD card. Once it is safe to remove
take it out and put it back in your Raspberry Pi. So the next thing to do is
to connect all your peripherals to your Raspberry Pi and power it on now
most operating systems will require you to configure
some basic settings.

When you put them up
for the first time since the Windows 10 iot core is
the smallest version of Windows. It almost has negligible
settings to be configured. It will only ask you to set
up your default language and if you want to connect
to any Wi-Fi network, and that is it so now
upon starting the pie. You should see the windows logo. You can see the welcome screen
for the Windows iot 10 code now since it has been designed
for minimal and low-cost devices the configuration upon the first boot
has also been kept minimal so that does it for finally
booted into the settings of the windows iot core. So let us set the default
languages English and hit next after which it will ask you
to connect to a Wi-Fi network. Let us say we will skip
this step and You can also do it later
from the home screen or the desktop.

So that's it. You finally successfully
booted the windows iot core and it is ready for use. So here we have Katana
you can record your voice for better speech recognition. I'll skip this for now
and let's say got it. So this is your desktop for the Windows 10 iot core you
can see there's device info which is mainly a home screen. It tells you the IP
address and everything. There's a command line window. There's also a browser
and there are tutorials for you to make the most
of the windows iot code. This is settings button. There's a power button
as well other reason behind your desktop
being so minimal is that the windows iot
has been designed to run both headed
and headless applications so to develop applications, You can do it on your laptop
and then push it remotely it onto your Pi upon which the pie
will become their application. You can use the visual
studio for it. So now you can go back
to your iot dashboard. Now the iot dashboard also
offers some functionalities for you to remotely
control your pie or your windows iot core.

So you can go to the my devices
on your dashboard and you can see there's a Raspberry Pi
3 with the name mean when RPI the name that
we gave it in the start now. From here, you can open it in device portal
to our extended features. You can launch
a command line window. You can launch
iot Remote client. You can shut it down. You can restart it plus you
can add another pie to it. You can also connect it
to the Jour Cloud for intelligent analysis
and advanced cloud computing. And also there are
three packages which indirectly be deployed to your Raspberry Pi so you basically
won't need Visual Studio. You will not need much
of coding you can directly download these packages
and run them to die. The power of Windows iot core. So that's it. You can see the settings offers some basic preferences
this network in Wi-Fi. This blue to this. Katana is a command line window.

There's an internet browser and there are other
tutorials to make the most of Windows 10 iot core. So that will be all
I hope you followed how to install the Windows
10 iot code now looking at the rise in the Popularity
of Internet of Things. I've come up with this tutorial
to make sure you people pick or purchase the right
development boards for your iot projects. Now the adreno and the Raspberry Pi are you go
to votes for all things iot, but how are they any different and which one
should you be using? Well, don't worry by the end
of this session.

You could be educating
your friends on the same. But before we begin though, let me quickly tell you
what exactly I'll be covering in today's session. So for those of you that are still confused
on what these devices are. I'll briefly talk about
these integrated circuit board. Odes then we
compare their hardware and software specifications
understand their modes of operation check out
there available boards and finally conclude
with the purpose that each of these boats
have been designed for so without putting
it off any further.

Let's get started. The computers were
a breakthrough in the world of machines making
the operation of any device or machine smarter than ever and the motherboard
in a computer is what drove these operations either performing
logical instructions that have been fed to them or calculating outcomes based
on the information. They receive these
motherboards LED all parts of the computer communicate
and act by utilizing the CPU and the memory in fact
any peripheral connecting to the computer also
needs to connect to the motherboards
programmable input/output. Actors for their operation now these motherboards
are integrated circuits and with the world trying
to minimize the size of devices and make them more portable.

We now have a variety of
similarly capable circuit boards available to help us build
smart equipment of our choice and according to our needs. Only smartest development
boards today zero down to the Raspberry Pi and the Arduino
both these integrated circuit boards might have
a few things in common, but differ majorly
in the mode of operation and capabilities and if you've been experimenting
with the embedded systems, or if the onset of iot has got you playing with
these integrated circuit boards, then you must understand
the key differences between them and know the one that will be more suitable
for your iot projects.

So let me Begin by telling you that the Arduino is based
on a microcontroller and is mostly designed. To control the electrical
components connected to the circuit board
in any system. Whereas the Raspberry Pi
is based on a microprocessor that computes data and produces
valuable outputs and if required it controls
the electrical components and it's system based on
the outcome of its computation. So basically the Raspberry Pi
is a single-board computer with the Arduino is just
a single-board microcontroller. So let us start
with the comparison by learning more
about the hardware and software specifications of the latest models
of both these devices. Now the Arduino boards have a very simple hardware and
software structure the Arduino, you know runs on an 8-bit AVR atmega328
microcontroller on a chip, which has a ram of two kilobytes
upon an eeprom flash memory of 32 kilobytes and clocks are processing speed
of 16 megahertz on the contrary the Raspberry Pi boards
have a complex.

Lecture of hardware and software the
Raspberry Pi 3 B plus comes with a powerful
broadcom BCM to a37 b0 microprocessor on a chip as
its Central Processing Unit, which runs on a 64-bit
quad-core processor called the a arm cortex a53 featuring a static Ram
of 1GB running directly upon the SD card storage
at a clock speed of one point four gigahertz. Now this microchip also acts
as the graphics processing unit with the broadcom video
code for integrated graphics card building. It for low-power multimedia
processing now such a multi utility microchip
is being called a Soc or a system-on-a-chip these days and besides the processor
and the graphics card. They also house other
microcontrollers to control the electrical components. So there's plenty
of power packed into it. Even for many add-ons
or USB connections. Now most of the other Hardware, uh, pretty much the same
for both these devices like timers voltage
Regulators serial, peripheral interface bus has
into integrated circuit serial, you are and I/O pins, okay. Connectors but again, the I/O connectors
in Arduino are more capable than the I/O pins
in the Raspberry Pi which must depend on transistors
to drive external hardware.

I'll be Raspberry Pi is still
better logical processing which means it can compute even
complex mathematical operations enabling it to process and support audios videos images
and other gu eyes. So it's more like a computer
in contrast to the Arduino which can only control
path The device and would need additional circuit software and communication buses
to run audio video or any visual graphic at all. Plus the pie also
offers HDMI support. So all that you need
is just a screen or any display device removing
the need for connecting it to a computer all the time
like the Arduino now this is because the Arduino comes without any operating software
the only real software it has is for compiling code
to Machine level and allowing serial connection
for data transfer.

This is also why
it requires less power and could even get faster as it only needs
to compile code and use the chip directly
to control any component. Whereas the Raspberry Pi must enable all required
layers of software and utilize different programs to make any task
happen then again, it is also why the Pike
in multitask doing a variety of tasks at a time while the Arduino can perform
any single task multiple times. So the Arduino offers
an ID with the compiler and is the only one
that this device supports which means only the codes
written here will work and get compiled
on to its physical board this He uses basic C and C++ paradigms and breaks
down all its functions into accessible packages
making it quite easy to learn and operate however
with the Raspberry Pi which supports multiple
programming languages and software environments. You need to be proficient at coding to get
the most out of it. Also the pie now
comes with Bluetooth and Wi-Fi support
for remote connections.

In fact, its latest model
features faster Ethernet or dual band of 2.4 gigahertz
and 5 gigahertz wireless, LAN and an embedded web server while the we know features
Bluetooth on just one of its boards all the Arduino BT and will require
additional circuit for communication over
wireless networks or ethernet. Now these additional circuits
for the Arduino or called Shields and are attached to it
for extended functionalities similarly in the case of the Raspberry Pi
these extended circuits are called hats both are plenty of available housing
diverse functionalities sensors Motors actuators and software on them for interacting with
the physical world and driving external hardware according to It's
host devices capabilities. Okay. Now I can see
somebody has a question. So Debbie wants to know what is the most
popular programming language that is used for coding
with the Raspberry Pi.

So since the Raspberry Pi is essentially a computer
you can actually run code on it in almost
all programming languages. But the most popular one
in my opinion would be python as even the pies official
operating system comes with the default python ideally, which is the IDE for python. So I hope that clears you doubt
if there is Any more questions, please keep it coming. Okay. Meanwhile, I mean move on. So let me now tell you how you can identify the purpose
behind using either an Arduino or Raspberry Pi. So the Arduino being more
of a microcontroller motherboard is best suited for
repetitive tasks like reading and Reporting temperature
opening and closing of doors controlling lights or building motion
detecting alarms. It also works great for creating quick
and lightweight prototypes, but the Raspberry Pi is more
like a general purpose computer and is good at complex. Relations or performing
multiple tasks or processing a large amount of data.

So if you need
a full-fledged computer on a very small scale the pie is
what you should be looking at. So let us now move on
to the different boards that both have had over time and look at some
of its prominent ones. So the Arduino has been around
for quite a while now and has had multiple
boards over the years with different functionalities. Although the Arduino, you know, the Arduino Mega they
Do you know lily pad and the Arduino Bluetooth
have been the more popular ones? Similarly? The Raspberry Pi despite being relatively new is
on its third generation with each of its models
better than the previous ones the Raspberry Pi 3, B+ is its latest and most
powerful development board yet in the session.

We'll be talking
about the top seven projects which are outstanding
themselves in the Internet of Things domain now, let's talk about Each
of these projects. Let's start with number 7,
which is a biometric system. Now a biometric
system is something that we always encounter
on our daily basis as well because we always
either use a fingerprint sensor or we use an iris scanning. So it depends from
organization to organization. But how does this actually
work the system there? Let's take in case of this example has
a fingerprint scanner. Now the first time that I
am presenting my fingerprint, it scans the fingerprint and considers this as
part of an enrollment.

Us from this fingerprint
template what it does is that it extract
certain key features, which makes it different
from others and stores it into a database from then
forward every time that I place my finger on top
of this fingerprint scanner. It creates a template and Compares this
with all the templates that's present in the database if it matches
then correspondingly, let's it gives me an attendance
or lets me access at or if it does not then
it raises an alert with respect to that same now. This is just a foundation now as I said this biometric
system Fingerprint, it can be is scanning or it can be a combination of both as well as
voice recognition system is one of the key products
in the biometric domain next.

We have Smart irrigation system. Now I am someone who personally likes
gardening a lot. Now, this is something that would really
make my life easier because usually what I do is that on Sundays I spent about two hours just
watering and looking after my plants through
a smart irrigation system. What it does is that it checks the moisture
present in the environment or in the water lanes that I
have created now to help. You understand how it works. Usually there are two main
Internet of Things devices that are used here, which is the Arduino board
and the Raspberry Pi your Raspberry Pi becomes
the main processing unit. And I place an Arduino board
for each of my water channels.

These addressing modes
themselves are connected to multiple sensors which are part
of this water channel. So what these sensors do is that we check the moisture
present in these lanes are such so let's say a specifically in does not meet the minimum
required moisture then what it would do is that it will Send a signal to
the Raspberry Pi again.

All these devices are connected on the same
wireless router Network and the Raspberry Pi
would identify the lack of moisture and pass
the signal to the relay. The relay in turn
would initiate the water pump and water would be pumped now
in order to ensure that water is not wasted we
would create gate controls and only the gate where the moisture is less. Would the gate be open
once my sensor detects that the moisture level has gone beyond my required
level it would Against another signal to the Raspberry Pi asking
it to stop the pump as well.

So this in turn helps you
to save a lot of water and also makes your life
quite easier as well. So after this your only task in your garden would be is
either setting up new plans or creating new water channels
as such the next project in our list is a security camera
and door unlock system. Now, this is something
that's quite interesting and I have personally
tried this out and it's really something that you should try
out as well here.

What happens is
that you place a camera on top 40 Which in turn
clicks the photo of a person who comes into the frame now, this photo is again sent
to an analytical system which in turn Compares this
with all the photos that it possesses
in order to identify whether to let the user open
the door or not now and evolution to this is that if it does not find
the photo of that person it can notify the concerned person that so-and-so person
is trying to access this dough. Would you like to
authorize this person and address information
to the database or would you? I'd like to deny the access
to this person as well.

Usually this is used in areas where you have high
sensitive information stored in order to maintain
a strict control to the access to this information
as well another usage of the security camera and door unlock system
can be even at our homes when we can identify who's come at our home
when you're not there and either decide to give them
access to our homes or not. Now the next thing is something that we all really
decide to have which is a smart home system
a smart home system can be something
that really makes. Life quite easy starting
from energy management where the light control system
is the AC the appliances that we use the thermostat
all this is managed in short trying to cut
down the power consumption that's taking place by door management system
is also part of this.

My security system is also part of this my water management
system again becomes a part of this as well. Again, these are key things that really stands out
in the smart home system. But again, what I
would personally recommend is that a Smart Homes
limitations is where our imagination stops anything that you wish to automate
or make wish to make your life easier can be part
of a smart phone system as well. Now a smart home usually
is going to be a base for our next project which is a smart City
a smart city is an evolution of a smart home here. It's not just the sensors
of a single home that is connected here. It's correlation or a network or a connection
between various organizations various domains as well
as various segments of that city as a whole
as such Judo the life of every single dependent person in that City becomes easier
as a whole as well and in turn will really
help develop that City to Greater extent such now
the key factor here for a smart city is
a government support as well.

And if governments are
really willing to take this step then I hope we would see
a smart City completely built on internet of things maybe
the next 5 to 10 years as well. Now the next
project is something that really stands out
on a personal level this this is Zelda Ocarina controlled
home automation system. This is personally something that I feel is the closest
to a smart home system where most of the elements of the home is completely
controlled by an Ocarina what Alan pan has done here is that he's created
a node-based recognition system, which completely automates
his hope but rather than telling more about this. Let's just look at a quick video which will give you a glimpse
into how he has done this and what has he done. 7:27 p.m. Next on our list at number one. If you've not already guessed is Jarvis Jarvis is the
artificial intelligence system that Facebook's creator
Mark second Berg has built for his home automated system. I'm quite sure you've
already seen the video of Mars are kannberg interacting with Jarvis which has
Morgan Freeman's voice.

And if you've not, here's a quick glimpse
into the same. Good morning, Jarvis. Good morning Mark. It's Saturday. So you only have five meetings
room temperature is set to a cool 68 degrees
earlier this year. I started building a simple AI
to help run our home. I talked to Jarvis
using this app. I built it uses artificial
intelligence to understand me and figure out what to do
Max woke up a few minutes ago. I'm entertaining her. All right. Let's go check on her. Good morning. Let's practice our man.

Zhao Xiang Hao Jarvis
your Mandarin is so soothing she she Jarvis also helps
me get ready in the morning fresh shirt Byron home. Hell yeah, Jarvis knows when to
make me breakfast. Your toast is ready. All right, it's time
for my call with shrap. Can you get him
on the video conference line setting up the BC room. Now remember to check on the AI
guidance system for tequila. One of the best things about
Jarvis is it could recognize people at the gate let
them in automatically and then just tell me about it Mark your parents are coming in. Thanks Geoffrey. It's Jarvis and Jarvis can play
all of our favorite music.

Hey play some good. Go back songs. I'm sorry Mark. I'm afraid I can't do that. There are no good
Nickelback song Good that was actually a test. Okay. How about just play some songs that are whole
family likes what? I'm a dad. Now. This is what I listen to. No, what you need
to understand here is that internet of things
is not something that's just dependent
on a sensor or a few sensors, which is connected
to a Raspberry Pi on adreno put when I look at the entire
architecture of iot. This is a complete ecosystem where in my sensors
gather information, which is again stored
on a platform and then processed on this now if there have been
any issues or failures that have been reported
by these sensors, then I need to create
actionable items.

In order to ensure that this is never
really repeated again, but the information
wants to spin process the process data is then passed
into machine learning and artificial intelligence
in order to understand analyze and identify various patterns that's out there and help
pass this information on back to the sensor
this in turn helps. You have a better experience and also improve the system
as a whole a system where I come home every day at 8:30 start off
my Casey wait 15 minutes for it to cool down is
a tedious process. But it's a today my Internet
of Things platform identifies this pattern already switches
on the AC at 8:15. Then I just need to come home
and I can relax right away. This is just one
of the key examples of one of the key ideas that's out there today and the limitation here again
is just your imagination. It is so good to see that so many of you
are keeping up with the trends. Of technology today. So let us dig deeper
into these devices that Mark the beginning
of every iot ecosystem and look at the best ones in use
today in different domains.

But before we start
don't let me quickly run you along the outlines
of today's session so that you have
a clear idea on the topics that I'd be covering. So first I'll be telling you
how you can identify any object to be an iot device. Then I'll tell you what they
can do for you and cite some of the major use cases on it
and then I'll tell you how iot devices are shipping
the entire world and code some leading examples and then I'll tell you
how secure is. The device in iot and finally, I'll be telling you all
the important things that you need to know
to build an iot device. So without putting
it off any further, let us begin our session today.

Now these devices that play the role
of things in iot are what make the smartest
systems possible today be just a smart Appliance
or an entire Smart City. It could be complete
Computing devices designed keeping the portability in mind or tiny electronic
components operating on minimal device software
for data transfer and Activity without
any Computing abilities at all and there are also objects that are not made up of
any electronic Hardware at all and can still become
the things in iot by having these smart things attached
to them in summer the other way. So what I'm basically saying is that even we humans
can become a thing in the internet of things. But again, that is a contextual top
and you'll understand why as we move on with
the session today.

So for now we can just say that any device however puny or powerless with
the ability to receive or send data allowing
it to communicate over networks can be called
a thing or an iot. Ice also, it should be serving
a purpose like either collecting some information or
delivering some outcome. Now that is the least
any iot enabled device or thing in iot
will require today, even though the bigger devices
have diverse features and can be more powerful. It is a miniaturizing
of computer hardware that has truly given
the Internet of Things its Edge in the market today. It is made it possible for these iot devices to even
function and microscopic levels in the remotest corners
of our world. And as also Borden focus on more Target oriented features
specific to their goals, Plus with devices running
on incredibly low power levels and operating with
such minimal resources. The things in iot come
with the promise of implementing Solutions in the most cost effective way
possible without compromising on the system's accuracy.

This is because at the smallest
levels these things are embedded with just enough technology for them to communicate
over the internet and other networks to get
the data analyzed stored and processed over that Network or over the cloud rather
than physically housing. All those Technologies
on themselves. Also such low power levels
are perfect for the lead. Our chips sensors
and other low energy components that is devices used
for the operation. But like I said, there are substantial equipped
to connect wirelessly for exchanging data and Performing
actions based on them. Also such low energy modes
of connectivity make it easy for these things to operate
just about anywhere while letting us control
and monitor them remotely for almost any part
of the world.

So it is as if the British technology Pioneer Kevin Ashton
who coined the phrase internet of things back in the 1999
somehow knew of these potentials that I would have brings out. Devices today so
let us move on now. Let us see what things
can do for you. So one of the most popular
implementation of these things and their applications
have been in the sector of home automation today, the use of Internet of Things in this industry
has got the world closer to achieving a dream home
powered by the smartest systems using these iot devices and these systems
have been built such that all its devices can intercommunicate to allow
owners a customized access. To all aspects of your home like your lights your logs
or the inside environment or security cameras or even your total energy
consumption with the brand specific IOD platforms
and clouds behind them. These iot devices are
now capable of exhibiting ambient intelligence and also stay connected
to the internet for driving real-time operations. So let us get into some examples of iot devices used
in most Smart Homes today, and we must begin with the
tunable smart Lighting systems like Philips Hue
smart home lighting or the tp-link.

Color Smart Wi-Fi that can be easily controlled using your smart phones
with the option of creating custom
lighting automations from anywhere in the world
by just being connected to the internet
with smart lights like these you could turn
them on or off anytime and tune the color and the brightness of Lights
in your home's remotely no matter wherever
you are moving on. Did you know that locks and keys are getting
old fashion nowadays. It's not a joke. Smart locks are a part
of almost every smart home today and the August smartlock
third generation is one of the newest and the phones
on the market today. What makes it Stand Out
Among its peers is that it comes
with bluetooth support so that you won't need to worry, even if your internet is down
somehow with a device like this that attaches to your existing
that bolts you will always know if your door is
completely closed and locked with its doors and Technology.

It'll even remind you
to lock your doors when you leaving or tell you if they were properly closed
or not based on the location of your phone, you can even create
secure virtual or temporary keys for your neighbors and guess just in case now the next iot device is Nest
learning thermostat it is one of the best examples
of an iot device today as a part of your home automation system this intelligent device
Lawns your schedules and preferences over
the first couple of weeks too smart in the cooling
and heating systems in your home and then regulate
your home temperature automatically to save
electricity by 20% among a ton of other features. So to reduce your energy bills, it uses sensors and your phone's location
to realize the whether the time or the environment inside and when nobody's home it
will shift into energy saving.

Mode apart from the
thermostat Nest also provide smart cameras with smoke and carbon monoxide alarms to better manage
your home's atmosphere and Security Plus it
lets you manage and monitor each of them
through its dedicated app or even build your own
Revenue channels upon them. There is also one more device
that I think is worth the mention in the home
automation systems of today. It's mostly just a doorbell
for your front doors. Only a lot smarter
the video dogus by ring is a modest name
for all the things that it can do. It's like Always home as it lets you answer
your door from just about anywhere it will in fact, even a lot you of motion
within 30 feet of your door and stream its live footage
onto your phone. And if somebody rings
a bell you can let them know that you're not home and even have a word with them with its right Vision the wide-angle high-definition
recordings get simultaneously saved were Cloud
for your use anytime. Now before I tell you what else iot devices can do for
you virtual or home assistance like the Amazon Alexa
the Google Assistant Siri and Jibo are also attending
application of the internet of things and have made it big in the home automation
systems of today.

Now, other than making
your Home Smart iot devices are also capable of intelligent Lee
tracking your health and fitness and as far as Fitness
goes the Fitbit tracker or the Apple watch and other such smart watches
have been a revolutionary success and along
with your Fitness aspects. They also solve your day
to day Health Care needs like checking your heart rate
and perspiration levels and tracking your body
temperature to predict a cold or a flu on the Are you
will be amazed to know how the other iot devices
are saving more lives and making Health Care better like the Philips Healthcare is
medication dispensing service or the hero smart pills
dispenser are the most successful use cases today and exemplify the potential
of iot in the healthcare sector.

It is the perfect reminder
for your medications and is a convenient measure
for the elderly and the sick alike with the option to remotely
manage it with your smartphone. You could also
monitor the medication of your near and dear ones
and be notified upon running low on any Medication at all plus you could also get info
on the right medication for common health hazards. And now with how integral smart phones
and internet have become in our lives Health and Fitness Solutions
using iot will only get more and more prominent
in the recent years to come.

So apart from
the personal benefits that you can get as a consumer
or user iot also aims to impact the greater good the talk of smart cities
is prevalent these days where the waste management
system is more efficient. You shall in the environment
is checked and even the outdoor lighting and traffic signals are equipped with motion sensors
to ensure energy conservation by turning on only
upon detecting traffic updates and its route or upon sensing pedestrians
and Vehicles nearby.

Now, let us look at some
of the other sectors of service and Civic amenities that these iot devices are
powering to up the efficiencies of our world today. One of the most visible
Smart Systems in place is in the domain of transport
and Automotive today and along with more and more
connected car platforms today there has Also
been a lot of hype around smart and self-driving
Vehicles hitting the lines of Transport very
soon plus with the maps providing real-time Intel and the modern vehicles housing
numerous sensors in them. You could always tell
which way to go or what parts need to be looked at. Like say tracking the Fulton's
option altitude and maintenance issues of flights
in real time without waiting for it to land every time
can help in anticipating problems to schedule maintenance
prior to its arrival.

So that deal is
and mishaps are minimized in the aviation industry
another major area of Application for
iot devices isn't the field of Agriculture or sector that is often neglected. Despite. Its utmost importance can now
be brought up to speed with iot with several cheap
and minimal sensors that monitor the best climate
and soil quality for the right kind of crops
or other smart devices that ensure the efficiency
of automated irrigation systems, even the gardens in your home
or the trees in smart cities or even the plant life
and vegetation in agroforestry or wildlife habitats could be kept in check the most
Innovative iot devices to they include the smart
watering system Blossom, which can create
optimal wanting she Duels for all the plants in your home
based on real-time weather data and forecasts and will regulate
all your sprinkles accordingly and allows you complete control
over them through Bluetooth or the internet and also the clean grows carbon nanotube probe is one of
the best iot devices for farmers and gardeners all around the world today with
sensors to monitor the intake of nutrients in the crops to
better manage farming resources and improve the quality
of their fields farmers can now order Maturity rate and the color of props
for better yields and faster.

It's a production now. It might be a little ironical
of me to talk about one of the very first Industries
to be made smart on such a late note
in today's session, but I really just wanted
to save the best for last and believe me the sector
of retail and Logistics is where the internal things
promises the most astounding results with iot devices already
being extensively used in shopping restaurants
hospitality industries and many other
businesses to control the supply chain effectively. And obtain valuable
insights based on them and manage their logical
or merchandising expenses in the best possible ways. Now the Q hop is one of the leading examples
of internal things being used in the retail today typically designed to bring in
seamless autonomous check out Technologies to
all retail verticals by digitizing the checkouts
through RFID tags that only unlock
after its payment is processed.

The sole purpose behind it was to allow users
to sell check out in stores. Although it is mainly used
for security reasons today to inhibit Petty thefts. Doors, but guess what that was before the Inception
of Amazon go earlier this year. Now the technology inside this convenience store
will really seem like it was pulled out
from the future somewhere. Although it is so new that there are
only three locations with this feature
has six toes so far. So operate and are managed by
the online retailer Amazon. These stores can give
you a shopping experience unlike any you've ever had before with the idea
essentially being grab-and-go. These stores will just
need your Amazon go apps for you to enter
and then employees. Eurovision machine learning and Sensor Fusion
to automatically add items that you pick instantly on to your virtual card
will also remove them of just as promptly if you
keep them back now once you've grabbed
all the things on your shopping list and are
ready to exit all you need to do is just walk right
out of the store.

Yes, no more lining up
in busy cues of the usually limited checkout counters to
wait your turn for the purchase. You can exit the store without even having
to pull out any cash or a card and you will find
the amount for all the things that Walk out with the beaded
simultaneously from the balance in your Amazon account such
a smart system could also check the inventory regularly
to notify retailers on the need for restocking and even helps to manage
the supply chain and a better way.

Now, there are also other
promising areas in logistic that iot devices have started
to unpack like in the case of shipping cargo or Fleet
Management smart Bluetooth. Low energy tags are attached
to the items being moved for remotely tracking the exact
locations speed of transport and storage conditions. For instance. The things dot IO is
a simple iot platform that provides a dedicated
cloud-based dashboard for better Logistics
by enabling access to real-time and reliable inputs from it's
connected smart sensors and paired location trackers
irrespective of wherever they might be so although use cases and the respective
iot devices are things. We just went over
our only a select few of the countless applications
of the internet of things that can drive almost
any sector today and these iot devices
could be things themselves or even attached to someone or something to make
it a thing in iot. Like even a person with a heart rate monitor
could be a thing in iot as it collects
and provides information that can act as inputs to other Smart Systems
to operate on so the Baseline for anything to become
an iot device could be laid out as any object with a unique IP address
for communication over networks and the ability to gather
and transmit data or receive data and perform tasks based on it and the Ameri technology
in these devices are what interact with
either the internal States or the external environment.

To capture all data and drive decisions
made up on them. Now with the internet
of things being such a large community of different
devices the challenges of iot devices mainly start with
communication as the protocols and languages used
by each of them vary. Hugely due to the lack
of common standards for all of them yet and this lack of a uniform and secure standard
across all iot devices, which is great security risks making them highly unreliable
for most important. Missions are into
operations today. Also without customers
being assured of the privacy and security of the data. There is just no reason
for them to risk using or adopting such
insecure Solutions. Do you really understand
what the role of security and iot devices is today.

Well, let me tell you
about a major Cyber attack that happened back in October of
2016 a large distributed denial of service attack dubbed
Mirai affected DNS servers on the east coast
of the United States which disrupted Services
all across the world upon further investigations. This issue was tracked
back to the hackers that infiltrated smart networks through the iot devices
being used in them like the routers or the camera.

So that brings
about the situation. We're in our devices and data
are all remotely connected and stowed upon these networks and its security
gets compromised. We might even not know it
over the first few days or weeks and it might be just
too late by the time we do realize now the way in for these hackers were
undoubtedly a result of poor practice at some end like say the use of default
passwords rather than changing. Hence, the adoption
of better practices and the reinforcement of proper authentication
Network segmentations encryption and cryptography can
still make the things and its systems
quite secure given that we start making sure
of building them up securely from our end as well plus the issue of overall
connectivity is also a feat that our world is still
driving to achieve but hasn't been able
to accomplish it.

That brings us
to the last topic for today. So let me tell you
the important things that you should know
to build an iot device. So building an iot product or device or solution
must be done thinking about the relevant purposes that it can serve and the ways in which they
can be prepared to work for at least the next couple
of decades along with the option and space for
quick improvisations and upgrades and just like we saw in all
our examples today.

You must have understood
the two important categories that iot devices
are mainly made up of the first is the hardware
as And the underlying room is to aggregate the hardware
in the most minimal way. You can without compromising
on the primary features that you want
your device to use. Now. These features are mostly due
to Bluetooth low energy sensors or beacons connected
to the internet or a customized product with
probably a combination of these on a circuit board made up
of a semiconductor like Silicon and may also house
or the components like transistors resistors
receivers transmitters actuators and integrated circuit
or a microchip. So the most devices
like a smartphone or a result of such combinations
on a little more complex level with proper casing and with the second
most important aspect of these devices. So the second important category in iot devices is
the software aspect on the device level the size
of your software will depend on how minimal or bulky your device is.

And what are the components that your housing on it
on the most basic note. The device software only needs to be enough
for handling the operation of your device driving
components to collect data and converting them
into transmitters. Fun connecting two networks
driving the transmitter to send data and the receiver to receive
data to and from the network and converting it to the machine
understandable form for driving components to perform
some task or display. Some outcomes based
on the received instructions. Now all this will require
very minimal software unlike the software
on your phones that come with entire
mobile operating systems all the other important
software for intelligence and smartness in these devices would be provided by the
underlying Cloud infrastructure and even by the Mobile apps
or web dashboards. The software aspect
of iot devices is in fact what controls the hardware
aspects to sense some information or
perform an instruction while both aspects are the most
integral parts of an iot device.

You might also need
to overcome a few more hurdles before you iot device
is truly ready to implement smart Solutions and Power Smart Systems
of our world today. These hurdles could
be connectivity issues or compatibility problems or
security and privacy concerns, but don't let
the obstacles dishearten you in Just consult people
with knowledge on the same. While the Internet of Things
equips a multitude of domains and millions of devices
with connectivity every day. There are still a few domains, which I find a tad
more interesting than the others and they are iot in everyday
lives iot in healthcare in smart cities agriculture
Industrial Automation and finally in
disaster management first, we have Internet
of things in our daily lives. This is probably a Hallmark
in the iot industry as it's also One of the first industry is
to deploy iot at its service. So let me give you an example of how iot can service
in our daily lives consider a home appliance
such as your AC currently, what you do is that you go home you
turn on your AC and wait for it to reach a temperature that you like say about
25 degrees Celsius.

So does anybody
see a problem here? No one that's probably because there isn't
a problem here. This is a perfectly
functional setting. But what if it could be better what if when your car
was five minutes away your AC received a message. What if it was
connected to a cloud which had a dashboard containing
all the relevant information like the location of your car
the outside temperature and the temperature at which you liked your room
your AC could then turn on before you arrived
and create an Ambience that you like? Wouldn't that be something? Well, you can remove
all the waters from the previous scenario
as this no longer. Must just be a figment
of your imagination. Thanks to the internet of things
iot can connect your fitbit's to your vehicles
from your smart phones to your in-flight services from
home appliances like your ACS to whole entire cities. Maybe this is what Kevin Ashton meant
when he spoke of this concept where every area sensor man
and machine could be connected to one another. So I hope you all are
with me till here.

So next we have
iot in healthcare. I'm sure most of you have heard about the Smart Medicine
dispensers by now as the name suggests. It's basically a smart appliance that stores dispenses and
manages your medicines for you. Now. This is a very small piece of a very big picture
the health care and the general practice of medicine majorly
faces issues in one or more of these three things. We have your research
devices and care. Medical research has to rely
upon leftover data in control settings
for medical examination. It lacks real world data, which can solve
critical conditions iot could be the answer to all
these problems The Internet of Things opens ways to a sea of valuable
data through analysis and real-time testing Internet
of Things empowers Healthcare professionals and
improves the quality of care. Finally It ultimately
reduces the unsustainable. A high costs of medical devices. So here is an example. This is basically an outline
of how a care device Works a care device
has certain parameters that are considered safe. Once one of them is breached the sensor immediately
realize this message via a secure gateway
to a cloud now.

It is vital for this
gateway to be secure as it holds all your valuable
medical records the cloud then passes a remote signal
to a Mod device that is monitored
either by a nurse or a caretaker at home. The beauty of remote
patient monitoring is that patients can now
replace a long wait at the doctor's office
with a quick check-in data share and instructions on
how to proceed iot. Hence Bridges the gap
between reading devices and delivering Healthcare by creating systems rather than
just equipment with that said, let's move on to one
of the most talked about prospects of iot
the smart cities.

Now the thing
about a smart city. Is that a smart City solution is
very specific to that one city. The problems faced
in Bombay are very different than the problems
faced in Delhi. Even Global issues such as Waste Control
traffic management availability of finite drinking water housing and pollution impact different cities with
different intensities. So the only way to really
make a city smarter. Is to cater specifically
to its problem one such problem consistent among most
Urban cities is traffic. So imagine an intelligent device like a traffic camera a camera
that can monitor the road of traffic jams
accidents rains Etc and communicate that status
to a Gateway.

Now this Gateway also receives data from various
other cameras from all around the city this in itself could form
a Citywide traffic system. Now where can we use it? So let's say the municipal
Corporation has decided to repair a road which connects to a highway
for more than one city. Now this could cause a massive
congestion a smart camera could send this insight to the Citywide traffic system
now considering this is a smart traffic system
it quickly learns and predicts
patterns in traffic. It will analyze the situation
predict its impact and relay this information. Two other cities that connect to the highway via
their own monitoring systems. Now the traffic
Management Systems, then can derive routes
for cars around this projects live instructions could be sent
to drivers via radio channels and their respective
smart devices. What is a bonus is that if there is a school
or an office building which has no other way but to use that road
under construction, they can be automatically Ali
called and asked to reschedule this creates a network
of self dependent systems which leverage real-time control and this is just one example
of the potential benefits of iot applications.

So next we have a sector which is most neglected
despite the importance. It holds that is agriculture. However manual handling
often results in loss of energy labor cost
and other inaccuracies, which may call its Is
less effective internet of things here can provide with the number
of solutions Precision farming smart irrigation and smart Greenhouse
are a few to name. The first two cases are
pretty similar as in both cases. There are sensors
detecting various parameters at each level of the soil. We have moisture
content temperature and weather conditions one can tell the correct
depth to so the crops or the right time to water them, but One of the more
intriguing Solutions is the Smart Greenhouse a lot
of you might be wondering what is a greenhouse. So the greenhouse is
a farming technique where you can increase yield by
controlling natural parameters. So if we could use embedded
devices in these greenhouses, we could not only just
monitor it regularly, but we could practically
control the climate inside the greenhouse. So how the system works is that the sensor sends
various Toes and areas of issue inside the greenhouse.

They then relay the information
via a connection gateway to the cloud which then sends remote commands via the same Gateway
back to the sensors. So once these signals
are acknowledged they are passed on to the switch gear which then activate
the lighting pumps and turbines inside the greenhouse which then create artificial
sunlight and sometimes artificial precipitation. Inside the greenhouse what more
from the connection Gateway as you can see, there is a monitor through which 24/7 real time
monitoring has come into effect. Also, you could use any smart
device to remove the conditions inside your Greenhouse.

So with elimination
of irregularities and human errors, this creates a much
more efficient system. So with that we conclude
the role of Internet of Things in agriculture. So next we have another domain where iot could prove
to be a game-changer? This is one of those fields where both faster developments
as well as the quality of products are the critical factors for
a higher return on investment. I'm talking about the
Industrial Automation sector, but there are still
a few problems that need to be addressed in this sector. I think you all might
have already guessed. What I'm going to say. Well I OT comes to the rescue
Again The Internet of Things improves the line
of command immensely. It optimizes packaging and makes quality tests
so much easier to run what more you do not even have
to worry about the training cost of too much staff or a lot
of stuff going on a holiday because these factories
pretty much run on their own you can monitor
the supply chain in Real time while keeping an eye
on your inventories with iot applications one could
even re-engineer products and their packaging to deliver
better performance in both cost and customer experience.

So this brings me to the final
application for today that is disaster management. Now the iot cannot stop
disasters from happening, but it surely can help in preparedness and resilience
during one due to high. High population density
poor evacuation infrastructure and exposure to severe weather
events developing countries are more exposed to the risks
of natural disasters and often have limited means
to sustain the effects as a consequence according to a study
more than 95 percent of all deaths caused
by a disaster occur in developing countries
iot can compensate for this by prediction
preparedness response.

And Recovery to rescue
developing and emerging countries from their
vulnerable positions. Let me give you an example
of a forest fire where iot could be used as
a solution to be prepared for critical incidents. Like a forest fire sensors are
installed near the perimeters of the forest. They contribute to data feeds about temperature and carbon
emissions to a control room, which is common
to the entire town.

This is done
via a secure network. Gateway in real time, they anticipate problems
and put defenses in place to mitigate
that impact namely the police the nearby hospitals and most importantly
the fire brigade if such an emergency occurs
near urban areas people and communities are alerted via social media conventional
media channels and SMS. This brings me to the end
of all applications that I had listed now
that we've gone through a few. Applications of iot let's move
on to its future scope in just one year internet-connected devices went
from five million to billions, but there are still a few areas
that need work.

So the device is forming
the base of iot Are Wireless in nature and recite
at very remote places where energy is
a very vital issue. So with growing functionality
of each device, we need algorithms and Hardware
that are energy efficient. To avoid quick
draining of batteries. We need to make sure that sensors are active
for longer durations, like any other
advancement in technology, even in iot security
is a standout issue. This issue keeps getting bigger with more and more
devices being connected to one another we need
information seclusion methods to benefit end clients and secure that
data and privacy. No, it will be really tough
to implement the anytime concept of iot in reality, but this needs continuous work and the closest we
can get to this is only by reducing the complexity
of each existing time systems. We need continuous work
to reduce the gap between near real-time and actual real-time iot
applications promise to bring immense value into our lives.

In fact the number of Openings
for iot professionals is at an all-time high. So I think it is
the best time to begin exploring the true potential of
this technology from smartphones to Smart cards to that Fitbit
on your wrist iot represents millions of rupees
of potential for an industry as The Internet of Things
becomes more important for companies of all sizes. It professionals are beginning
to seek out roles. Related to this growing Niche. So before going
into the session, let's quickly look
at our agenda. So we'll start off
by discussing a little bit about the current scenario in iot market trends
current salary situation and projections in iot and how it compares to other sectors after which
we shall see the salary Trends in iot by both experienced
and functional areas. Also I shall be talking
about the companies that are hiring for iot
as well as the roles they offer then I shall Discuss
the skill set you must acquire before applying into the sector. And finally we will see
an outline of the training provided a Teddy Rekha. So without Much Ado, let's get straight
into the module.

So with the proliferation
of connected devices iot has ventured successfully across
all working areas in India and abroad India
is quickly becoming one of the largest hubs for iot across the globe companies
are viewing iot as a key enabler in various fields and are Come to integrating it
into existing infrastructure as the adoption
of iot has increased iot Market is also expected
to increase quite exponentially. So with that let's talk a little bit about the salary
Trends and projections. Now the median salary of iot professionals is
15 Point 2 lakhs per annum which is according
to the 2017 study this figure compared to the 8.65 lakh
per annum in the eye.

It sector gives about 76 percent more to iot professionals iot
being a relatively new entrant Professionals in this area
are commanding higher salaries. This number is predicted
to go up as much as Seventeen point five lakh by 2019. So let's see how iot does compared
to other contemporaries? Like I said before I
OT pay is 76 percent more than the it sector
interestingly only 33% of iot. Specials have salaries
under 6 lakh per annum as compared to 58% in the it sector
also we can see around 16 to 18% of iot Professionals in India
earn in a salary bracket of 10 to 25 lakhs
per annum almost 5% of iot professionals occupy. The largest salary bracket
that is 50 plus LP a while. In other domains barely two percent of the workforce
commands this figure with That said let's look
at the salary trends for it Professionals in India and the US according
to the current Financial year. So what I've done
is I've divided this into two parts salary is
according to functional areas and then according to
the experience level first up.

We have salary Trends
by functional area. Now as you can see, I've divided this
into four functional areas, which majorly command
the iot industry one is embedded systems
next system programming then we have the Engineering
design and finally application programming
in one end of the spectrum. We see application programming
being the highest paying job in India with an average
of 13 lakhs per annum whereas its us counterpart pays about sixty nine
thousand dollars per annum on the other side
of the spectrum. We have embedded Technologies, which pays an average
of eight point two lakh per annum in India,
but in u.s. It is the highest paid
in the sector with an average of $9,000 per annum
the system programming and engineering design sectors lie somewhere in between
with 11 point 6 lakh per annum and 10 lakh per annum respectively as for the
experience level more than 90% of freshers in the iot field
fall under the 6 lakh per annum salary bracket, which is not a bad
number for a fresher on the other end somebody who has a decade of work X
in this field can quote up to a 30 + L.

Your salary now. What is interesting here is that from each experience level
bracket to a higher one can lead to almost 50 percent jump
in the salary with this. I think we've covered
the salary aspect of this industry. Let's move on
to the career aspect of iot. I'm sure a lot
of you must be waiting for me to disclose
the names of companies and the roles they offer. So the concept of iot
has given rise to a new era of economic growth and companies are Looking
at it to transform their businesses now here
you can see two types of companies firstly there are
companies like Dell and IBM which have a vested interest
their core products and services are built
around delivering and facilitating iot, but there are also companies
like Verizon and Accenture where it is more
about preparing for the future.

Although iot hasn't completely
changed the face of it. It has definitely
created new opportunities for job seekers in the markets. I Be elaborating on this
in the following sections of the module which brings me to current roles
for iot professional. Now if you were to ask me
what field do you need to be in to land a job in iot the answer
would be many iot works on many layers software
plays a key role in usability and functionality Network layers are key to infrastructure and
Hardware defines capabilities and development opportunities
involved in an iot solution. Existing professionals
with transferable skills will definitely find progression
opportunities with iot. The iot is based
off of many technologies that it professionals
are already familiar with IP experts both software and Hardware engineers. And even UI designers could find
themselves to fit in somewhere in the industry. These companies could be ranging
from startups to Tech giants that are driving the industry, but with various domains that have adopted
the potential usage of industrial IO It has led
to a massive job creation. But unlike the other fields
iot job market is a complex one given the wide variety
of skill sets required in this place.

Here are some emerging job
profiles for iot professionals a few years down
the line first up. We have solution architects. Now, what a solution
architect does is that it takes an idea and converts it into a design
and then takes the design and converts it
into code now a solution. Architect may not be
a back-end developer, but it takes the requirements
of the company and then turns it into solution blueprints which brings me to another very important player
in this end-to-end execution, which is the product manager the responsibilities of
a product manager may be many but mostly it revolves
around making sure that the clients get
the solution they asked for on time moving on now when we talk about iot we talk
about huge amounts of data. And where there is
huge amounts of data, we have analytics on top of it. So this is a job profile
created specifically for the iot Industrial Field, which is the
industrial data scientist. These are data scientists that basically work
with sensor data and have expertise on it. Which brings me to another very important
industrial job profile, which is the
industrial Engineers.

Now as I've mentioned before Hardware plays a key role
in the development. Moment of connected
devices for that. We need material Specialists
who can work on semiconductors that are used
to make microcontrollers and microprocessors
in those connected devices. Next up. We have another role that is created specifically
for the iot field. Now iot has pushed
the developers to go beyond a full stack.

We need developers
at the back end who are not only proficient in software coding but So in
Hardware programming, hence, we have the full stack developer which brings me to our final
emerging role in iot as we have all known
and predicted very soon. Our shop floors are going
to be taken over by robots. So what do we need? We need a supervisor who can take care just in case
there is a miscalculation or a breakdown. This has created
the final job profile that I'm talking about today
the robot coordinator. With that said let's move
on to our next topic. So while iot is poised
to be the next great boom in the field of jobs lack of skill is citing the biggest
barrier for companies that are looking to implement
this technology to be considered for any of the rules mentioned
earlier the qualifications. You need are no different than an IT development
roll Proficiency in coding and fundamental in object design
are at least required for your resume to be looked But the skills you need here are
way more than that businesses who engage in iot
Technologies are businesses that are invested in the future.

They are seeking
forward-thinking professionals who not only meet
standards in academics, but also have soft skills and Innovative thinking I
am talking about people who can integrate deep knowledge
in embedded Technologies and concepts of cloud computing
and Edge Computing. These people are tipped
most Be in demand next up. We have networking
and communication protocol. These are very important as devices need to be connected
to one another at all times in real time.

Finally. We need professionals who can convey a complex idea in simple ways either speech
written communication or other abstract methods. So the iot job market
is the perfect platform for job Seekers
to Showcase their skills and for companies
to establish relationships with These professionals so this is the best time to get
into this technology and who better to guide you then
the iot trainers at Eddie Rekha. So Ed Eureka provides
an iot certification training and the outline of a syllabus
look something like this. This training course
is tailored specifically by industry experts and a takes you through Concepts
such as iot framework ecosystem and solution architecture it also teaches you networking
protocols and application. Our in-depth you
shall be working with Raspberry Pi and sends hats and will gain hands-on
experience with Azure iot Hub and Alexa voice.

This course also
has a real life demo and case studies which will help you master
the iot technology. So concluding I
would like to say that iot is amidst an explosion
this definitely suggest optimistic future for
professionals looking to dive into this industry. So grab this opportunity
while you still have it. Thank you and have
a great day ahead. I hope you have enjoyed
listening to this video. Please be kind enough to like it and you can comment any
of your doubts and queries and we will reply them at the earliest do look out
for more videos in our playlist And subscribe to any Rica
channel to learn more.

Happy learning..

Categories
Technology

How To Use NBMiner | Step-by-step Guide

hey everyone and welcome back to 
another mining chamber video in   today's video i'm going to walk 
you through how to use nb miner   we're going to first go through a quick 
setup so you guys can get going right away   and then we're going to get into more details 
and how you should download it and all that   information that you need to know so now let's go 
ahead and get into the video right after the intro first we're going to start off with the overview 
on nb miner if you guys want to jump to a specific   point of this video feel free to look in the 
descriptions below everything will be time   stamped below so nb miner is a cryptocurrency 
miner that can be running on windows or a linux   based mining operating system if they support it 
so the coins that you can mine with nb miner are   all these coins that are mentioned right here or 
in general any coin that follows these algorithms   that are showing on this table so there's a vast 
majority of the popular coins that you can mine   here including ethereum raven coin and then coin 
flux as well you can also mine ethereum classic   and multiple other coins in these algorithms here 
so as for the developer fee the fees on this miner   you'll be paying one percent if you're mining 
ethereum or ethereum classic so anything on ether   or atc hash will take from you one percent and 
then for raven coin you guys can see here on kapow   you will be paying two percent and on octopus 
which is cone flux you will be paying three   percent you also have the other algorithms in 
here with their percentage as well so just keep   that in mind when you're using this miner now nb 
miner supports the vast majority of the gpus so   usually you won't have any troubles trying to 
use it on newer hardware or older hardware but   you can come back here and double check so this 
will all be in the readme section of the nb miner   i will leave the links for all this in the 
descriptions below so here you guys can see   different algorithms as well as the coins 
and then the compute compatibility so this   applies to nvidia cards although i was not able 
to find amd cards compatibility so to look at   these compute compatibility you just want to look 
for the number here and then you can go to this   compute compatibility reference link and then from 
there you guys will find the number and then with   the gpus that are included in that number so for 
example for the rtx 3000 series they are on the   8.6 so if we go back here you'll see that 8.6 
is supported on almost all the algorithms now   as for the vram i don't think this is updated 
since in ethereum now you do need more than 4   gigabytes to mine ethereum so just follow the vram 
information based on the dac size of the coin that   you're trying to mine now to download this miner 
you want to go to releases and then from releases   you can download the latest one so you guys can 
see here there's different versions and then   if you go lower you'll find the older versions 
with all the fixes they added so in the time of   this video the latest one is 36.1 so you guys can 
download the most recent version if it's different   than this one now if you scroll down a little 
bit you will find here the assets for this miner   and then you have here the linux installation as 
well as the windows installation and then where it   says dot shot 256 that is the check sums for the 
miner so we will compare those later on after we   install the miner and then you have all the source 
code in here as well so it's an open source miner   which gives it credibility and it makes it secure 
for yourself to use it for mining so now since   we're on windows and we're going to test it on 
windows i'm going to install this nb miner 36.1   winzip if you're on hiveos or any mining specific 
operating system you won't have to do anything   you'll just find it in the list of miners and you 
can use it directly from there so to download it   just click on the zip file and then you can save 
it anywhere you want but just remember that your   antivirus might flag it as a virus and then you'll 
just have to whitelist it from your antivirus   now what i did is i just have a folder named 
miners in my desktop and then that folder i have   it whitelisted from windows defender so that every 
time i install a miner in there it doesn't delete   it for me right away thinking it's a virus it's 
all just false flags so don't worry about them at   all now if you have no idea how to do that i have 
a video on mining on your pc and then i go into it   with details in that video i will leave the link 
for that video in the descriptions below so now   let's go ahead and save it here and then after 
we save it here you guys can see on the bottom   left i got a dangerous so brave has blocked it now 
this is normal like i said it's just a false flag   and all you need to do is you want to click on 
show all and then on show all you want to go   ahead and hit on keep dangerous file so after that 
you will see that it finished installing and then   you can do show in folder and then you'll be able 
to find the miner in your folder so now the first   thing you want to do before extracting your miner 
you want to make sure it's an authentic version   of nb miner like we've seen recently with the 
news that phoenix miner was recently compromised   so please make sure to do this step just to make 
sure that you have an authentic version of the   miner and it matches the checksums which is like a 
fingerprint for the folder of the miner to do that   all you will need to do is go ahead and open up 
the command prompt to open up a cmd and then from   there you can go ahead and navigate to the miners 
folder so if you have no idea how to navigate   in command prompt you can look it up it's not 
really that complicated i will give you a simple   explanation here so you just want to do cd to 
change directory and then from there you want to   go to wherever this miner is so now i'm currently 
in my so canon user and then in that user i have   downloads documents and all these folders right 
here so i want to go to desktop so i would say cd   desktop and then from there i can just hit enter 
and that will put me in the desktop folder so now   after the desktop folder i have my miners folder 
so now i need to go to cd and then miners and   after that i am in the folder where i have nb 
miner installed so i can go ahead and type out   dir which will show all the stuff that's in this 
folder so here i have nb miner 36.1 win.zip so now   i want to make sure that this is authentic through 
the checksums and to do that all you need to do is   type out cert util and then dash hash file and 
then you want to put the name of that folder so   what you can do is just type out nb and then hit 
tab it should automatically fill it out for you   just make sure that it's the zip and then after 
the zip you want to go ahead and say the algorithm   so you want to say sha 256 and the reason that 
we're saying shot 256 is because here at nb minor   they have the shot 256 one so we can go ahead and 
hit enter and then you guys will see here there's   a long string that comes out and that string will 
be in this file right here so i'm going to install   this file as well now and then i can go ahead 
and save this to the same folder and now after   you save it you just want to go ahead and do open 
with and then select notepad and open this file   with notepad so now once you have that open you 
will see here a string and then the matching zip   file so if we go back to our command prompt we can 
compare them and then they are matching exactly   the same so that means that the nb miner that we 
have is authentic and we're good to go so now i'm   going to go ahead and delete this shot 256 file 
and then i'm going to extract nb miner within my   miners folder and now here we have the extracted 
folder so usually what i like to do when i   install any miner i don't like to have to click on 
two different folders to reach the items so what i   will do is i will just drag all these files in 
here back to the other folder the first folder   and then like that i can go ahead and delete the 
second folder so now once i open up nb miner 36.1   i don't have to open up two different folders to 
reach the files for the miner so that's for the   installation of the miner and now you're all set 
and you have that miner installed on your system   securely without any issues or anything you need 
to worry about so now the first thing i want to   go over after installing the miner is showing you 
guys a quick start to get going right away without   any extra information and then after that we're 
jumping into details with this miner and talking   about different commands that can help you out 
later on so let's go ahead and get started with   the quick start so the first thing you're going to 
see when you download your folder for nbminer you   will see all these different files right here so 
all these are different batch files and they all   say start and then the coin so here you have start 
adc start eth and the o follows simple principle   so all you need to do is just go ahead right click 
on it and then do edit and then you might get this   pop-up right here just do one more info and then 
run anyways and then after that you will see some   information like this now when you're here all 
you need to do is change the address here for   your own wallet address now if you don't know 
how to get a wallet address you guys can come to   miningchamber.com platforms and then here you will 
find some wallets that i do like and i use so you   guys can't download any of those and then get your 
ethereum address from there so since this is for   start eath then you will be putting your ethereum 
address here and then you're also going to be   changing the pool based on what works best for 
you so there's multiple different pools out there   you guys can use ethermine it's a good choice and 
then just put the server that's close to you and   the port number and then you're all set after that 
you just close this file make sure that you save   it first and then you run that file you don't need 
to run it as an administrator because you're not   doing any overclocks there so you can just double 
left click on it and then it will start kicking in   and start mining for you so that also applies for 
all these other ones so if you go for raven coin   for example if you have a four gigabyte card you 
just go ahead hit edit and then same thing run   anyways and after that change the raven address 
and then the raven pool and that's all you need   to do to get started super quickly now if you 
want to learn more about the different commands   please stick around and then we're going to go 
into details on all these commands so that you can   learn how to use these miners efficiently so now 
that we covered a quick start let's go ahead and   jump into details with the commands so there is 
a huge list of commands but we're not going to go   over all of them i'm just going to pick the ones 
that i think are very important to know so the   first one i want to start off with is dash a and 
that's the first command in your script so dash   a or dash dash algo and what that does is selects 
your mining algorithm so if you're mining ethereum   you would do dash a e and then that would be the 
ethereum algorithm so eth and if you're mining   ravencoin or anything like that you would select 
a specific algorithm that that coin runs on so   it's a fairly simple command and you guys will be 
able to find all the algorithms that supports it   in the requirements list here and then one other 
command that goes hand by hand with this one is   for example let's say ethas when ethereum classic 
used to also be on ethash and now it has its own   algorithm which is etc hash so back then when 
there was ethereum and ethereum classic running   on the same algorithm you would have to use the 
command dash dash coin so dash dash coin would   set a coin for ether algo whether it's eth or etc 
so if you wanted to an ethereum classic you would   do dash dash coin etc and the default is ethereum 
but now since ethereum classic is not in ethash   anymore you guys don't need to worry about this 
command if you're trying to mine ethereum classic   all you need to do is just change that algorithm 
to etc hash now they don't mention etc hash here   in the algorithms but you guys can give 
it a try and see if it works out for you   now if using the etc hash method doesn't work 
you can try doing eth and then dash dash coin   and ethereum classic so after dash a and dash 
dash coin the next important command to know is   dash o or dash dash url so what that does is 
basically specifies your mining pool url you   guys can select any mining pool you want i have a 
full video on mining pools so if you have no idea   how mining pools work feel free to check out that 
video the link will be in the descriptions below   and with the dash 0 there is also dash 01 or 
02 and what that does is you specify a backup   mining pool so if mining pool number 1 goes down 
mining pool number 2 will kick in and then etc the   maximum that you can specify is three pools so you 
have dash o and then dash 01 and dash o2 so after   the mining pools you have your user and your user 
is your wallet address so here you see the isu or   dash dash user and this is usually your wallet 
address now in some scenarios you would make a   username and password with your mining pool and in 
that case you can use your username and password   but most of the time all you need to do is just 
put your wallet address if you don't have a   username and password with the mining pool that 
you're trying to mine to and this also goes back   to u1 and u2 so you can have backup users for your 
backup pools now the next important command would   be dash d or dash dash devices and what that does 
is basically you specify the gpus that you want to   use for mining so let's say you have two gpus in 
your mining rig you can do dash d0 and then that   would select only the first gpu that's on your 
mining rig that also goes with your main pc so   if you're trying to mine with just one gpu you can 
do dash d0 and then you would select the first gpu   or you can do dash d1 and that would select the 
second gpu now note that it starts from zero so   the counting would start zero one two three and 
that would be for the first four gpus so just   keep that in mind when you're trying to disable 
one of your gpus just like the devices command   there is also the dash dash platform command and 
what that does is it chooses for your platform   so whether it's nvidia or amd now the default is 
both of them but you can do one to choose nvidia   cards only and you can do number two to choose amd 
cards only meaning that if you do one you'll only   be mining with your nvidia cards and if you do two 
you'll only be mining with your amd cards and then   there's also the dash dash feed command and then 
this command basically changes the percentage of   your fee for the miner so you can set it to zero 
to turn off your dev fee or you can keep it the   way it is and not change anything the only thing 
about this is if you do set it to zero it reduces   your performance now i'm not sure exactly what 
comes out to be more profitable either turning   off the defeat or lowering your performance but 
honestly i would say just keep it on and then use   it the way it is if you want to give it a test and 
turn off your death fee then feel free to do that   and another really useful command is temperature 
limit temperature limit sets a limit for your gpu   in celsius and if that exceeds it will stop the 
gpu for 10 seconds so that means if your card is   overheating it will stop mining for 10 seconds 
so it cools down a little bit and then it will   kick back in and now the last command i want 
to cover is dash dash mt or dash dash memory   tweak so what that does is basically modifies 
your nvidia cards memory specifically the 1080   and 1080 ti so before with the 1080s and 1080tis 
you have to run the pill before running the miner   which would increase your hash rate up to 40 or 
45 mega hash but now you can do it through this   command instead so this command ranges from 1 
to 6 so that means you can do mt and then 1 or   mte2 and keep going until 6 so you can try all 
of these numbers and see which one works best for   your gpu the one that gives you the highest hash 
rate will be the better one for your gpu now that   is it for the commands for nb miner we covered the 
most important ones that i think you guys should   know if you guys have any other commands that 
you think people should know please leave it in   the comments below and then from there everybody 
can read it and learn from it so now that we've   covered the commands let me tell you guys a couple 
of things that you can do with this miner as well   so first you can monitor your rig through the 
web monitor using your port number and if you   are a developer you can also use this to build on 
it applications now i'm not going to get into this   in this video but this is just something that you 
can keep in mind or go more into details with it   if you are more technical and there are also the 
config files that you can run which will save your   settings and then from there you can open it in a 
different computer that's also a good choice to do   but with how simple the bat files are in nb miner 
you don't really need to worry about that as well   so now before i wrap up the video let me give 
you guys my conclusion on nb minor i think it's   a pretty good miner it does come at a one percent 
fee for eth which is a bit high so comparing to   phoenix miner which has point sixty five percent 
fee it is considered a bit higher but all around   nb miner is not a bad choice at all if you're 
looking for a simple nfs mining software for amd   and video together now one of the things i wish nb 
miner had is being able to overclock through the   command line arguments that would be pretty nice 
so you can just put your overclocks in nb miner   and then it will automatically apply them as soon 
as you run the minor we can do that in phoenix   minor but not in nb minor so hopefully eventually 
they will apply it to here that is unless i missed   it and i didn't figure out how to do it so if 
you guys know a way to apply your overclocks   with nbminer please let me know in the comments 
below now that wraps up the video guys i hope   you enjoyed this video if you have any questions 
or feedback let me know in the comments below now   the next mining softwares i'm going to be covering 
are team redminer as well as t-rex miner so if you   haven't subscribed yet make sure to subscribe so 
you can get notified when these come out and drop   a like on this video if you guys enjoyed it thank 
you again and i hope you have a wonderful day you

Categories
Technology

PS5 Teardown Surprise!

This is the PlayStation 5 and we are going to break it scream So now that we’re going to see what’s inside the box, but we’re also going to tear this thing. Apart, Look at the size of this box, Okay, wow.

What a nice unboxing experience! So, if you’ve, actually seen we’ve done an entire video on the DualSense already And we may or may not have broken that one as well.

Oh, is that a bad luck that all the PlayStation videos we do it? Just ends in destroying things Ken: It works, though box rattling.

This makes the fat PS3 look reasonable.

Are you kidding me? I hope you got room’cause it’s big.

I almost called it a big chungus, but I didn’t’cause.

I’ve used my chungus quite enough today.

So for the obligatory size comparison, we have the Xbox series, S Austin laughs, Which is funny, And then we also have the series X.

So the PlayStation 5 is big, But why is it so big? Well, there’s only one way to find out watching the official PlayStation tear down video.

The second best way to find out is to continue watching this video. As I wreck a PS5 ding, Oh yeah, that’s, why you need the stand? Huh Woo look at that Look I’m, not gon na, be the guy who tells you that size, doesn’t matter’cause.

It definitely matters if you’re a PlayStation 5 One of the things that’s interesting about the PS5 is that it’s supposed to be easy to open up the side.

Panel machine clinks, Austin laughing Okay, so the PlayStation 5 is very easy to remove the side panel.

I definitely just scratched it.

Oh my god.

Do you see the size of that scratch? I just put on Look at that.

Well, this is going well, isn’t it.

As you can see.

The side panel of the PS5 is very easily user removable, So easy Tool, less Brainless as well.

Obviously, Oh look at that. That is how to do it gently Grasping So immediately it’s clear that they’re going for a different cooling approach compared to the series X.

So you can see that we have what I believe is a 120 mil fan, but you actually have clearance on both sides, So you can see it’s open on this side as well as this side.

So if you compare this to something like the Xbox series X, which uses honestly just a much more complicated way of cooling off the console, So you have dual motherboards, you have a mid plate.

You have vapor chambers, It’s very complicated, Whereas with the PS5 it seems like Sony’s opted to go for a cheaper and simpler approach And the downside there is just simply the console is bigger.

Now you might wonder why has Sony made it so easy to remove the side panels of the PS5? Well, the big reason for that is that not only can you clear out dust from these little traps, but importantly, you can also upgrade the SSD.

So, behind this little panel we should see that there is an M2 slot So right here we have a slot for a PCI 4 point, O SSD.

Now, as of recordings, this video – you can’t, do anything here yet So the idea will be a long term once it gets a firmer update at some point that you will be able to easily upgrade the storage of your PS5 without needing to buy some Kind of proprietary memory card, like you do on the Xbox The main downside to upgrading your PS5, as I accidentally screw my hand, is that you need a very fast SSD, So you need to be not only PCI 4 point O, but in theory at least you Need it to by Sony compatible, So we actually can’t test it since it doesn’t work right now, But stayed tuned to make sure to subscribe to the channel, because we will be taking a closer look at what kind of SSD options and how You can upgrade the storage on your PS5, All right, let’s plug it in and see.

Can you actually run it without the sides on machine beeping? Oh, I see Oh yeah that fan’s spinning You can absolutely do this, Should you Probably not, But as far as the PlayStation’s concerned, it doesn’t care or doesn’t even know.

I guess if you have the sides on What’s interesting is so I can definitely feel it is definitely pushes all that air which it sucks in through this way, through the fan and out the back.

There’s like a good little breeze back here. So what it seems like for the cooling solution is that all of the cooling is happening on the top half of the console, Which kinda makes sense because on the bottom half you mostly have the disc drive and I assume the power supply.

Oh yeah, That works.

Okay, So if your PS5 is overheating, you can take the side panels off, You might get dust in there and it’s probably not recommended, but technically that works.

You know, kids are gon na.

Do that Matt? How much are you actually gon na tear this apart? Yes, is the answer.

Matt There’s, probably a very elaborate way to do this.

I’m just gon na start, unscrewing things All right.

There we go.

One T is void There.

We go So a little note if you decide to tear your own PSI apart. They have a lot of screws and they’re all different.

Like all of’em.

I’m 12 screws.

In now.

Let’s remove the fan tool: whirring Riveting content watching Austin Evans label each individual screw, so he’s not an idiot and knows how to put it back together.

So I think those are all the screws So Well that comes out easily.

Now the fan – oh wow – that just comes Whoa – that’s cool Out Wow.

I can just feel the breeze I mean I feel like this fan weighs like half an Xbox series S, So the fan basically is pushing that air right through those heat pipes.

So far so good, Let me pull this little cable loose.

The shroud has given up and we have more shroud Austin laughs. Here we go Okay, So the optical drive should just come loose now That That’s actually a very oddly large drive.

So, of course, this is what you use to watch Blu Ray’s, 4K, Blu Ray’s as well as their proprietary hundred gig format or whatever they use for PS5 discs.

Do you see this Look? How tiny this little bit of the heat sync is.

Look it just pops out on this side, So next I’m going to remove these.

What I assume are antennae for wifi, probably like Bluetooth.

I guess we can start undoing the oh, my god That’s a lot of screws All right.

If these are all different sizes, I’m gon na be labeling screws all night long, Let’s Get started.

Shall we upbeat music? These are famous last words.

I will say so far.

This has been fairly easy to get into. At no point have I felt like I was about to break something: Okay.

Well, I’m just gon na take it apart That’s literally dangling, So you mean I’m almost done.

I hear nothing but positive things right now, Matt! This is what a PS5’s supposed to look like, I think So, after removing a couple of dozen screws, we finally have the heat shield off or the shield Shield off Wait That’s not part of the heat sync at all.

They have a separate heat pipe on the back, So this also serves as a heat sync for the back of the PS5.

So taking a look around here, this looks to be the SSD, or at least that’s.

What I assume is the SSD.

It’s fairly close to the M2 slot And then, if we slide things over a little bit, you can get a little bit of a better look at the GDR6 memory, specifically 16 gigs of it on the PS5.

Now something else interesting.

I believe, if you can see this little guy right here, I believe that is the wifi chip And something unique about the PS5 is that this actually has wifi 6.

Unlike the PlayStation 4 And, of course, the Xbox series X and series S, all of which have the older wifi 5, Just a nice little feature Now. I think the board should just come out.

Oh, I’ve got a lot more screws to undo don’t.

I Yeah you do Yes, you do.

That is a bizarre looking heat sync, So you actually have these like cross heat pipes.

Do you even PlayStation bro? So what’s left inside the chassis is almost entirely the power supply, Which is 370 watts, so that’s actually a pretty beefy power supply.

I can’t.

Imagine the PS5 actually needs that, But you can see the overall volume of the PS5.

The power supply takes up a pretty huge chunk of that It’s.

Fine, it’s.

Fine, it’s not going anywhere Fine. We can pretty quickly undo the last couple of screws.

The only problem is, it likely is going to be terminal.

So on the underside of this heat sync, there is thermal compounds specifically known as liquid metal.

Liquid metal is something which has never really been used before.

In certainly a game console and really in most electronics, And basically we can’t really put it back on.

So, if I take this off right now, we’re probably never going to have this PS5 up to the same cooling.

I might try some normal thermal compound to see, but this is the point of no return tool whirring As soon as I flip, this over liquid metal might go everywhere.

That is still firmly attached, So the back half of the board is free, Whatever they’re.

Doing to keep that liquid metal attached is absolutely what’s holding the board in right now, mumbling in distance.

Okay got it Yep, Okay, That my friends, oh no don’t leak. Don’t leak.

There we go all right, So that is the inside of PS5, So the main star of the show here is absolutely that liquid metal.

So if you see, if I lean it in it actually runs, do you see that Look at that? That is liquid metal? So, essentially that is what is interfacing between the SOC of the PS5 and this heat sync, which is of course, on the other side.

I’m not gon na flip this over’cause.

It will absolutely go everywhere, So, interestingly, what they’re doing.

So one of the main disadvantages of using liquid metal and one of the main reasons why it’s not typically used is because it is literally liquid metal.

So if it goes everywhere, it would short things out cause tons of problems.

So you can see when I opened it up, the liquid metal actually went all off to one side That foam barrier kept it from actually reaching the board, Because if this liquid metal touches any of this, you are in major trouble.

I just so happen to have an Xbox series X, SOC don’t ask, And if I put that side by side, you can see the difference in the PS5 SOC versus the Xbox series X.

This just simply is bigger, which makes sense, because, essentially, how they’re getting the performance out of the PS5 is they are throwing liquid metal at it. They’re, throwing this huge heat sync at it, just to try to keep it cool because they’re running at such high clock speeds That my friends is what is inside a PlayStation 5, Make sure to subscribe to the channel for more PlayStation content.

Where probably fewer PlayStation’s will be harmed And if you’ll excuse me, I am now going to go, spend all night putting this back together.

I labeled these right.

.

Categories
Technology

How to Use an iPhone as a Webcam – Elgato EpocCam Set Up

Hi, I'm Steggy from Elgato, and in this video I'm going to show you how to turn your iPhone into a webcam using Elgato EpocCam. EpocCam is an iOS app that let's you use your iOS device as a webcam, whether it's wired or wireless. That means you get to take advantage of your iPhone or iPad's amazing camera for your livestreams or video calls. And to set this up, is extremely easy. First, download and install EpocCam from the iOS app store. EpocCam requires iOS 14, so for a list of all iOS device models that support iOS 14 check out the link in the description panel below. Next, launch the app and tap begin. Here, we see instructions on how to set up the computer driver for EpocCam. EpocCam works with both Windows and Mac operating systems, so simply choose your platform and follow the instructions to download and install the driver on your computer.

Please note if you are using Windows, you will need to download and install Apple iTunes in order for EpocCam to work. If you're setting up EpocCam to be used in wireless mode, you can simply hit next. Just make sure that your iOS device is connected to the same network that your computer is connected to. If you want to set up EpocCam in wired mode, before you tap next connect your device to your computer using a lightning or USB-C cable. Please note if you're using a third-party cable, that it's properly rated to send and receive data. As some inexpensive cables are for charging only which won't work in this case. Now all that's left to do is enable some permissions on the iOS device by following the prompts on the app. And now you should be able to see a preview of what your iOS device is capturing.

And then on your computer's side, EpocCam will now show up as a webcam device in your favourite app. Simply choose it and your webcam will show up. All the controls for EpocCam are on the iOS app itself. You can flip to your front or back camera, change to your different zoom levels, and access this menu to change your bitrate, your connection mode, and your chroma key settings. Now one thing to note is EpocCam has both a free and a pro version. So if you're interested in additional features, such as 1080p capture, smart HDR capture, chroma keying or more, be sure to unlock the pro version for a one-time cost of $7.99 USD. Now you have a super high-quality webcam thanks to Elgato EpocCam. If you have any questions feel free to leave a comment down below and don't forget to check out the rest of our videos on EpocCam on our YouTube channel. And be sure to get subscribed so you don't miss our new videos that will help you unlock the full potential of your Elgato products.

Once again, I'm Steggy from Elgato, and until our next video, good luck and have fun..

Categories
Technology

15 Windows Settings You Should Change Now!

Even if you've been using Windows forever,
there are probably a lot of settings that you never realized were on by default, and
should probably change. These might be settings for privacy, convenience,
or just usefulness in general. So in this video we're going to go over a
bunch of settings in Windows, specifically Windows 10, that I think you should change
right off the bat, including stuff you should disable, and even features that are good,
but aren't enabled by default.

And I believe there are about 15 of them,
so you'll hopefully learn at least a couple new ones. Let's go. First up let's head to the Windows Update
settings. To get to the main settings Window, you just
click the start menu, then click the gear. Go to Update & Security, then look for "Advanced
Options", and then click "Choose how updates are delivered". Here you'll want to make sure the setting
at the bottom is set to "PCs on my local network", and NOT the other one with PCs on the internet.

What that would do is download parts of updates
from other people who have the update, to supposedly make the downloads faster. But it would also send parts of your updates
to other people, using up bandwidth. On your local network it doesn't really matter,
but you can disable this altogether by switching the toggle above to off. Next let's change some WiFi settings. Back in the main settings window go to Network
& Internet, then the Wi-Fi tab. Under WiFi services, you'll see two options
talking about suggested open hotspots. I would disable both of those. Suggested hotspots are supposed to be hotspots
that Microsoft has deemed "legit", and this would allow your computer to connect to them
automatically. But open hotspots are inherently insecure,
so you never want your computer to connect to any network without asking you first, it's
just ridiculous. Below are settings for Hotspot 2.0 which is
a relatively new technology, but you can leave that on. I'm not going to get into that in this video. Now we can go through a bunch of privacy settings
and get those out of the way all at once.

So start out going to Settings, then Privacy. First we'll start out in this general tab. You'll definitely want to uncheck the first
box, and probably the second box as well. These basically allow websites and apps to
track you based on a unique "Advertiser ID", in order to learn more about you and show
you more relevant ads. The next one about your language list might
not matter, but I just have it disabled. If you use a language other than English,
maybe keep that enabled. The third setting is also something you may
or may not want to disable. It basically keeps track of which programs
you launch most frequently, so you can have a "most used" list in the start menu. If you don't care about that, disable it. The next tab we're going to look at is "Speech,
Inking, and Typing".

This feature basically keeps record of everything
you type or say to cortana, the virtual assistant, and apparently uses it to "get to know you",
and make better suggestions. For those of you who don't use Cortana, it's
definitely something you want to disable, so just turn that off. Moving on, head to the Location tab. Very straight forward, if you don't want Windows
apps using your location, turn this off. If you have some apps you DO want to allow,
you can turn the feature on, and individually enable and disable apps in the list after
scrolling down.

The next tab is "Feedback and Diagnostics",
which adjusts how Windows will track how you use Windows, and then send it back to Microsoft. Unfortunately, Microsoft doesn't make it easy
to disable completely, and that's beyond the scope of this video. But you'll at LEAST want to change this from
Full to Basic, to minimize what they collect. Otherwise, look what it tracks. Browser usage, like what websites you visit
probably, "feature usage" which could mean anything, "inking and typing data" which is
literally anything you type.

So yea, you REALLY want to not have it on
Full. And maybe disable the toggle below about tailored
experiences too. And finally for privacy settings, these actually
are for cortana specifically. To access these click the Cortana button,
then the Gear. Or search for "Cortana settings" in the start
menu. If you don't use cortana, you basically want
to turn all of these off. If you DO use Cortana, you can go through
these and change what you want it to track. But I definitely suggest disabling Cortana
on the lock screen, otherwise some person might be able to access a lot of your data
even when the computer is locked.

Alright, now let's do something about all
those annoying notifications Windows seems to give you all the time. So head to Settings, System, Notifications
& Actions. I personally wouldn't disable notifications
altogether because they can be useful, but if you see one app that is particularly annoying,
you can scroll down and disable it's ability to show notifications. Back up top, you probably want to disable
the option to show notifications on the lock screen. As you know, a notification can sometimes
show private information, like emails for example. Also, I'd enable the one that says Hide notifications
when duplicating the screen. Say you go to do a presentation, and you hook
the computer up to a projector, you again don't want some notification popping up on
the screen with sensitive content for all to see. Now you don't have to worry about that. Finally, you can disable notifications for
tips and tricks, which could be annoying. Speaking of annoying, let's disable the obnoxious
"suggested apps" you see in the start menu, which are essentially advertisements.

In settings go to Personalization, Start,
and disable where it says "Occassionally show suggestions in start". Next up, there's a setting we want to change
under Settings, Gaming, Game DVR. You almost definitely want to disable the
one that says "Record in the background while I'm playing a game". Leaving this on means any time you're playing
a game, it will constantly be recording video even if you don't save it, which will use
up resources and could severely affect performance. One setting you might want to ENABLE in gaming
is Game Mode, which will only show up if you have the latest creators update version of
Windows. This setting supposedly might free up system
resources for your games if your computer is really crappy. Though another tech channel, LinusTechTips
did some tests, and found it made little difference on reasonably powered computers, and might
actually decrease performance in that case. So probably keep this disabled unless you
have a really old computer, then it might help.

Alright now we've disabled a lot of stuff
so far, so how about we actually find some neat features to ENable. First up is a super cool feature called "Night
Light" which can be found in Settings, System, then the Display tab. But this feature will only show up if you
have the latest so-called creators update. What this feature does is change the color
of the screen at night so that it's much easier on the eyes, and won't disrupt your sleep
schedule as much.

And it does this by cutting out blue light,
which is what keeps us up at night longer than we want to be. In Night Light settings, you can adjust the
strength of the effect, and what time you want it to activate, including sunset to sunrise. But you will need location services enabled
if you want to do that. If I were you, I would literally set it to
the strongest setting. It might look jarring at first, but I can
almost guarantee you'll get used to it at night. Here are a couple more settings to enable
for Windows Explorer. Just open up any explorer tab, like My Computer
or whatever. At the top click View, and then check the
two boxes that say "File Name Extensions" and "Hidden Items". If for some reason those don't show up, you
can find the same settings by hitting Options, then going to the View Tab. What the first check box does is makes sure
that for every file on your computer, it will include the file extension with the file name.

So it shows the ENTIRE file name. This is REALLY important for a lot of reasons. For example, maybe you download a suspicious
file that claims to be a video, but with this, you can see that it's actually an exe file,
an executable! Guess what, that file is almost certainly
a virus. The virus maker may even add their own fake
file extension like "virus.mp4", but now you can see that the real name is "virus.mp4.exe". Another example is if you have a folder full
of files with the same icon from being opened by the same application. This way you can still see what kinds of files
they are if you know you're looking for a video as opposed to a picture or something.

That other check box we selected was for Hidden
Items. You may or may not have known this, but there
are file and folders on your computer that are not visible to you by default. These might be settings files for certain
programs, or log files, that sort of thing. Most of the time you won't need them, but
occasionally you might come across a tutorial showing you how to fix a program, and it will
refer to a file that's hidden. If you don't have this enabled, you might
think that file is gone. Also, a lot of times viruses will create hidden
files for obvious reasons, so the average user will have almost no chance of being able
to remove it all by themselves.

So it's at least good to know that these files
exist. And I think that covers just about everything. I hope you guys found this video helpful,
and maybe learned a thing or two to make windows better. I'm sure there are some I didn't mention so
if you have any more to add, let us know down in the comments section. If you want to keep watching, here are some
more videos you'll like, such as some hidden Windows features and programs you might not
know about. And if you want to subscribe, I make new videos
every tuesday thursday saturday. I'm looking forward to hearing from you, so
thanks for watching, I'll see you next time, have a good one..

Categories
Technology

Introducing Logitech Capture

Looking for an easy way to start creating content with your Logitech c922 – webcam. Then, Logitech capture is the perfect choice for you. Logitech capture allows you to record video, take snapshots and can be used as a virtual camera in your favorite video chat software. You can download logitech capture from logitech.com/capture Once you've installed, let's add some sources. You can add two sources to logitech capture. These sources can be any combination of Logitech webcams or capturing a desktop from your PC. Once you've added a webcam, you can customize the settings such as adding a colored border. The streaming preset will set your priority to framerate and is useful if you be recording something with high motion on your desktop. The video calling preset will focus on exposure or lighting. And is good, if you're using logitech capture in conjunction with video chat software. When using the zoom feature, you can use the pan and tilt to adjust the framing of your camera.

You can also adjust a variety of settings on your camera such as focus, white balance, brightness, sharpness, contrast and saturation. If you have a green or a blue backdrop, you can activate chroma key to remove the background. In the Advanced Settings, you can enable camera mirroring. If you add a desktop as a source, you can also apply a border chroma key and mirror the desktop Now that you've added your sources you can use this section to switch between or layer your sources. If you are layering your sources you can position and adjust the size of the smaller source. You can start a recording or take a snapshot here. But let's look at the sayings first. In the recording sayings, you can apply a filter to your sources. Your resolution can be set to either landscape or portrait if you decide to make snapshots or videos for mobile. Next, select your recording quality frame rate and video encoder. Select where your recordings and snapshots will be saved.

Some advanced features, include a countdown for a recording on snapshot is taken taking enhance snapshots and excluding logitech capture from desktop capture. The audio menu, lets you select your audio input and out devices. Audio input captures audio from your microphone and audio output captures audio from your PCs playback device. The transition menu, lets you select from a variety of effects along with the duration. You can set hot keys to switch sources, pip shots, start/stop recordings take snapshots and mute, unmute audio input or output. You can save your settings to a profile. Logitech capture is a great tool to get starting creating content. If you'd like more features in the ability to stream with your logitech webcams. we recommend checking out xsplit broadcaster..

Categories
Technology

Plugged In, Not Charging Windows 10 Solution (2 Methods)

Open PC settings and click on 'Update & Security' Click on 'Troubleshoot' from the left side panel. Search for 'Power' and run troubleshoot Wait for few seconds. It will take some time. If there will any issues, troubleshoot will fix these. If the issue is not solved then follow the steps in method 2 Click on start and search for 'Device Manager' and open it. Expand batteries options Right click on each driver and check for update. If drivers are outdated, then Windows will automatically fix this. Now, check the update for second driver. Now the issue will solved. If still there is an issue, then uninstall the drivers Now, restart the PC after uninstalling Subscribe to our channel for the latest uploads..

Categories
Technology

How to show multiple clocks on multiple desktops in Windows 10

Hey guys, Eddie the Magic Monk here.
Today I want to share with you how to get multiple desktop clocks so that you
can drag them to different desktops so if you like me you probably have a few
monitors and what I found was that the clock this bottom right hand corner
clock that shows up on your taskbar only shows up on one of the desktops which is
a little bit annoying because sometimes if I'm playing a game on one monitor I
might need to see the clock on another monitor so to get these clocks what you
need to do is you need to download a tool called rainmeter
so if you just google rainmeter you will probably find it it says rainmeter
desktop customization tool so if you click on that and if you just click on
download and click on the final release download so don't download the Beta
because um you might crash your system or something so just do the final
release download it and once you have downloaded it install it and then you
should see this icon pop up on the bottom right hand corner of your desktop
so um it will have this picture here in a form of the raindrop so if you
right-click on that okay you can go into layouts or skins and it shows you what
skins you have and if you go to an illustro clock you can enable your clock okay
and once you enable it you should be able to see it on your desktop so
you'll be able to see the clock that you can drag around and you can drag this to
another desktop if you want so you might say well how do you get all these other
fancy clocks so the way you would do that is you need to search for some
custom skins for your rainmeter so if you go back to Internet Explorer or
Chrome and this time you can just google you can just google rainmeter skins ok
and click on the first link that comes up that links you to DevianArt so
click on that and then you will see that there are skins for all sorts of
purposes and if you click on time and dates right these are all the different
clocks that you can get so let's say I want this clock you can click on that
and then if you click download ok it starts downloading the clock so if you
want to install this clock just click on it and open it oops um somehow my
rainmeter is too old for that so let's say I want
this clock download run oops what's going on what's my rainmeter version okay I've decided to get this clock but
um if you have downloaded the latest version of rainmeter the same problem
shouldn't occur but let's say I install this clock and once you have installed
it if you don't see it on your desktop straight away right click on rainmeter
and go into skins and find the clock that you've just downloaded which i
think is called Eridian and just click on clock and you can see it on your
screen ok on your desktop and you can drag this to other desktops if you want
ok thanks for watching guys see you next time.

Categories
Technology

Learn React JS – Full Course for Beginners – Tutorial 2019

Welcome to an introduction to react. My name
is Bob Ziroll, and I'm here to guide you through learning how to build front end web applications.
using one of the world's most popular front end web frameworks react. But first, a little
background about me. I'm the Director of Education at V School, which is a technology education
school that teaches full stack JavaScript and UX courses to those looking for a career
change.

I've been teaching in the boot camp space since the very early days of boot camps
starting in 2014. Over the years of teaching and designing curriculum to help students
learn difficult topics in a very short amount of time, I've developed my own learning philosophy,
which I think would be helpful to share. First of all, the easiest way to learn something
is by doing it the hard way, there's truly no substitute for getting your hands on code
as soon and as often as possible. During our class orientation at V school, I typically
give an analogy about myself.

So I've recently developed an interest in woodworking. I've
read books, I've watched hours of YouTube videos, I've received new tools as gifts.
However, none of those things has actually brought me any closer to becoming a skilled
carpenter. It's not until I actually put in the hours of cutting, sanding, gluing, screwing
things up. And finally, eventually building things that I'm actually proud of that I can
say that I'm actually starting to become a skilled woodworker. As such, if you actually
want to learn react well enough to be able to use it, you'll need to be actually writing
react code. Most of the lessons in this course are followed up by an exercise that I fully
expect you to put in real time and effort into accomplishing on your own.

Now, if you
decide to breeze through them the easy way without actually doing the exercises, you're
actually kind of taking the hardest road possible to learning react. And along those lines,
you should really use the scrum platform to its full potential. Throughout the course,
I'll be having you pause the lesson and actually dive into the code making changes. But even
when I don't ask you to pause and play with the code, you should take the initiative to
do it on your own. And just be curious in general, doing this is going to help you avoid
what some call tutorial hell. And if you want some more information, there's a medium blog
posts that I've linked here in the slides. The idea essentially being that you should
get your hands on the code as much as possible. And by doing so actually do the things. Okay,
not just necessarily the exercises I asked you to do, but anything that you're interested
in curious about. And as I mentioned, scrubba is ideal for this sort of learning if you
use it the right way.

Another main point of my learning philosophy is that spaced learning
and repetition are absolutely key, this information to actually stick in your mind. And one of
the main tenants of spaced learning is that you don't just binge on the course, this kind
of goes in line with the concept of Tutorial How, where it can be the easy way out to just
binge on the course and feel like you're actually learning something when in reality, your brain
has been incapable of actually retaining the information. So as you're going through the
course, make sure that you take frequent breaks. And I don't just mean for five or 10 minutes
here, there. But finish a couple of key principles, practice them quickly, and then rest your
brain for the day. And when you come back to the course, don't be afraid to go back
to previous courses and review them. Yes, it will obviously take a lot longer to complete
the course that way, but it will be super beneficial to your learning.

Okay, I'll get
down from my soapbox for now. But I'll be reminding you of some of these things frequently
throughout the course. So for now, let's quickly cover what you'll actually be learning. When
we talk about react, we can't avoid the concept of components. components in react are the
core building block for making reusable pieces of HTML. And pretty much everything else that
we talk about deals with how to use these components to build the web applications that
we want to build. We'll also be talking about JSX, which is reacts proprietary wrapper around
JavaScript. And it simply lets you build components in a very familiar way, using the HTML syntax
that you're already familiar with. We'll also spend a little bit of time talking about styling
your components will get a chance to learn about props and how to pass data around your
application. And when we talk about props, we oftentimes talk about state which is how
to maintain and change data in your application. We'll talk about event handling, and how you
can have strong interactivity with your users.

We'll talk about lifecycle methods, which
help you hook into different timing events of your react components. We'll talk about
fetching data from an API using HTTP. We'll talk about forms and their role in creating
a good user experience. And there's plenty more that we'll be covering in this course
as well. Now, there's a few things that you should already know before taking this course. And honestly, it's just the basic building
blocks. htm Well, CSS, vanilla JavaScript, and ideally a little bit of the updated syntax
for JavaScript in iOS six. If you're feeling rusty on any of these topics, I've included
links on the logo that you can click, and it will take you to another free course here
on scramble to brush up on that topic. Okay, that's plenty of talking. For now, let's actually
dive into react. Let's take a quick look at some of the applications
that we're going to be building throughout this course, this should give you an idea
of what you'll be able to accomplish by the time you're done with this course.

The first
one is kind of the default required to do list application, it may seem a little bit
boring, but it actually covers a lot of the topics that we're going to be talking about
in this course. And of course, you can click an item to mark it as completed, and we see
some style changes and everything. And is kind of a capstone project to this course,
you're going to be building a meme generator. And the idea is you input some top text, some
bottom text, hit the button, and it will randomly choose meme image from an API that contains
meme images. Some of them are funnier than others. So get excited. React is really exciting
technology. And it's going to be an excellent tool in your tool belt as a developer. Alright,
let's get started. We're gonna jump right into learning about react. But first things
first, let's learn why we're going to be using the React framework, instead of just developing
something in vanilla JavaScript.

One of the things that you'll hear people talk about
with react is its speed, and how fast it is compared to web applications that are developed
in vanilla JavaScript. The way that react is able to do that is by using something called
the virtual DOM, we're not going to go into a lot of detail about the virtual Dom right
now. But if you're interested in learning more about it, I've included here a link to
a YouTube video with a pretty simple explanation of how the virtual DOM is different than the
way that web applications work when you're developing in vanilla JavaScript. So feel
free to pause the screencast and click on the link to watch that video if you want.
For now, it's enough to know that the virtual Dom helps make react work a lot faster than
vanilla JavaScript. Another really awesome benefit react gives us is the ability to create
reusable web components. And I'm going to talk about this through an example. Right
here, we have the bootstrap default navbar. If you haven't used bootstrap before, it's
just a CSS library that has pre written code that makes some elements look really good
for you.

But you can see that it's about 40 lines long, and it's pretty unwieldy and difficult
to understand. And if you were to include this in an HTML page with a bunch of extra
content in it, it would be pretty difficult to decipher, and everything would start to
feel pretty cluttered. reacts, web components allow us to take these pieces of HTML. So
this 40 lines that we see here, and put it into a component of our own, almost like a
JavaScript variable. In this case, we call it my sweet navbar. But you could call it
whatever you want.

And we can see that this is a lot easier to read, if you're coming
into it as a developer, to see exactly what is going to be where, in this case, the body
of my HTML will have a navbar on top, some main content in the middle and a footer at
the bottom. The ability to do this is really nice for reusing these components on other
pages if we need to, and for making our code look a lot nicer when we're working in it.
Another reason why react is so awesome that I like to include is that it's maintained
by Facebook, whether you care for Facebook or not. There are a lot of really smart developers
at Facebook whose job it is to work on react.

On top of that, because react is so popular.
There's a lot of contributors on their GitHub, which is open source who contribute to the
React framework, which means it's going to be evolving for the foreseeable future. And
last but not least, React is very hireable. At vi school, we focus our curriculum and
our efforts on the things that are most likely to get our students hired. And react is very
in demand right now. So if one of your goals is to get a job as a front end developer,
React is a great choice in terms of frameworks to learn.

So that's enough talking for now
let's jump into some code. Okay, we're just gonna jump right into the
code. One thing you're gonna want to be somewhat familiar with is es six, or ACMA script six
or ACMA script 2015. It's a slightly newer version of JavaScript if you're used to using
things like var. We're going to be replacing that with some
Yes, six stuff like const and lead. There are some videos here on screen buy that should
be able to help you learn that if you're not familiar with it, and you'll want to do that
before you move too far along in react because we'll be using a A lot of ESX in react, one
of the things we'll be using really often, in fact, in every react file we create is
the import statement. And so I'm going to import react from react.

And you can see over
here on the left, I have react and react Dom dependencies included in this project. So
I'm actually also going to import react Dom from react DOM. And the last thing we're going to do is use
react Dom's render method to render something to our screen. But let's stop and explain
this a little bit here, I'll get to why we're important react in a second. But for now,
I need to import react Dom so that I can use it in my line for code here, where I use the
render method. And what this is going to do is it's going to take two arguments, one is
going to be what you want to render. I'm doing this in pseudocode, obviously, so that it's
clear that this is not the right syntax. And the second parameter is, where do I want to
render it? react Dom dot render makes the second one really easy. Remember, everything
is going to have to tie back to an HTML page of some sort, the JavaScript we are going
to continue to write is simply going to be compiled down to or turned into elements on
a page.

And so you can think of it as being inserted into an HTML page of sorts. So let's
go over to index dot HTML really quick. You'll see everything in a basic HTML pages here,
including a link tag and a script. Don't worry about the fact that this is slightly different
right now, it will still connect correctly to our index dot j s.

One thing I want to
point your attention to though is this div right here with the idea of Route right in
between the opening and closing div tags is where react is going to be sticking everything
that we create, you can think of this as a container for our entire application. So back
in our index dot j, s, this, where do I want to render, it needs to point to the div with
the ID of route. And the way that I can do that is using a vanilla JavaScript document
dot get element by ID route. This way render looks at the first
parameter, which I haven't filled out yet that says, What do I want to render, and it
will stick it inside of the div with the ID of root.

Now let's look at this first part,
what do I want to render? Let's get rid of this placeholder. And let's just start with
a simple h1. And of course, we have to say hello world to refresh the browser over here,
and notice that we actually get an h1 with a Hello World in there. Now the astute of
you might have said, Wait a second, why are you putting an HTML element in the middle
of your JavaScript parameter, that's an obvious syntax error, JavaScript is going to think
that that is a less than symbol and that this is a greater than symbol and not know that
this is an HTML element.

Well, fortunately for us, the people that created react created
a little pseudo language, you could call it called JSX. JSX is very much like a JavaScript
rendition or version of HTML. In fact, we're gonna see that most of JSX looks almost identical
to HTML. With this few slight differences that we'll talk about along the way. There's
a lot happening under the hood with react, where everything is getting compiled down
to a plain JavaScript version of itself.

But for us, we can just pretend that this will
work just fine. And it turns out, this is why we need to import react from react because
the React library is the one that will enable JSX to work the way it's supposed to work.
In fact, you can see that if I remove the import react line, and try to save it and
refresh the browser, it tells me that react is not defined. Even though I'm not explicitly
using react anywhere in my code here. Under the hood, it's getting used to interpret the
JSX. Another point I want to touch on really quick is also dealing with JSX. It's important
to note that I can't render two JSX elements next to each other. For example, if I wanted
an h1 and a paragraph, you can see that it's already not liking what
I'm doing.

And if I were to save the page, it tells me that you can't have two adjacent
JSX elements. But instead they have to be wrapped in something so that it counts as
just one element with two elements inside. For example, I might choose to wrap this in
a div And I need to put my reactant back. And there
we go. Using JSX can take a little bit of getting used to, but it's much better and
nicer after you get used to it, then doing it the old way where you'd have to say things
like, var, my new paragraph equals document dot, create element paragraph, and add some
inner HTML, then take that paragraph and append it to a parent. That was very imperative.
Whereas now we're going to be doing things much more declaratively.

I also want to interject
right here that you should remember that the benefit of scrambler is that you can pause
this screencast and play with this code. So please take some time to do that. Not just
at the end, but also throughout the entire screencast. We're also going to be including
entire screencasts that are dedicated to you doing exercises, as mentioned in the first
video. So take some time, play with this, study it up and get ready for the upcoming
exercise. All right, welcome to the first practice of
this course, this is where it makes a lot of sense to you scramble over a regular video.
As we mentioned, we highly encourage you to actually give these practices and exercises
a shot. Sometimes it's really tempting to just skip ahead to the solution. But you're
only going to be hurting your own education. If you do that. So please give it a shot.
The way this will work is I will put an objective up on the screen sometimes some hints as you
see here.

And then I'll leave about five to 10 seconds of silence to give you a chance
to pause the video and actually try to accomplish the objective. If you get stuck, I recommend
that you not just skip ahead to the solution. But instead that you go back to a previous
video and relearn the thing that the practice is about, the more effort you put in, the
more likely This is actually going to stick. So let's take a look at this practice. Your
objective is to fill in the basic boilerplate react code needed to render an unordered list
to the page inside that unordered list, you can put three list items with anything that
you want in them, it doesn't really matter. The way that you'll know that it worked is
that it will show up in the little browser window on the right here. Since it may be
your first time working in react, I've included a couple hints that remind you of the steps
you'll need to take. So I'm going to leave some silent space now and go ahead and pause
the screencast and give this a shot.

Okay, let's go through the solution together, I'm
going to remove the comments that I have. And the first thing we will need to do in
almost every react file that we create is we're going to need to import react from the React library. And since this is our index dot j s, and we're
going to need to render something to the page. We're going to need the React Dom library.
Last but not least, we're going to use react DOM. We're going to use its render method.
And there are two parameters that we need to pass into render. The first one is what
do we want to render? Well, as the challenge said, we need an unordered list. And inside
that unordered list, we need three list items. Copy and paste this so we don't need to 123
you can see here, this is kind of looking pretty ugly.

We're going to see in the future
how obviously, we're not going to put our entire page here in the render. So I'm going
to move this on to its own line so that it looks a little more like regular HTML. If
you didn't do that, that's totally fine. And then I'm going to be really boring and just
put 123 in here. Okay, that's the first parameter. And the
second parameter is where do I want this to load into. If you remember from the last screencast,
we have a div with the ID of route. And that's where we want to place our application. So
in react Dom dot render, I need to provide get element by ID route, so that it will go
find that element and let react Dom dot render node, this is where I want you to put This
code and when we refresh the browser, we get our three bullet points with 123. If any of
that was confusing, I highly encourage you to go back to the previous video, rewatch
it, play with the code, come back, do this practice.

Again, mess with the code that I
put here, see if it works, the way you understand it, try to break it, etc. Doing that is going
to really help you understand react on a deeper level than just passively watching me explain
it to you. Awesome job. Let's move on to the next topic. In the last practice video, I mentioned that
you wouldn't want to end up sticking your entire application right here inside of react
Dom dot render. Imagine having a web page with hundreds of elements on it, this would
just be impossible to maintain. Back when we talked about why react was popular. One
of the reasons we mentioned was reusable web components, we're going to get a chance right
now to learn how to create functional components in react.

The reason they're called functional
components is simply because you create them by writing a function, I'm going to add some
space here and create a new function called my app. Notice here that I'm using the constructor
convention of having capital camel case for my component name. This is a very strong convention
that you should adhere to in react always have camel case and start your first letter
as a capital letter. And the really simple thing about functional components Is that
all you need to do is return the JSX that you want this component to represent. So in
our case, we can just take this unordered list and return the unordered list from our
functional component.

It's important to know that although in this case, it would work
without it, it's always a good idea to wrap this in parentheses. And then another strong
convention that I really like is to put everything on its own lines. This way, it reads a lot
more like HTML. Then in react Dom dot render, we can create an instance of our functional
component by placing the name of the component and wrapping it in basics tags, you'll notice
that I've made this a self closing tag, there are some instances where you'll want to create
components that can accept children elements. But for the next little while, we're going
to make every component a self closing component.

Now notice when I refresh, I have the same
thing that I had before. Though the same rules apply to our functional component as they
did in react Dom dot render, meaning I can't return two different elements next to each
other, like having another ordered, ordered list near this one. That just wouldn't work
because our component needs to return a single JSX element. And here it's returning to, you
can usually get around this by just wrapping everything in a div, or whatever other elements
that you want to wrap it with. In this case, we're just going to return the unordered list.
So maybe you can start to see the power in doing this, we're going to be able to create
our own components, which contain pieces of JSX, which represent HTML in our final product,
and we can start composing them together.

Here I have a component that I created rendering,
React elements or JSX elements or HTML elements. But as we create more and more complex applications,
I'm going to be creating components that render other components that I have also created.
Eventually, it needs to boil down to a regular HTML element. But sometimes that can happen
over the course of maybe dozens of your own react components that you created. Eventually,
as we start to create more and more components, we're obviously going to split these into
their own files. But for now, it's important to play with this and see what you can get
to work, what doesn't work and get a really good idea of how a functional component works.
As we move on, we'll start to make our file structure more and more complex. Now that
we've learned about basic functional components, let's put it to practice. Okay, let's get some practice of functional
components in. One of the things we really pride ourselves at V school when we're teaching
our curriculum is that we include a lot of spaced learning and repetition, which is a
principle of teaching that helps people retain as much information as possible.

As such,
like before, I haven't included any boilerplate code for you to start with. So it's going
to be up to you to build everything from Scratch during this kind of repetition is going to
be really good for your memory and should help you really understand the concepts. So
let's go for the objectives you have. First, you're going to set up the basic react code
from scratch again. And then you'll need to create a functional component called my info
that has an h1 with your name a paragraph with some information about yourself, and
an ordered or unordered list of the top three vacation spots you'd like to visit. Obviously,
since we're not going to be grading this or anything, you're welcome to change this to
whatever UI you'd prefer to present.

And then you'll need to make sure to render the instance
of your functional component to the browser. If you want a little extra challenge. Although
we haven't yet gone over how to style your components, feel free to search on Google
how you can add some style to your page. If it's enough of a challenge, just getting the
functional component working, then don't worry about that we're going to cover styling in
a future lesson. One less thing before I give you some space to pause the video and try
this out for yourself, I will once again get on my soapbox for the last time, I promise
that you should definitely actually do this exercise. If you're hoping to get from this
course, a real understanding of how react works just passively watching isn't going
to do it.

So please take the time to actually do this. Okay, I won't mention that again.
So go ahead, pause the video. And we'll pick up in just a few seconds and solve this together. Alright, so like last time, we need to start
with some of the boilerplate code, we're going to once again import, React from react, import,
React DOM, React DOM. And this is going to be a little out of order.
But I already know that I need to render something to the page, they already know that I'm going
to call my component my info. So I'm going to put an instance of my info right here.
And lastly, I'm going to do my get element by ID route. So that render knows where to
put the my input component. Okay, now the more fun part, let's build our function. Remember,
the one thing that the functional component needs to do is return the so to speak HTML
that we're going to be putting in the page.

In reality, as you know, it's actually JSX.
But sometimes it's helpful just to think of it as HTML. Since I already know this is going
to cover multiple lines, I'm going to put everything inside of parentheses. Now one
thing you may have tried to do just by habit is putting an h1 and putting your name and then going to the next
line and trying to put a paragraph. But think for a second what the problem with
this is. If you realize that the reason this is a problem, you may have tried to save this
and it says adjacent JSX elements must be wrapped in a enclosing div for an enclosing
tag. So I'm going to put this whole thing in a div. And it's a very common mistake to
make, especially as you're starting. So if you made that mistake, don't worry about
it. Okay, right here, we should have something that is at least working. So I'm going to
save this and see if it renders and there we go, we have a good start, all I need to
do is add my unordered list and put a few list items in there.

And I've always wanted
to visit Thailand, let's say Japan. And I've never been to the Nordic countries. So we'll
just add Nordic countries in general. And when I save this, I should see that my list
shows up in the browser. As a reminder, if you look in the very upper right, there's
a little left arrow.

If you press that and open the side menu, there's a chance to ask
questions on any pieces of code you're unfamiliar with or didn't understand. And I'm going to
be trying to check these as often as I can. So if you ask a question there, I'll try to
get back to you as soon as I can. Also, just because we finished this example, don't be
afraid to spend some time playing with this code a little bit more before moving on. Again,
the more you get your hands on the code and actually play with things, the more likely
this information is to actually stick and for you to be able to be productive with react.
Once you feel pretty comfortable with everything we've covered so far. Let's move on to the
next lesson. Let's talk really quickly about our setup here. Right now we have our functional
component inside of our index.js.

But remember, one of the main benefits of react is that
we get to create a lot of our own components. Eventually, we're not going to be able to
To put everything right here in this file, so what we need to do is we need to take our
my info component and move it into its own file. And it's a pretty good convention to
have each file contain just one react component. So the first thing I'm going to do is create
a new file.

And there's a quirk of Scripture right now that you won't be able to see me
typing this video, I'm going to right click up here by file since a new file and a dialog
box just popped up for me, and I'm going to give it the same name, my info as my component
with the same capital camelcase and everything. And you should see it pop up here now and
notice that the file, my info is spelled exactly the same with the same capitalization as my
component.

That's a really good idea, because it will make things a lot easier for you when
you're looking through a complex project tree. The next thing I need to do is take this component
out of this file, so I'm going to cut it, go over to my info dot j s, and paste it in.
There's a few issues here. You may remember in one of the early videos, we talked about
why we import react from react, even though we're not using react anywhere, try to think
if you remember why that is. The reason we had to do that was because of our JSX. We
used to have this component here and it contained JSX.

The computer won't know what this is
because it's not normally valid JavaScript. But the React library helps it become legitimate
JavaScript, which means we undo that back over in my info.js. Anywhere we're going to
be using JSX, we need to make sure to import react. Almost every react component you create
is going to have this line in it. The last thing we need to do is make this function
my info available to other places in my application. The way I need to do that is by exporting
it. If you don't feel totally familiar with import exports from ESX, that should be okay,
as long as you remember this export default and then the name of your component. But I
would also recommend that you go check out the free introduction to s6 course here on
screen. But now that this component is exposed through the export default, I'm going to go
over to index dot j s. And let's just Command S, we'll save this and see what comes up.
Notice it says my info is not defined.

Well, that's because we used to be declaring that
function here in this file and making an instance of it by putting these braces around it. But
now we're not doing that. So we need to import my info from my info dot j s, that's really
easy to forget that we can't just say my info dot j s. reason is because when imports don't
have a relative path, they will automatically look for a module with the same name that
you're providing.

This works okay with react and react Dom because they are third party
modules or dependencies that I've installed into this project. When it's one of my very
own modules, or one of my very own files, I need to make sure to provide a path. So
I'm going to say dot slash, which means from the current directory, look for a file called
my info dot j s. Another important thing to know about imports is that they assume that
you're importing a j s file or in other words, dot j s is the default extension. So I can
delete dot j s, and it will still work just fine. Now if I refresh, you get my component
back in the browser on the right. As your project gets more and more complex, it's going
to be really important that you have a good organizational structure. One simple organizational
structure I can employ right now is by creating a new folder called components where I'm going
to put all of my components in.

So I'm going to create a new folder. I like components.
And I'm going to drag my info dot j s into components and looking back@index.js what
do you think I'll need to fix here. If you notice that the path to my my info file is
now incorrect, because it's no longer inside of the root directory, I need to provide dot
slash components slash my info. And when I save this, everything should be working just
fine. Having a components folder is to me a little bit of an oversimplified way to organize
your application, because you're going to have so many components that you create that
you're going to need to find a structure that works best for you. And I'm not going to offer
one that works best. You'll probably even see me throughout this course using a few
different types. But each person has their own opinions about what the best organizational
structure is.

And it definitely depends on the project as well. Before moving on, try
playing with this a little bit. Maybe go change some code inside of my info, or maybe move
it into another folder or change the file name and see what you need to fix in order
for everything to keep working. Or if you're really wanting to be forward thinking you're
welcome to try and create a new component and nest that inside of my info, but this
is actually what we're going to cover in the next lesson. Once you feel comfortable with
everything we've talked about here, let's move on. In this lesson, we're going to talk about
parent and child components, our applications are going to be much more complex than just
having a single component my info, for example, render to the DOM.

Instead, you're going to
have a complex hierarchy of components that eventually lead down to JSX elements. I'm
going to start from scratch here just for repetition sake, so bear with me. Take a second to see if you can remember what
the next step is, you can start with something simple like getting HelloWorld as an h1 to
show up in our browser. In order for anything to show up on the page, we need to use react
Dom dot render. first parameter is what we want to render, so maybe h1 hello world. The second parameter is where do we want to
put that we'll be in an element called route in our index dot HTML. If any of that's confusing,
make sure to go back and review some of the previous lessons. But I'll assume that that
makes sense from now on. I refresh my browser, I get hello world. But we've moved past this
so far. Instead of having an h1 here, we put my info in less time. Instead, this time around,
let's create a component called app. An app is going to be an entry point into our entire
application.

In order for this not to fail, we need to import app. And in order for this
not to fail, because that component doesn't exist yet, we need to create it. So I'm going
to create a file called app dot j s. Notice it has a capital A because it's a react component.
In app.js, I need to remember always to import react. And before I forget, I'm going to export
default app works at this point app doesn't exist. So let's create it. Before I put anything
in the return, I'm going to refresh the browser really quick. And notice that there's a problem.
See if you can remember what we need to return here inside of this component. I need some kind of JSX element. So I might
put an h1 Hello, again, refresh. There we go. Or I could put any kind of other HTML
in here as well, maybe a div. Inside I have an h1, maybe something like
an unordered list. Maybe at this point, I decided that I want this to be an actual website
and I start putting things together.

So this top section might be a navbar. And below the
nav I might put a main section where most of my content will go. And at this point,
I would do something like add some styling to my unordered list so that this was more
like an F bar. As you can see, this app component is getting pretty large. And it's kind of
defeating the purpose of react, we talked about how we can take each piece of HTML and
put it into its own component. We're not really doing that very well here. Instead, we may
decide to create separate components for each little piece of HTML that we need on our page.
Take a look at this diagram to get a better understanding of what I'm talking about. Here
we're rendering the app component, but app may decide to render another component called
my info where my info may eventually render some kind of regular JSX element. Notice I'm
making a distinction between components and elements. elements are the ones that boil
down essentially to regular HTML code. Notice that here I have a lowercase D and Dev.

That's
a dead giveaway that this is a regular element rather than a component that I've created.
On the other hand, my info starts with a capital M. And that helps me understand that this
is a component that I've created. You may have heard of how the DOM or document object
model is oftentimes referred to as a tree where the HTML element is the most base root
of that tree. In our case, we can think of the app component as being the root of this
tree. And the app component isn't limited to just rendering my info. It could also render,
for example, a footer and that footer could render an app actual element called footer,
which has all of the HTML relating to our footer in it.

And if we have a footer, we
naturally probably want some kind of header. I've specified these as awesome header and
awesome footer. So it's not to be confusing with the regular footer element. And just
like app is rendering more than one component header may also render multiple components,
for example, a navbar, but also maybe a logo component. And those eventually would need
to end up as regular elements of some sort, in this case, an image element and the nav
element. Hopefully, here, you can start to see how our react application could become
more and more complex as time goes on. And this is only scratching the surface. So in
our sample app here, let's create a little footer really quick, going to create a new
file called footer dot j, s with a capital F, as seen here, which you'll need to import
react from react is always going to export the thing before I even create it just so
that I don't forget. Notice here the difference between the capital
F footer and the lowercase f footer.

As I mentioned before, the lowercase f footer is
the actual element that will get rendered to the screen. Whereas the capital F footer
is the component that I'm creating. It's just a function with a name. Inside here, I may
put, I don't know an h3. This is my footer. I've created this component. But notice it's
not showing up on our page. That's because our app is not rendering a footer anywhere
and need that footer in this file in order to create an instance of it. So I'm going
to import footer from dot slash footer. And maybe right under
my main section, I'll include the capital F footer that I just imported. refresh this
now. There's my footer element. At this point, I have kind of a strange mixture
of elements that are regular JSX elements being mixed in with components that I have
here. If I can, I really like to have this app component almost be like a table of contents,
where instead of having some elements in some components, it's mostly just components.

So
this might look like this. header, main content, and footer. And then I can go to each of those
individual components and see what elements those are rendering. Now header and main content
don't actually exist. But the point is, you can continue to nest your components as deeply
as you need, we're going to get a chance to practice this in the upcoming lesson. But
if you'd like you can spend some time trying to fix this code. Since header and main content
currently don't exist, go ahead and create them.

Also, before we move on, feel free to
click in the blue slides in the lower left to check out that diagram once again. Once
you feel pretty comfortable, let's move on to the practice. Okay, let's jump right into
the challenge, you're gonna set up a react app from scratch. Once again, what you're
going to render is the root app component, as mentioned here, and that app component
should render three separate components, each of which will have some kind of elements that
they render, first, a navbar component. Second, a main content component, and third, a footer
component. So give this your very best shot. Remember, you can always turn to Google for
help. Once you think you have this challenge, then move on with the video and we're going
to do this together. Okay, let's get started. We're going to import react from react, React DOM, React DOM, we're going to use react Gmes render method
to render a component called app ranks you select the root element app doesn't exist,
so we need to import it.

That file doesn't exist, so we need to create it epital a app dot j s. Remember, I like to
treat this file as kind of a table of contents. So we'll need to import react from react again. At this point, I'd like to just put something
on the page to make sure that I'm on the right track. Okay, at least not showing up tonight.
No, I haven't made a mistake up to this point. If you look back in the challenge, it said
to create a navbar main content and footer components, we could do this in any order,
we could first create the files, and then import them, we could import them and create
instances here and then create the files, whichever way you want to do and makes most
sense to you is totally fine.

I'm gonna finish my app component first, and then go create the components necessary for that
to continue working. And remember, everything needs to be surrounded in a single component,
because any given component can only return one element. Here, I'll put my header content and footer. Up GS needs to know about those first, so
I will import those. And those files don't exist yet.

So I'm going to create, you can
imagine as I keep creating new components that this is going to get pretty cluttered.
So I'm actually going to put everything into a components folder. drag my footer, header,
and main content into my components folder. I also need to fix my app j s. References
here. Okay, over in those files, I'm going to start creating those components. This will
just have a basic footer element. For now, I'm just going to fill it with some text because
it's not too important what's there. If creating these components is still a little bit foreign
to you, and you have to remember what step comes next, I'd recommend actually retyping
everything from scratch. Because I've done this enough times, I'm actually just going
to copy everything and paste it into header changing some of the references.

It'd be the same thing for main content. elicit
this just says main instead of main content, and that it's got a lowercase M. Hopefully
you understand at this point that this is because this is a regular, you could say HTML
element, main, header and footer are all semantic html5 elements. main content, however, is
something that I created. And so I couldn't say something like main content, because it's
not a real HTML element. Let me refresh the page and see if it's working. Okay, it's pretty
boring. And it looks like I forgot to put this is the main section.

Right. In the next
couple videos, we're going to learn about actually styling this because this is pretty
awful. And we want this to start looking good. Once again, feel free to pause the screencast
and play with the code that we have here. Or if any of this was still confusing, go
back to the beginning and try it again from scratch. Once you feel comfortable, let's
move on. Alright, so from what we've learned so far,
we can get started on our phase one of our to do application. So what you'll do is you
will initialize a new react app from scratch, you're going to render an app component in
the index js file here, which means you'll need to create an app component from scratch.
And your app component should render three or four checkboxes with the paragraphs or
spans or whatever kind of text you want next to it as if you're making a to do list with
some hard coded items already in it.

So pause the lesson here and give this a try. And then
we'll go over this together. Okay, so let's do this. I'm going to erase my comments here.
And as always, we need to import react from react, import, in this case, React Dom from react
DOM. We're gonna use react Dom to render an app component to the screen. And we want that
to be in the element with the ID of route. The app component doesn't exist yet. So we
need to import it. And this file doesn't exist yet. So I'm going to create it. We'll move
over to that file. Now. Where I want to also import react from react will create it our
functional component and want to remember to export it before we forget. This functional
component should return the div will need to wrap everything in it. Because
it can only return one element at a time. And inside this div, we will put our input
type checkbox. And our paragraph. For now we'll just put some placeholder text. You
save this and see how it looks. Okay? It's pretty ugly.

But we're going to get to that
later. And it said to do three or four times, so I'm just going to copy and paste these
two lines here. And there we go, we've started our application. That's pretty straightforward.
And the next time we see this, we're going to have learned about styling. And we're going
to add some style to this, so it isn't quite so ugly. So if anything was confusing, go
back and play with this. Again, try to do everything from scratch if you'd like, feel
free to post a question in the q&a section. And when you're ready, let's move on to learn
more about styling. This example is the same one that we finished
with at the end of the practice in the previous lesson. And I wanted to take some time to
learn how to style this. Now, there's actually a bunch of different ways to style things
in react. And we're going to start with the one that's probably the most familiar to you.
And that's just using CSS classes in CSS rules on those classes.

Let's drill down the tree
here and see where we can actually start putting some classes. You'll see on my index js, I'm
rendering an app component. And the app component is rendering a div with three other components
header, main content and footer components. And each one of those is just a basic component
that either has a single element as part of it with some text inside, let's focus our
efforts on styling the header. And normally, what you do in HTML, when you're going to
add a class to something is you add a new property called class. But one thing we need to remember right here
is that we're not actually dealing with HTML. Instead, we're dealing with a variation of
JavaScript JSX.

And something you'll just have to remember with JSX is that using class
as a property name doesn't really fly. Instead, we need to use something called class name with a capital N. A lot of places will tell you the reason that
you have to do that is because class is a reserved keyword in JavaScript. But the truth
is underneath JSX is just using the vanilla JavaScript Dom API. And if you've ever used
the vanilla JavaScript Dom API, you'll have something like document dot get element by
ID, something. If you wanted to add a class to that, you could say dot last name, plus
equals and then add a new last name. I prefer class list myself because it has properties
that you can use to add and remove classes. But that's beside the point. Class Name is
an underlying JavaScript Dom API property. And so using class name as part of our JSX
is simply a way to access that Dom API under the hood, which is what JSX and react is doing.
That's just a little bit of extra background that you may or may not be interested in knowing.
But the point is, all you need to do is wherever you normally would say class in HTML use class
name instead.

Here I'm going to say class name equals F bar. I'm going to delete this before it becomes
a problem. Then over in my style, that CSS, I just need to select the navbar and include
whatever styles I want. For example, I might change the background color to purple. If
I save and refresh this, you can see that now the background color is purple. I'm going
to copy and paste in some style since this isn't a course on CSS, so that we can get
something that actually looks pretty good.

Okay, the only thing I've done here was added
a zero margin to the body so that it went all the way to the edge, and a number of styles
to the navbar. If you're interested in actually checking this out, feel free to pause the
video. But the point is everything that you normally do in CSS is going to be essentially
the same as you do here. The only change we've made so far remember is that we have to use
class name instead of class. One of the other things to keep in mind that maybe tricky to
remember at first is that you can only apply the class name attribute to react elements
like header or paragraph or h1. If you try to apply class name to a component that you've
created, such as header or main content, it's going to do something a little bit different
than you think. And we're going to talk more about that in the future.

But for now, just
remember that the only thing you can apply classname to are react elements and not react
components, the things that look basically like regular HTML. Another thing that can
be kind of tricky in the beginning is if you're using something that requires different levels
of your tree hierarchy, like Flexbox or CSS Grid, where you need to know which items are
the flex container and which items are the flex items. be tricky looking at your component
to know exactly how that works. For example, if I wanted to make this div a flex container,
and I wanted to specifically style one of the items they're in, I would need to go to
the header component or the main content component.

And look at the elements, they're in order
to give them the class names that are necessary. For example, if I go to header js, this header
element will be the direct child of this div. Think of it as react, taking the contents
that this header component is returning, and copying and pasting it into this place. When
you create your react applications and you inspect with the dev tools, you'll see that
this is actually how things end up in the DOM tree. So take some time to play with classname.
In this project, see if you can style the main section in the footer a little bit differently.
And once you feel good, let's move on to the next lesson.

Before we get too much further, I wanted to
cover some caveats about the way that I tend to write my JavaScript, you may have noticed
that I tend to leave out things like semi colons, you may be super used to putting semicolons
everywhere at the end of a statement, I personally have recently decided that I kind of hate
them. And so I've been removing them from my code. Obviously, there's still some places
that you simply can't avoid them. For example, when you're writing a C style for loop, zero
semicolon that's necessary in order to separate the three different statements on one line.
But for the most part, at the end of statements, they're not really required, and they won't
break anything by not having them there. This is totally a personal style decision. And
like I said, one that I've only recently made.

In fact, it's such a strong habit for me that
I may accidentally put some semi colons in future videos. Another personal preference
is although ESX technically gives us the ability to put arrow functions everywhere, we used
to have the function keyword. For example, I can say const app equals an arrow function.
And one of the benefits of this is actually that I can actually just wrap everything in
parentheses and get rid of my return. And in this case, I could even simplify it like
this. I've either not yet gotten used to this syntax, or I simply don't care that much for
the look of an arrow function.

I think they're extremely useful in certain instances, for
example, whenever you normally would put an anonymous function or when you need to write
a class method, which we'll talk about later. But my personal preference is to keep the
function keyword and it just to me makes it look a lot more like a regular function component.
There's a lot of people who will disagree with that. And I'm totally fine with that
I totally understand the preference for doing it as an arrow function. But me personally,
I tend to keep my function keyword in there for my functional components. I'm not going
to necessarily advocate for one way or the other. So that's totally a decision that's
up to you. Okay, I just wanted to get some of that out of the way. Let's move on. Before we can move on to talk about inline
styles and some dynamic styles, we first need to understand how JSX and JavaScript play
together, we saw that in the middle of our JavaScript, we're able to return something
that looks like HTML, but we've discovered is actually JSX.

What if I have a variable
that I want to stick inside of my h1? Maybe for example, I have a first name and the last
name. And instead of saying hello world, I want to say hello, Bob's a role. Well, I might
be tempted to say hello, and then first name, plus space plus last name. But I'm assuming
you can figure out exactly what's going to happen here. When I save this. It literally
interprets every character that I typed as if it were the text inside of the h1, which
is pretty much exactly what we should expect it to do. So how do we jump into JavaScript
while we're in the middle of our JSX, they actually made it really simple. All we have
to do is surround any JavaScript that we want to be interpreted with curly braces. And once
I refresh this, you'll see that it actually interpreted everything inside of the curly
braces as JavaScript. The way I like to think of this is we're looking at JavaScript, JavaScript,
JavaScript, JavaScript, and now we're in JSX land.

Once we're in JSX land, which actually
started with this less than symbol, everything will be treated as if it were regular HTML,
meaning any text inside is going to be literally interpreted. However, as soon as we want to
get back into JavaScript, we put a curly brace and now we're back into JavaScript. Learned
JavaScript JavaScript JavaScript, closing curly brace tells me we want to leave JavaScript
and go back into JSX. And you can do pretty complex JavaScript operations inside here.
Since we've mostly converted over to the e6 syntax, I'm actually going to change this
to the string templating syntax of ESX, where you put backticks, and then $1, sign curly
brace surrounding any variables that I want to show up, then I can just put a space itself,
and that will be treated as a literal text space, then $1, sign curly braces again, last
name. And I save that and you see, we get the same result over in the browser. Because
this is just regular JavaScript inside pretty much anything that I could regularly do in
JavaScript I can do inside of these curly braces.

Let's look at one really simple example.
Maybe when it's morning, I wanted to say good morning. And when it's night, I wanted to
say goodnight, without actually having to come in and change the code manually. Well,
I can just do some simple JavaScript to set that up. I'm gonna speed this up really quick,
but we'll get a chance to explain it in a second. Here, you can see one example where
I've created a new date instance, and simply put in my h1 It is currently about. And then
in JavaScript, I got the hours and did a modular 12, so that it would be in a 12 hour clock
system.

Alternatively, I could check the current hours for what time of day it is, and set
a string equal to either morning, afternoon or night, which let's try that out right now.
So here, all I did was set a variable called time of day, and did a simple if else, to
check what time of day it was. Then down here, I simply said good, jumped into JavaScript.
And said time of day, when I refresh this, I get good night.

Because it's nighttime where
I'm recording this, hopefully, you can start to see the possibilities that this brings.
And we're gonna see as the course moves on that this is actually really useful. We needed
to see this right here simply so that in the next video, when we talk about inline styling
with the style property, the way that we have to do that, we'll make a little bit more sense.
Feel free to mess with this, there's some pretty fun things you can do. Once you're
ready, let's move on. Let's pick up really quick where we left off
in the previous video, we created this little application to tell you what time of day it
was.

Essentially, we want to add some styles with inline styles this time, and we're going
to see why this might be the way we choose to do it instead of using a class name. Normally,
to do inline styling with HTML, we simply put a style property and set it equal to whatever
CSS styles we want. Maybe we want to change the color to be this kind of yellowy color
that I just grabbed. Well, let's see what happens when I try to save this. Let me open
the console. Notice that it says the style prop expects a mapping from style properties
to values instead of a string. We have to remember here that we're not actually inside
of HTML. So sometimes the rules are going to be a little bit different. In this case,
JSX expects style to not be a string, but instead to be an object, a JavaScript object.
So I'm going to delete this and put in an object and say, color colon, and then as a
string.

That color again, notice that I have some syntax problems. Remember, anytime I
want to change from JSX into JavaScript, I need to wrap my JavaScript with a set of curly
braces. This can be a little confusing at first, because objects are also wrapped with
curly braces. But in order for this to be a JavaScript object, I need to wrap it in
curly braces. So we end up with two sets of curly braces. Now when I refresh this, you'll
see that I get my more orange or yellow color as the color of this text. If I want to add
additional styles, because this is an object, I just add another key value pair. For example,
maybe I want it to have a background color of this somewhat red or color that I got. Well,
what's my problem now take a second to see if you can figure out what's going on.

Remember,
because of this set of curly braces over here, we're actually inside of JavaScript. And inside
of JavaScript, I can't have a dash in the middle of my property name. I technically can in regular JavaScript by surrounding this
with quotes, but that's beside the point. Because of this inside of the object where
we're defining our styles. We're going to change anytime that there's a dash, we're
going to get rid of the dash and make everything camelcase. This right here is the legitimate
style object. Let me refresh. And you can see now we have a different background color.
As you might imagine, this style object right here may end up getting longer and longer,
in which case this h1 line is going to become really long and it looks a little bit ugly.
to split this out onto separate lines, so what I prefer to do is actually make a separate
variable. Let's just generically call it styles for now. And put this entire object into that
variable. We can split this onto its own lines without it looking funny.

Inside of my curly
braces here, where I'm now inside of JavaScript, I can just put variable name. And that's going
to be exactly the same thing. Notice when I save, it continues to work. What's nice
about this is as I continue to add styles, it doesn't clutter up my h1 down on line 24.
There's a number of little tiny quirks that we have to remember when we're doing these
style objects. For example, anytime I have a measurement that's going to be in pixels,
I technically can just put the actual number value in place, and the
default will be pixels.

So when I save this, you see that I get a slightly smaller font. But 200, I get a really big font, and so forth.
I can also still specify pixels. But obviously, that's not going to work with numbers by putting
200 pX because that's not valid JavaScript anymore, I need to turn this into a string.
And now it's valid JavaScript again. And then anytime I want to use another unit like M
or VW or percentage or something like that, I will also put that as a string. Also notice
once again, that I've replaced the dash with a camel cased version of font size. There
are some pretty interesting limitations with this. For example, it looks pretty funny when
you have to add things like vendor prefixes. But there's other things like pseudo selectors,
such as colon hover, that become actually impossible to do inside of these inline styles.
If you need something like that, for now, you're better off just doing that in CSS and
using class name.

And in the future, you can learn about really cool styling libraries,
such as styled components. For now, we're just going to keep it simple and stick with
either inline styling or using class name and using CSS styles. You may ask yourself
why you would ever want to even use an inline style like this. Well, one reason is that
you may want something to be more dynamic, in which case JavaScript would actually determine
what the styles are. Let's take a quick look at what that might look like.

Notice what
I've done here, where I moved the styles up here above my if else, and set a default font
size of 30 pixels, then I let my if else in my JavaScript actually determine what color
the font is going to be, I changed not only the time of day string, but I also changed
the color property of my styles object. Because it's an object, I can access and create properties
just by using the dot syntax. If it's morning time, I use this color.

If it's afternoon,
I use this color instead. And in any other case, when it's night, I use this color instead.
Because I'm recording this at night. This red color is the one that's actually showing
up. But let's see what happens when I create the date not for the current time. But instead
for a time that was this morning. This is the year, a month today. Let's say it's 10am. I save this, notice that
we get instead the color that is the color for morning. If I change this to, let's say
15. And it's hard to see, let me choose a different color for the afternoon. You can see a little more clearly this is
choosing a different color for the afternoon. This may be a little bit contrived. But the
point is we can have dynamic data that actually changes the way that our hard coded components
display. Take a second to try and think of different things that you may be able to accomplish
by having these kinds of inline styles.

I'd also at this point, recommend spending as
much time as you can to really solidify the stuff that we've covered together. So far,
we're about to come up on a topic that typically is a little bit challenging for some people
to really help you to make sure that you understand everything we've talked about up until now.
In the next lesson, we're going to talk about a concept called props, and how we can make
our components quite a bit more reusable. Props is a super exciting topic. And we're
about to get into parts of react that make it extremely useful. So get excited. And let's
move on to the next video when you're ready. Alright, so let's pick up where we left off
with the to do list. Now that we understand Parent Child components and how a parent component
can render a child component, and we understand how to inject some styling into our react
apps.

Let's progress our to do list forward a little bit. So before we get to styling,
what I want you to do is to take these input and paragraph pairs, and I want you to put
them into their own component called to do item. For now it will still have just this
hard coded placeholder text here paragraph And later, we're going to learn how we can
actually make those different.

But that'll be the first thing to start with. And then
essentially, you have a blank canvas to paint whatever kind of picture you want, you can
make this look as traditional or as weird as you'd like. So go ahead and hit pause and
give that a try. Alright, so the first thing is moving each of these into their own component.
So I'm just going to copy this and create a new file called to do item dot j s. And
while I'm still here, I'm going to import the new item from that file. Let's go over
to to do item, we'll import react from react, create our functional component, we'll just
return the thing that we copied before. And remember, I can only have one element that
I'm returning at a time.

So I'll wrap this all in a div. And then over in app j s, we
don't need these anymore. But instead, we can just create instances of our to do items.
And everything looks the same. Now since this isn't necessarily a course on styling with
CSS, I'm basically going to cheat right now, I'm going to set myself up by creating a class
here of to do list. And over in my to do items, I'm going to give this div a class name of
your item. And I'm basically just going to paste the styles that I've already created.
Okay, and you'll notice that let me make this a little bit bigger. And notice that I just
kind of came up with a cool little paper looking stack and have a checkbox next to each one
that's a little bit prettier, with nicer font and little separation and so forth.

Obviously,
you're welcome to pause this and look through some of the styles that I have. But it's really
nothing too fancy. And since I'm not really a wizard at CSS, stuff like this, with the
cool little effect on there, I basically just found online. main takeaways, though are to
remember that if you want to apply class to your elements, you'll need to use class name
instead of class. And if you wanted, you could apply some of these styles just right here
in line. So with a little bit of CSS styling, our to do list is already looking a lot better
than it was. Now we are checkboxes do technically check and uncheck but what we're going to
do is make sure that when we check these, some actual data is changed, which will allow
us to do something cool, like put a little strike through through these texts.

Once you
feel pretty comfortable with this, let's move on. Let's talk first about the concept of props
in react. To do so we're going to look at just a regular HTML file, notice that this
has nothing to do with react. This is just a basic index dot HTML, I want you to take
a close look at the three elements that I've put inside the body, the anchor, the input
and the image and think about what's actually wrong with them right now. None of these things
are actually going to do anything important. anchor tags need an H ref for them to make
any sense at all. This way, the HTML spec can define the anchor tag once and allow us
the ability to change the place that the link sends us. For example, here, I may put a link
to Google. Or obviously, wherever I want to send the user to in this link, an image tag
is very similar. An image tag alone without the source property is pretty useless. An
image element needs a source in order to function correctly. This may either be the path to
a local file or the URL to an image hosted online.

In those two examples with anchors
and images, the href and source properties respectively, are required. Inputs technically
will show an input on the page. But I can beef it up a little bit by adding additional
properties such as placeholder, or the name property, or the type property type is an
interesting one. Actually, it allows me to change this input to be multiple different
things. For example, this may be a radio button or a checkbox or a regular input. That input
could be either text or an email or a phone number, and even changing it to a submit button.
A lot of times these are called attributes. But another legitimate word for it is a property.
If this simple concept in HTML makes sense to you, which I assume by now it probably
does. Understanding props in react is not too difficult. Instead of using the built
in HTML tags, since we're creating our own components, we can actually make it so that
we can allow properties to modify the way that the component acts.

So in the next video,
we're going to see how we can actually do that. I want to make one more conceptual point before
we actually get into using props with react. This here is from the YouTube homepage. And
while I'm pretty sure the YouTube homepage doesn't use react since Google is the main
backer of Angular, the concept will remain the same. Think for a second how this page
may be developed in react, something you'll begin to get really good at doing is noticing
how something can be divided into separate components. For example, notice that each
of these separate pieces of the page are all very similar in their own way. If you notice,
each one of them has an image on the top that takes up about the same amount of space. Each
of them has a title, which is in bold and appears usually directly below the image.
Each one has a number of views.

Each one tells you how many days ago it was published, each
one has a little timestamp inside of the image that tells you how long it is, you can imagine
that the creator of this page didn't actually go into the code and copy and paste this a
bunch of times. If this were developed in react, then you can imagine there might be
a video title component that is created. And that component has a number of components
inside such as an image, maybe an h3, a little timestamp box, and so forth. The main point
of what I just said is that it will be a single component that's developed once, but we need
to make it so that that component can change depending on the different properties such
as the image URL or the title.

That's what we're going to be working on in the next video.
Right before we move on, though, I wanted to get you used to the idea of thinking in
terms of react back a few lessons when we talked about parent and child components,
that tree can go as deeply nested as you want. In fact, you can see here, we have different
lists. So there may be a component that is a list component, which renders a number of
video title components, which in themselves render an image and an h3 or whatever, like
we talked about. Also, over here on the left, you can see a number of things on the page
that may have only been developed once as a single component. And then given a property
of maybe a little image on the left and the text that should show up as part of the link.
Hopefully, you can see how the idea of web components and reusable HTML is really powerful.
And this can help you understand why frameworks like Angular and react and Vue JS are very
popular.

So that's enough with the conceptual let's move on to some code and see how we
actually do this in react. So let's take a look at an example where it
would be really nice to have separate components, but not just separate components. But those
that could take different attributes or props in order to make them a little bit more dynamic.
Here, I've created just a really basic contact card list, where it shows the image of the
contact and a name for the contact the phone, and email.

Right now I only have four contacts
and my contact book. To start, we know that it would be really nice to take these pieces
of repeated HTML code and put them into their own components. But from what we've learned
so far, we would actually have to create four separate components, one for each individual
contact, but that's not really gonna work for us. So first things first, let's actually
create the component. And then we'll learn how to make it more dynamic. We're going to
create a new file called contact card, Gs. And I'm going to take this div, which is the
repeated div across these four contexts, and just copy it. And I'm going to start a new
component. If you'd like, feel free to pause the video and see if you can figure out how
to do that. As always, for components I'll need to import react from react Yak. And I'm going to export the function
that I'm about to make my spacing here. And this is a great start. The problem with this
is that it has a hard coded image source, a hard coded name, hard coded phone, a hard
coded email and so forth.

Instead, we're going to want to figure out a way to make it so
that this contact card when I make separate instances of it will be able to take as properties
the different information that I'm going to put into these places. Another quick conceptual
point you can think of has to do with functions, which actually mirrors pretty nicely what
we're doing because we are using functional components. When you create a function, let's
say add numbers. Maybe this function returns the result of one plus one. Well when I want
to do an operation with one and two, or one and three or two and three, I'm not going
to want To create separate functions for every single one of them.

Instead, we use function
parameters, maybe a and b. and make it so that any two parameters we pass into this
function, we can get a different result depending on those inputs. The same concept of adding
parameters to a function to allow the function to be more reusable is the same thing we're
going to be doing with react components. Let me delete this. In order for us to illustrate
this, let's go over to App j s. And I want to be able to replace all four of these with
the individual information for each component. But let's start by actually putting the component
in there, I would like to be able to say, I want a contact card here. And I actually
want four of those.

Well, for this not to fail, I need to import contact card from that
file. And now comes the time to actually pass down individual information for each contact
card, just like we did with regular HTML where you pass in an attribute or a property right
here, we're going to do the exact same thing, except this time, we get to decide what the
name of that prop is. For example, each of these contact cards has four pieces of dynamic
information, the image URL, the name, the phone number, and the email address. So let's
pass a property down for each one of these, it's actually pretty simple, I'm going to
say name, equals, and then put in the name that I want this contact card to use. And
I'll do the same for the other information, image URL on an email.

Now, for me personally, when these start to
wrap on two separate lines, I like to put everything on its own line and in rented, I'm gonna do that really quick. I'm going to go through and do this really
quickly for the rest of the contact cards, putting each of these individual contact card
information into properties of the contact card component. Notice when I just refreshed even though I've
put separate different pieces of information into each one of these contact cards, I'm
still getting Mr. Whiskers send four times. The reason is a contact card currently has
hard coded values inside of itself. But we're passing in separate props, name, image, URL,
phone, and email. So let's see how we can inside of contact card j s access the data
that we're passing down to the contact part, over in contact card, one thing that we haven't
put in quite yet, is inside the parentheses here in this function, it's going to take
a parameter called props.

Because it's a function parameter, you technically
can call it whatever you want, but it's a strong convention to call it props. Props
is an object that has properties of that object, each one being a prop that you passed in,
or rather, the name of the prop that you passed in. What I mean by that is, we will have inside
of contact cards will have props dot name, and props dot image URL, over in contact card
j s. Let me just console log ops. Take a look. Take a look at this, we got four console log
entries, the reason being we have four instances of our contact card component.

And the props
are an object with a name, image URL, phone and email properties. This means now inside
of my code, instead of having hard coded values here, I can use the property of the props
object that's coming in. So I can say source equals, and I can't just say props dot image
URL, think for a second why that doesn't work. And think of how you might fix it. Remember,
when we're switching between JSX and JavaScript, we need to use curly braces around our JavaScript.
We can do the same thing for the other values here as well. Props dot name. Here, I can
leave phone colon space as a hard coded value. And then just replace this with props phone
in the same thing with the email. Now when I refresh, I actually get my four separate
contact cards with the individual information. I'm going to delete this console log so it's
not cluttering things up. And as easy as that I now have a component that is reusable in
a lot of different ways.

Now at this point, I want you to think What would my component
look like if my contacts had, say 50 properties to them over an app js, each of these contact
cards would end up getting pretty long, right? I would have a prop for each individual thing
that I'm saving about that contact, which like I said, perhaps could be something like
50 different properties. Another legitimate way to do this is instead of passing down
each part of this person or contact as an individual property, I could pass down an
object that was the entire contact.

For example, instead of name, image URL, phone and email,
I might simply pass down a prop called contact, whose value is an object. Remember, I'm going
between JavaScript and JSX here, so I need to put a double set of curly braces, the first
one getting me into JavaScript, inner one being the object itself, that object would
have a name, an image, URL, phone, and an email. This technically would allow me to get rid
of these four properties, and just pass down the single property called contact. Now, this
may not actually look better than what we had before. But we're going to see eventually
how this data isn't usually hard coded in like this, but rather comes from something
like a JSON file, in which case, it can be really nice to pass down the whole contact
as a single prop. However, our component is going to be broken now. Notice when I refresh,
the only thing that shows up are the phone and email hard coded text.

Pause the video
and try to think why that might be. The reason is over in contact card, we're receiving a
props object, and we told it that that object would have a property called image URL and
phone and name and email. However, for our first contact card, we're no longer passing
a phone, email and name or image URL. Instead, we're passing a prop called contact, which
is an object. So let's go over to contact card, pause the video and see if you can fix
this to work. If you're having trouble, one thing that may help is to console log prompts. See what's actually showing up here.
Okay, now that you can see this console log, give it a shot again. Notice the first one is not receiving a name,
image URL, phone and email like I mentioned before, but instead is only receiving a single
property contact. And that contact property is an object, which means I would need to
change everything to props dot contact dot image URL, and props dot contact dot name.

And the same for these other ones. Now, of
course, when I refresh, I'm going to have a major problem because my other components
aren't receiving a prop called contact, therefore, it's undefined. And I'm trying to access the
image URL property of undefined. So this won't just not show up, it's actually going to crash,
which means I need to go back to App j s, and fix each of these other contact cards.
I'll spare you the monotony of watching me do that and speed this up. Okay, that was
pretty tedious. Let's refresh and see if that works. Okay, now we're working again, our
contact card is passing down a single prop called contact, which is an object that has
all of the properties that we want. Again, normally, this won't be hard coded, but instead
would be something you get from a data file, such as a JSON file, which we're going to
cover in a future lesson. And over in contact card, I'm receiving all of my props as an
object called props.

And since I only pass the single prop down, I have props contact,
but props contact is an object. So that has properties itself like image, URL, name, phone,
and email. Again, this concept can be a little bit tricky. And I totally understand if this
didn't make sense the first time through. As I mentioned before, the sweet benefit of
schema is that you can pause this and actually mess with this code. So even if you feel like
you understood this, I'd really appreciate if you pause the video and go through and
actually mess with this, change the data over in app j s, see if you can then reflect it
to show up correctly on contact card. Also, feel free to go grab different image URLs
and put those in and see how it affects the code. More you mess with this more likely
you'll be to actually understand it well enough to implement it yourself.

To Go ahead, give
that a shot. And only after you feel really comfortable with it, move on. Okay, I'm sure this has been pretty obnoxious.
But this is the very last time I'm going to ask you to do this. I want you to create another
react app from scratch. Obviously the repetition is going to be really good for you and what
this react app should do is render an app component which should be in its own file.
And the app component should render five joke components, we can see that this is going
to help us practice the parent child component tree, it's going to help us practice putting
components in their own files.

But the main thing we're going to practice is passing props
down through the joke component. So each joke component should receive a question prop and
a punch line Prop, and then render those to the page however you want. That's just kind
of the basic part of the practice. But I've added a little extra credit section, which
I'd really encourage you to try. So in this case, if your component does not receive a
question prompt, you need to think how might you make it so that it only shows the punch
line instead? For example, if you've hard coded in a question, text that says, a question
colon and then appstack question. Obviously, this syntax is incomplete. But how are you
going to make it so that you don't have question, colon, and then an empty space? Also, while
you're at it, see what happens when react receives a prop that's undefined? If you don't
have a question colon, and you're also not passing down a question Prop, see what happens.
And while you're at it, spend some time practicing the style, if you joke component, make it
look good.

So pause the video do this practice. And we'll go through this together in just
a few seconds. All right, I'm gonna delete this. And I'm
gonna actually leave some of these comments here, just so that I can remember exactly
what to do. We know we need to in a basic setup, import react, and react, import react DOM, React DOM, when to use react DOM. To render our app,
we're gonna put it at the root element.

Don't have apps, I'm going to import app from a
file called app that doesn't yet exist. And I'll create that file. Now. I put a app.js.
Over in that file, I need to again import react from react for the app component that I'm about to make,
wrap everything in a div. Okay, and here, we're going to render our five joke components, that should be capital J 2345. Now for this to know what I'm talking
about, when I am trying to create an instance of a joke component, I will need to import
that. And that doesn't exist yet. So let's make that I'll create a file called capital
J joke. dot j s. And over in joke j s, let's again, import react from react. Default joke. And
before I get too deep into playing with props, I'm going to just have it render something
simple just to see if it's working.

I may have forgotten
something. But let's check this out. Okay, yep, my five highs on the screen, which
means my five jet components are working. React Dom dot render is rendering the app
component, the app component is rendering a div with five joke components. And the joke
component is just rendering an h1. And that's how I'm getting five highs on the screen.
And that's the tree that we're working with. While I'm still in this file. I'm going to
work on the props here.

So I know that I need to pass in a variable. I'm going to call it
props because that's the standard. And let's start with something simple. I'm going to
render a div with maybe a couple h threes inside. One will have the
question. One will have the answer. If you had gotten stuck anytime before this, I'd
really like you to pause the video and go review these things that we just went over
and then try it again from scratch. You can go back in time to the beginning and actually
try to build this out yourself. Then once that makes sense. Come back to this point
and move on. Now if everything did make sense up to this point, pause the video here and
see if you can figure out how are we going to get the question from our joke that's being
passed in. Of course right now.

It's not yet being passed in the wind it is how are we
going to place it right here. Remember, we're inside of JSX right now. So I can't just say
props question because that would literally put the text prompts question here. When I
want to go inside of JavaScript, I need to surround it in curly braces. Notice that I
get nothing On the screen, think for a second why that might be. Let's actually console
log prompts question. Open the console and see what shows up. That's what I get. No.
That's because this joke component when I'm creating instances of it in my app, I'm not
actually passing in a question or a punchline prop. So when react tries to render a component,
and we're not passing it any props, everything will be set as No. What's really cool about
react is if any JavaScript inside of JSX evaluates to something like undefined or no, it simply
won't display it.

This right here is going to be something we need to figure out how
to fix when we have our joke components that don't take a question prop. But for now, let's
assume that they all have a question and an answer or a punch line. So over here, I'm
going to also add props dot punch line, and they can delete my console log here. Let's
go back to App j. s. And let's actually provide a question in punch line for every one of
these jokes.

As I mentioned in a previous lesson, I prefer
to put these on their own lines, if they start to get so long that they're wrapping around. You may decide this isn't your style. And
that's totally up to you, I still go back and forth as to whether I want this closing
bracket to be on the previous line or not. So let's refresh this and see what we get.
Cool. Everything's a little bit squished together. So you may decide to do something simple like
at the end of a joke, you may put a little break tag, or maybe something like a horizontal
rule.

But obviously, however you want to style it is totally up to you. And there we have
the basics of the first part of our exercise. Now, as we see in the extra credit, some jokes
are only a punch line with no question. And as it stands, I have this hard coded word
question colon space here. I provide a joke that doesn't have a question. Like my favorite
one only has a punch line. See, when I render this, I get a question with nothing there.
We're going to talk in a future lesson about conditionally rendering parts of our page.
But for now, think about the way that we style our page and see if you can think of a way
that we can make this disappear if there is no question. So video and give that a shot.
Again, there's actually going to be a real way we do this with something called conditional
rendering. But for now, you may find a way around it where you can say I want this h3
to have a style feed display of none under certain circumstances.

But afraid here I use
the ternary operator to decide what that should be. inside of my object I could say essentially
is props that question a thing? Is it truthy, if so displayed in the regular block format,
but otherwise displayed is none. Notice that my first one has an h3 that is now displayed
none because it no longer has props question. If you're not very familiar with ternary,
I highly recommend you go spend some time learning about them because they're actually
used quite often in react. Another slightly more concise, but perhaps more confusing way
to write this would be instead of using a ternary.

And having a default of its own default,
like an h3 being display block. We can get rid of that. And we could actually say if
there isn't a proper question, then we want to display
none. But otherwise, basically ignore this rule totally. If you're not familiar with
using the double ampersand in this way, we're going to talk about it in a future lesson.
But just know for now, this totally works. You can see over in my browser, I have just
an answer to my joke that doesn't have a question in it. But the question does show up in all
of these other instances. Now if you look at my joke that doesn't have a question, it
doesn't stand out very much. Maybe you might decide that you want your answer only jokes,
your punchline only jokes to look a little bit different maybe to be grayed out or to
be a totally different color or underlined.

I don't know something, also video for a second
and think how you might do that using inline styling and JavaScript the way that we did
in line six. Maybe what I might do is on my answers, h3 is add an inline style with an
object it says the color should be and then do something similar to what I have on the
question art on the h3 above where I say if there is no props dot action, then I might
want the color to be I don't know some kind of gray This is pretty contrived. But you get the
idea, we can start using the different props that come into our component to display things
differently. And as such, our joke component is now more or less reusable, we can add jokes
that just have punch lines and jokes that have both questions in punch lines. And automatically
the joke component knows how to style itself based on the incoming props. And that's pretty
much it for this practice, feel free to pause this and play with this as much as you want
before moving on.

Alright, so we're going to pick up where we
left off in the previous practice with our app component rendering a bunch of joke components.
Some of these have the punch line in them, and some of them have a question and punch
line. But you can see right now that they're hard coded into our components written directly
as text. In reality, most of the data that you'll be displaying on a page will actually
be coming from some kind of HTTP call to an API, where there's a server that hosts the
database, and that database and server are returning JSON data to you.

We haven't quite
gotten to the place where we can make API calls quite yet. So what I've done is I've
made this file jokes, data j s, and it's just an array variable that I'm exporting. And
that way in a component, if we want it, we can pull that in and pretend like that's us
getting data from an API. So how am I going to take an array of raw data and turn that
into a number of components? Well, there's a common saying for those that are learning
react, where they say that react helps them become better JavaScript developers. And the
reason is, because things like this are oftentimes handled by methods and kind of magic under
the hood for other frameworks like Angular or view. But in react, a lot of these simple
operations are handled just with vanilla JavaScript.

Let me show you what I mean. With a quick
aside, we're going to talk about some higher order array methods. If you're not familiar
with these, these are methods that you can run on an array that take a function as a
parameter and allow you the developer to decide exactly what should happen to the elements
in that array. For example, if I had the following array, I can run a higher order method on
nums. All map, and map is a method of the nums array, and
it takes a function as its parameter, this function will receive each individual number
in the array.

So I might say num or number, Tim, this function will then run on every
single item in the array. And with map, whatever I return from my inner function here, will
be placed in the same index of a brand new array with some kind of modification, meaning
map actually returns a brand new array, so I'm going to save a new array called maybe
doubled. Now, if I from my inner function, return, num times two, doubled should be an
array of 2468 1012, and so on, let's take a look.

And there's my array of all the double
numbers. If you're not familiar with higher order methods, they're one of the key components
of functional programming in JavaScript, and they're really, really awesome, I'd highly
recommend go study up a little bit on map, and filter and reduce, and some of the other
ones that are really useful. With this, we're gonna stick with map and we're gonna see what
we can use it for. So the first thing I'm going to do is pull in my jokes data importing.
And then we're going to follow the same pattern that we did in our example here, I'm going
to say, oops, data dot map, provide a function.

Now before I typed the longhand function,
so that it was a little clear what I was doing, but we're going to use an arrow function,
which can just as legitimately be used here, function is going to receive each individual
joke object, so I'll call it joke. And with arrow functions, if I just have one parameter,
I can get rid of my parentheses. And what I'm going to return from this inner function
isn't some modification on the joke objects per se, but rather, I'm going to return a
component joke component and pass in the data from the individual joke object that I'm looking
at. Because I'm only returning a single component, I can actually just do this on one line if
I want.

And if you're familiar with arrow functions, there's an implicit return so I
could actually get rid of some of that extra stuff. If this is confusing at all, then feel
free to put the return in there. It looks like I have an extra space there. And remember,
map returns A new array. So I'm gonna save that in variable. And now I have an array
of components. So what am I going to do with an array of components? Well, React makes
it really nice, where I can just put an array of components directly here in my JSX.

And
if I refresh this, you'll notice a couple things. First of all, my jokes on the right
are working again, just like they should be. And second of all, you might have noticed
this little error that popped up that says each child in an array or iterator should
have a key Prop, we won't go too much into the details of why react expects a key prop
on repeated components. But it's enough to know that whenever you're doing a map like
this, you should give the component that you're creating over and over a new prop called key.
Now, whether you're putting this on a component that you've created, or some kind of div that
you're surrounding it with, doesn't really matter. Just give it a key prop and put something
unique inside the key prop.

Usually data from an API will include some kind of ID number
or something else that's unique about it. As long as it's unique, it should be fine.
Here, I could use the question because the questions are all unique. But I've also included
for the sake of mimicking real data, some ID numbers that I might decide to use instead
for my key.

So over in app j, s, key is going to be choke.id. Now when I refresh, my warning
goes away, my app js is much cleaner than it used to be, my data is coming from somewhere
external, like it would in the real world. One of the main takeaways, though, is that
we're just using the built in JavaScript map method on arrays. In fact, I'm going to include
some links to the MDN docs on these methods that will be really helpful for you to understand,
if you don't already feel comfortable with them, you can see on the far right in the last part
of the URL exactly which method it is that this URL is going to be talking about in this
course, will mostly be using map, but we may throw in one of these other ones every now
and then you don't necessarily have to go memorize these perfectly right now.

But this
is just some more material that you'll definitely be interested in learning about. Something
else that I just thought of that may be really helpful to you is to realize that things that
we're teaching here, because so much of react is just vanilla JavaScript, you can use these
things as tools to do a lot of what your imagination could come up with. For example, as I'm iterating
over a joke component and creating a number of jokes, I may find a reason to also put
a map inside of my joke component. And I end up with a loop inside of a loop, where each
joke component renders an array of its own components.

That's totally possible. And it's
as simple as putting another map inside of your joke component. One joke component gets
rendered, it renders a number of other components. The second joke component gets rendered, it
also renders a number of other components and so forth. Some of these other methods,
like sort, for example, may be used to put things in an order that you prefer, or something
like filter could only display certain elements of an array rather than the entire array.
If you want an extra challenge, try making it so that our array of joke components gets
filtered to only display those that have fewer than X number of characters in the question,
or maybe filtered to only include items that do have a question rather than those that
are just an answer.

This is pretty much everything we have to learn about map right now. So when
you feel pretty comfortable with this, go to the next lesson to practice it. Okay, so I know I told you, I wasn't going
to make you create the entire react app from scratch. But I didn't make it a whole lot
easier for you. I did put the basics in so it's rendering an app component. And the app
component is just rendering an empty div right now. And here we have the instructions for
this exercise. So given a list of products as an array, which will be the products data
that I'm importing from the file called visco products, you need to create first and then
render a product component. For each product in the list, you're going to have a chance
to practice creating your own functional component, passing props to it, and rendering the correct
things to display inside of that component as its receiving props.

And you'll also need
to practice using the map method on the products data. This array of data is just an array
of silly objects that I created for a presentation that I gave last week here in Salt Lake City.
And each object has an ID, a name, a price and a description. You won't necessarily need
to display the ID as text on the page, but try to think of what this ID might be helpful
for. So I will go back to the app and I'll give you a chance to give this a shot. Good
luck. Okay, let's start with just a really basic product component. So I'm going to create
a new file and call it product dot j s Which I'll need to import react from react and export
product. It my functional component already know this is going to need to receive
products.

So I'll put props there. And let's just return some really basic JSX. For now
we'll wrap everything in a div. I have, let's say an h2. For the props dot product dot name. Now this is a
nested object because I anticipate passing the entire product down as one object rather
than passing down each individual property of the product individually as a prop. Instead,
I'll just pass the whole product down as one object and access the properties through props
dot product, dot and then the name of the property.

Down below it, I will put a paragraph
put $1 sign in front of props dot product, price. And then one thing I'm actually going
to put here is a string method called to locale string, which allows me to display this as
currency. And I believe if I do that, it will automatically put the dollar sign there for
me. So I'm actually going to take my dollar sign out. And then after that gets evaluated,
I might do like a dash and put the description. This is pretty boring. But I'd spend some
time if I were you styling this and getting some more practice with styling. So over in
app j s, I know that I'm going to be rendering a number of product components. So I need
to first import my product component file. And at the top of my functional component
here, I'm going to create a new variable called products. That's a product components. That's
going to be coming from products data dot map. So products data dot map, again, we'll
create a new array, and we're going to make sure that array is filled with product components.
So this will receive an individual product or item.

Maybe I'll say item just to distinguish
it from all the other things I have named product. I want this to return a product component where the product is my item. And now that I have this
array of product components, I'm going to put it inside of my div here and try refreshing.
Cool. One thing you notice is I got that warning about the key prop over here, I will also
add a key property. And I'm going to pass in the items Id just to allow it to have something
unique so that react can correctly place everything the way that it wants to. And I need to fix
my spelling here. Let's try refreshing again, everything is showing up correctly on the
right, and I no longer have that warning popping up, which is great. I'm a bit of a stickler
for correct indentation, so I'm going to fix by indentation here. And this essentially
is the completion of this exercise. Take some time to try and style this, see if you can
display things a little bit differently. Play with adding products to the visco products
array and see how that affects our website.

One thing I didn't show is that I can scroll
down here and see all of the other products that are listed in that array. Maybe try building
a button that when it's clicked in each product tops up an alert with the information about
that individual product to spend some time with this. And once you're ready, we're going
to talk about conditional rendering. Let's use what we just learned about mapping
and props to make our to do list a little more dynamic. What I've done is I've created
a to dues data js file here and all it is doing is exporting an array of objects each
object representing a to do item.

Now normally, you wouldn't do it this way, you would get
this data from an API of some sort where the data is living in a database. But since we
haven't really gotten there, this will do for now. Then over in app j s, I've imported
that data as an array called to dues data. So your task is to essentially turn this array
of objects into an array of to do items. Now remember right now to do items are hard coded
with what they're displaying. So that will also need to change. Go ahead and pause the
lesson and give this a try. So the first thing I'm going to do is take
my array and turn it into an array of to do items, then we'll have to fix to do items
so that it can receive props before my return.

We're going to create up An array called to
do items, which is the result of doing to dues data dot map, which will pass a function
to that receives an item. Essentially, we're just going to create a to do item. And we're
going to pass the information from the individual item object down to to do item currently to
do item doesn't accept anything, but we'll fix that in a minute.

So I'm going to pass
a prop called item. And its value is going to be the object. And
now that I have an array of to do item components, let's take these out and replace it with my array of to do items.
Okay, and you'll notice that I forgot to put a key prop in here, always an important thing to do. And
with the two dues data, what I've done is added an ID property, these IDs we can assume
will always be unique. And so over in app j s, I will just add a key. Let's say it's
item that I be rid of that warning. Now notice that I still have placeholder text here. But
now I have it five times. And that's because I have five items in my to dues data. But
to do items still has placeholder text here hard coded in it.

Well, we're passing an item
prop down. So let's go over to to do item, have it accept props. Instead of putting placeholder
text here, we will simply say props dot item dot txt, dot txt, because that's what the
property is called in my object. So I save this. And there we go. We have our to do item
showing up. And essentially, we're declaratively turning an array of raw data into elements
on our application. Now, it's actually going to be quite a while in this course, until
we learn about forms and learn a little bit more about how this input type checkbox works.
But what I can do is give you a little hint as to how to make it so that the checkbox
is checked, when the item is considered completed.

Over in the data, you may have noticed that
I've set a couple of these to complete and true. Let's make it so the checkbox actually
gets checked. When that happens. Again, we're going to cover this quite a ways down the
road. But just so you know, for now, every type checkbox gets a property called checked.
And essentially, it tells the checkbox whether or not it should be checked, if the thing
inside is true.

And it will be checked. And if not, it won't be checked. This is going to throw a little warning that
basically says you've added a checked property, but you can't change it ever. So it doesn't
have an on change handler. But for now, that's okay. We'll cover this again in the future.
But you can see in my window over here, take out the trash and mow the lawn are already
considered completed. And you'll see when I tried to uncheck it, it won't let me like
I said, we'll fix that in the future.

But this is kind of a cool little addition we
can make now, hopefully that wasn't too difficult. If it was feel free once again, go back, rewatch
everything, catch up on any of the lessons that you may have struggled a little bit through
up until now. And once you ready, let's go forward. If any of you have done a react tutorial
before this one, you might be curious why we're using functional components instead
of a class based component. When I'm teaching react, I prefer to start with functional components
simply because functions are really easy to understand. And it's obvious what we're doing,
we are simply creating a component with a function that returns the UI that we want
to show up on the page. But as we go deeper and deeper into react and start learning about
some new parts of react, we're going to find that a functional component can't do everything
that we need it to do.

And so at this point, what we're going to do is actually learn to
create a class based component. For now our class based component is going to do exactly
what our functional component does. And then in upcoming lessons, we're going to talk about
what class based components can do for us, such as allowing us to implement state and
lifecycle methods. But for now, let's just look at converting a functional component
into a class based component. If you're not really familiar yet with the class syntax
in e6, then I'd recommend going over to the scrim by six course and learning a little
bit about classes. So instead of converting this functional component to a class component,
I'm actually just going to create a new app class below it. And that way, we can kind
of compare the two. The class base component will always start with the class keyword.
And we're going to give it the same name of the component as we had before app tip instead
of parentheses and curly braces, we're going to extend react component and if you're not
familiar With classes or what this is doing under the hood, essentially, this is still
using a prototype system in JavaScript.

And it's setting up a prototype with react component,
all that really means is that we're getting a bunch of goodies from react component that
are pre written for us. And we're gonna get a chance to see that in upcoming lessons.
For now, I'm just going to open this with a set of curly braces. And every class based
component at least needs one method, and that is the render method, and it actually needs
to be spelled exactly this way. And then render will return exactly what we have in our functional
component. In this class component is identical to the functional component we had above.
So I should be able to comment this functional component out and save to watch the browser
refresh. And we have exactly what we had before. Now let's take a look at our render method.
Anytime we have any kind of display logic, that's going to happen, I prefer to do it
inside of my render method before the return. For example, you might remember a few videos
back where we created a date object. And then we use that data to determine what time of
the day it was.

And we displayed in the text and used some styling, and all sorts of stuff
like that. If you have any code that determines the display logic, or in other words, what
exactly is going to show up on the page or what the style of that element will be things
like that can go right here inside of the render method before you do the return. So
this is a good place to set up your style objects. If you're doing any inline styling,
running the logic that will determine how something will get displayed on the screen,
things like conditional rendering, all of that can happen here inside of the render
method. Now, if you're familiar with classes, you technically could also take that and put
it inside of a method of your own a class method.

To do that, above render, you would
just enter your own method right here. inside of this method, you can do any kind of display
logic that you wish. And then from inside the render method, you can call your method
by using this dot and then the name of your method. If your method returns something,
this is where you put that a few lessons in the future.

We're going to talk about some
caveats with this. But for now, it's just as easy to put your display logic here inside
of the render method. There's one other thing that we have to touch
on before we're done with this. And that has to do with props. In our functional component,
we could pass props to the function itself, then inside of our code, we would just say
props dot, whatever the property was on the props object, there's only one small change
we have to make with the class base component.

And that's that anytime we use props, we need
to make sure that we are using this dot props. It's a pretty common thing to forget to do,
especially when you're converting from a functional component to a class based component. But
it's also a bug that you'll get really good at catching and being able to fix right away.
And before this becomes confusing, I realized I forgot my curly braces up here. And to be
consistent, we will add a dot whatever here. As I mentioned at the beginning, class base
components enable us to do a lot of really cool new things with react, we're going to
be covering those over the next few lessons. But for now, let's get a chance to practice
this.

So take a second to play with this code. And once you're ready, let's move on to the
practice in the next lesson. You can see that I've set this up where I
just put all three of these components in the same file. And as I mentioned before,
you obviously would want to put these in separate files normally. But for the sake of practice,
we're just going to keep them here so you can see everything at once.

And as you can
see in the challenge, all you have to do is convert all three of these functional components
to be class based components. And also there's a small bug inside of this program. So see
if you can find it. So now's the time, pause the video and give this a shot. Okay, hopefully this wasn't too difficult.
All we're going to do is every time it says function, and then the component name, we're
going to change that to class. We need to extend react component, get rid of our curly
braces. And then instead of having a bare return here, we need that to be inside of
a method called render. And take this return type here, fix my spacing. And that's it for
the first one. The second one is essentially the same thing except now we have props and
we have to remember exactly what we're going to do when we have props. So Then function
will become class will extend react component and get rid of the parentheses, put my return
inside of a method called render.

And then the one thing that's always really easy to
miss here is that instead of props, it needs to be this dot props. Because this is a class
based component. This third component looks a little bit more complex. But essentially,
it's the same thing. Class greeting. And, and now, like I showed you in the previous
lesson, we could decide just to put component here, which then means at the top, we would
need to import react and component, then all of this logic is also going to go inside of the render method. Looks like this component is not using props
anywhere, so I don't need to worry about changing that to this dot props. And you can see I
still am getting exactly what I had at the beginning.

Now hopefully, you'll also notice
that there's a bug here, it says welcome, comma, and then a space with nothing in it.
If you didn't do this in the beginning, take a second now to try and figure out why that
is. Well, let's look at the component that's in charge of actually displaying this. And
that's our header. Here, we notice that it's saying welcome, this stop props, that username.
But when I am creating an instance of header, I'm not passing it any props. So it's coming
in as undefined. So it's coming in with nothing. And I need to actually pass something there.
So the prop I'm going to add is username was then we can put whatever we want here. There we go.

That's fixed. Hopefully, this wasn't too difficult of a
challenge. If it was then go back through it and try to convert these classes back into
functions. And then from functions back into classes. I know that sounds pretty tedious.
But honestly, it's one of the better ways to learn. Once you're ready, let's move on.
Okay, so we finally come to one of the most important parts of react and that is understanding
state. State is simply the data that a component maintains. And when I say maintains I mean,
it actually can change its value. The reason that's a distinct feature over anything we've
learned so far is because props, the other way to pass data from a component to another
component cannot be changed by the component receiving the props. They say in the React
documentation that props are immutable or unchangeable. All that means is that I can't
receive a prop and then say this dot props dot something equals some new value.

Okay,
I can't change props. And if I do, it may cause some weirdness with react. So state
is different in that it's a way that a component can maintain its own data and change its own
data if it needs to. Let me get rid of this before it becomes confusing, because you should
not do this. So anytime we're going to introduce state to a component. The first thing is that
the component needs to be a class based component. We'll talk a little bit in the future why.
But for now, just know that if you want state in a component, or if you want a component
to maintain its own data using state, it will need to be a class based component.

The first
thing we'll do to introduce state to this component is we need to add a constructor
method. constructor is a specific method that's built into JavaScript that initializes parts
of this class, if you're feeling a little unfamiliar with classes, I went and grabbed
the link to a screencast that has some information on classes that you're welcome to pause and
go look at really quick. But the important thing to know is that when you have a constructor,
it's a place where you're going to be initializing some values. And the first thing you should
always do inside of a constructor is make a call to a global function called Super.
In short, what super does is it goes to the parent class or what's also called the superclass,
and it grabs some of the goodies there and brings them down so that our class or our
app component can use those goodies.

One of the main parts of react component that we'll
be using is a method called set state. And that allows us to change state but we're going
to get there. For now just know that if you have a constructor, you should always add
super. And then the only other thing we need to do to add state to this component is to
add a property to this called state.

And state will always be an object. And so I'm going
to set the start state equal to an object. And now I have state in my component. I can
access this state anywhere else my components code by referencing this dot state Now you'll
notice that I have an h1 here that says is state important to know. So I'm going to add
a property to my state as an initial value, the property will be called answer. And its
value will be yes. Now take a second to think how you might get that value to show up inside
the h1 after this question mark right here. Pause the video and see if you can get that
to work. The first thing I'll need to do is add some curly braces, because I'm going to
be interpreting some JavaScript inside of JSX.

And then I simply type this dot state
answer. When I refresh the page, you'll see that it
shows up on my browser window over to the right, yes, here, what I'm doing is I'm giving
an initial value to my state. This is the data my component will have when it's first
initialized. And the special thing about state is that I can always change this to something
else later if I want. The only other thing I want to touch on in this lesson before we
move on is to mention that we can pass state from this component down to a child component.
And remember, the only way we can pass information from one component to another is through props.
And so that might look something like this, where I have some kind of child component
right here. And of course, if I want to pass any information down to it, it needs to happen
through props. So maybe I have a prop that I add called answer.

And its value is this
dot State DOT answer. The only other thing I want to mention in this lesson for now is
that react will do some really cool stuff if we ever change state. And I don't mean
changing it here manually in the initial value. But I mean, when we use the set state method
that I mentioned, which we'll talk about in a couple of lessons, but if we ever use that
method and change the state, React will automatically update every child component that is receiving
parts of that state.

And so changing the state will automatically change how things get displayed
on the screen. But we'll cover that a little more in depth when we start talking about
changing state. Now take a look at this code and try playing with state a little bit. And
we'll move on to a quick practice. Okay, so here's your challenge. And this is
actually a challenge that incorporates a little bit of debugging, not just talking about state
specifically. So you're given an incomplete class based component that doesn't have a
constructor.

And your job is to essentially initialize state and make sure that the component
gets fixed. Pay attention to the console, which I've opened in the bottom. So make sure
you look at that. And that should give you some good hints as to what's wrong. And for
the values of state, you should be able to figure those out based on the context of this
component. So go ahead, give this a shot. And we will do this together in just a few
seconds. Okay, so there's a lot to be done here. And
I'm going to start first by adding a method that this return can be inside. It looks kind
of like this was a functional component, and was changed haphazardly to a class based component
but in completely.

So the first thing I'm going to do is add a render method that this
return live inside. Okay, so when I refresh this, you'll see it says component is not
defined, well, that's a pretty helpful hint. We either need to extend react component,
or we need to import component from react. If we do it this way, then I can actually
keep it as component either way is totally legitimate. The next area we're going to run
into is a little bit tricky. So I'm going to save this. Notice it says cannot set property
props of undefined. Well, that's pretty confusing, because we're not actually using props anywhere
here. And where this comes from is this little set of parentheses that shouldn't be there.
That's how a function is defined, but not a class. So I'm going to get rid of those
and save it again. You'll see cannot read property name of No, well, here's name, and
it's seeing that this state is no. So as the instructions say I'm going to create a constructor
method. And the first thing we should always do in a constructor method is add super.

I'm
going to initialize my state is an object. And I can see from the render method that
that object should have a name property and an age property. So inside this object, I
will add a name property and we'll say le age of saving again, now have a functioning
component. There's no errors in the console and Sally and 13 years old are showing Have
correctly over in the browser.

Now one thing we've been talking a lot about at visco, which
is the coding boot camp that I work for, is how important repetition is. And I know I've
tried to get you to write this code over and over again. But I'd highly recommend that
if any part of this was confusing at all, that you go back to the beginning of the screencast.
And you pause the video immediately, and you try to fix it yourself again. And then after
you do that, do it again, go back to the beginning, try and fix it again from scratch, and do
it again, and do that as many times as it takes for the syntax to kind of be second
nature for you. Doing that is going to do a number of things. But mainly, it's going
to make it so that in the future, you don't get so hung up on figuring out and remembering
the syntax as much as figuring out how to solve specific problems.

So feel free to stop
here, go back, redo this as many times as is necessary. And then when you're ready,
feel free to move on. Okay, so I actually decided at the last second
that I wanted to add another practice in here. And this practice is going to do two things,
it's going to give you the chance to practice converting a functional stateless component
to a class based component. Again, it's also going to give you a chance to add state to
a component. And then I have kind of an additional challenge here, that covers something we haven't
quite talked about yet, which is conditional rendering. But I want you to just give it
a shot, use your intuition. And if you're wanting to do any kind of Google search, you're
welcome to do that, too. And we are going to cover this soon. But I figured this would
be a good chance for you to exercise your problem solving skills. So given the component
here, change it to a stateful class based component, give the state a property called
is logged in, which should be a Boolean, either true or false.

And that's the first part.
If you can do that, that's awesome. Then I want you to give it a shot at rendering the
word in if the state is logged in is true, or the word out if it's false. So go ahead
give this a try. Okay, so the first part, we should be able
to do relatively easily, we need to change our functional component to a class based
component. So I will add class here, going to get rid of my parentheses, add extends
react dot component, I return needs to be returning inside of a method of some sort.
So I'm going to add my render method, my return inside game, then if I'm going to add state
to it, I will need to make sure I have a constructor which calls super.

I add a property called
state on this, this that state equals an object. We know that object needs to have a property
called is plugged in. We will initialize it as true. You were able to get to this part,
that's awesome, great job. The next thing is making it so that it renders the word in
here if is logged in is true or out if it's not. And again, we're going to cover this
when we talk about conditional rendering in a few lessons. But one way that we may decide
to do this is to maintain a variable that looks at the current version of is logged
in, and has a string that represents the word that should be displayed here.

That display
logic, as I've mentioned, I like to do inside my render method but above my return. And
so I'm going to maybe initialize a variable called Word display. And do a simple if else
statement that says if this start state that is logged in, is true. We're display should
be the word in otherwise, or display should be out. Finally down here, instead of having
both in and out here, I'll put curly braces because I'm interpreting JavaScript inside
of my JSX. I will simply put word display, I noticed that word display is just a local
variable to the render method, I don't need to put this dot State DOT word display or
this dot props that were displayed because it is neither a prop nor a piece of state.
Now when I refresh this, I get you're currently logged in.

And that happens because is logged
in is true. And if I change this to false, tell me I'm logged out. We're gonna see more concise ways to actually do
this is a totally legitimate way. And in fact, I believe this is the way that the React docs
tell you to do this. One thing I like to do if my variable is clearly named to be a Boolean,
like is logged in, I'm just going to get rid of my triple equals true because that will
already either be true or false. And that's it. So once again, please go back, try to
redo this yourself. See if you can do it from scratch, even delete the entire file and see
if you can write everything from scratch once again. Repetition is really going to help
you get the syntax down muscle memory so that you can focus more on problem solving.

Once
you feel pretty good about this, let's go forward. We are at part four of our to do app. So this
should be a pretty short one. Until now all we've done this loaded our to dues data into
our app component by importing it and then mapping directly over the thing that we imported.
However, eventually, we're going to want to modify this data, which means that it's going
to have to live in state of this component. So all you need to do for this challenge is
to make it essentially so that two dues data lives in the state of this app component.
Pause the lesson here and give that a try. Okay, like I said, to dues data is just imported.
And we originally were mapping directly over the thing that we imported. But let's put
this on state. for that to work, I need this to be a class based component. That will extend
react component.

Parentheses, we need a constructor always calls super first. And we'll start
some state, which is an object and we'll have maybe just to use is an array, we'll start
as an empty array. And that in just a second, right now, this map and the return need to
happen inside of a render method, we'll just move that in there. And then like the challenge
says, We essentially want to load the imported two dues data into state, which essentially
just means that instead of an empty array here, we will put to dues data, then the last
thing is to change to dues data to this dot State DOT two dues, because that's where the
two dues data is living now. I believe if we refresh, we're working great. The warning
that we receive is from the previous lesson where we had the checked property, and we
don't have an on change. But we're going to get to that later when we talk about forms.
For now, this is heading in a good direction.

We will revisit this in a little bit. But
until then, let's learn some more react. Before we can seriously talk about changing
state using the set state method, we're going to need to have an understanding of events
in react and handling events. event handling is essentially allowing the user to interact
with your web page and do something specific when a certain event like a click or hover
happens. And handling events in react is actually quite simple. You might be familiar with regular
HTML is the ability to add something like on click equals and then you execute a function
like my function. React is very similar to this with just a few small changes. The first
thing is that all of our event handlers are going to be the JavaScript version, which
has a camel case convention on click will have a capital C, on mouse over will have
a capital M and a capital O and so forth. And the reason it does this is because it
uses the same convention that regular JavaScript as if you were to add these events to elements
on the page.

So let's make it so our button can do something when a click of the button
happens using onClick. And then the only other major change we're going to do is that instead
of passing an executed function as a string, we're going to pass a function directly into
a set of curly braces. I don't have another function pre written so I could just do an
anonymous function right here. And maybe console log something. We can shorten this up quite
a bit by using yes sixes arrow function syntax. Or as always, you could write a separate function
somewhere. And put the reference to the name of that function right here. Any of those
should work just fine. I'm going to save this and click the button. And you'll see that
we get a console log of I was clicked. If we open the console, we will see that more
obviously. As a quick reference, I want you to take a look at the following react documentation.
This is a full list of the supported events in react.

The reason I want you to look at
this is because I want you to pause this lesson and add the functionality so that when the
mouse hovers over the image, another thing gets console log. So pause lesson here, feel
free to go to that URL and see if you can find the event that we'll need to use so that
when we move our mouse over the image, it will execute a function And then go ahead
and add that to your image element. Okay, so I think there might be a couple different
mouse events that we could use. But the one that I'm going to use is the on mouse over.
And when that happens, we will run the following function. And we will just console log, Hubbard
save this. And I'll open the console and try hovering over Bill Murray. Like that. Every
time our mouse goes over the image, it runs our function to handling events is going to
be really helpful. Obviously, console logging stuff is not all that exciting. But we're
gonna see how events mixed with the changing of state will allow our application to start
becoming really robust and actually really awesome.

Feel free to add a few elements here,
see if you can do some of the other events that are found at this URL. And then we'll
talk about setting state in the next lesson. So we another really quick update to our to
do app, we just learned about how to add event handlers to elements. And you may remember
that we used to have a warning, saying that we have checked prop on our input. But we
don't have any way to change that. So it says it will render a read only field. So your
challenge is to get rid of this warning by simply adding an on change to our input. And
for now it can just console log something. So pause now and give that a try. I'm going
to close this console for some extra room. And this simply entails adding an on change
that is equal to and then I could write this function somewhere else.

Or I'll just do an
anonymous inline function that until logs. While I'm at it, I'll put these on their own
lines. And now when I click these, it doesn't change the checkbox. But our warning is gone. And my onchange is
firing correctly. So we're going to learn about how to make these events actually change
our state. And then we'll be revisiting this app again soon. Okay, man, every new lesson just feels so
exciting because you're learning something that's like really bringing you close to making
awesome web applications with react. In this lesson, we're talking about changing state,
okay, having state in your component is great. But if you can only initialize it to a specific
value and can't change it, then frankly, it's kind of pointless to be there.

And it's really
no better than just hard coding it into your code. So let's learn about changing state.
And what we have here is a component that is a class based component. Because we're
using state, we have our constructor, we're calling super, as always, we're initializing
state with a property called count, and setting that equal to zero. And then in our render,
we simply have an h1 that displays the current count. And we have a button with the word
change in it. I've added a little bit of CSS, so it wasn't quite so ugly. And now we're
going to learn about how when I click this button, using the event handlers that we just
learned about how can I change the state to be something different, so that clicking the
button will actually change the value that gets displayed here? Well, let's start by
adding an event handler, which should be reviewed from the last lesson. So go ahead and see
if you can make it so that when you click a button, maybe something gets logged to the
console.

For now. Remember, to add an event handler I'm going to do on click in this case,
because I want it to handle the click event equals and then inside of curly braces, I'm
going to put some kind of JavaScript function. Now I could put an inline function right here,
which I don't particularly like. So instead, what I'm going to do is I'm now going to create
my own method constructor is a method that's built in to classes in JavaScript.

Render
is a reserved method name for react. But in between here, I can put as many methods as
I want. One strong convention that people tend to use is to have a method called handle
click when you're handling a click event. So I'll finish the stubbed out version of
this and then down here, instead of an inline anonymous function, I'll have it run handle
click.

Now let's see if I can get a console log to show up. Let's save that. And this
is a common mistake. When the method is part of my class, I need to reference it on the
this object. So this dot handle click to begin, click my button and says I'm working. Okay,
that worked. Well, that's pretty boring. So let's make it so that when I click it, actually
changes my state and increases my count. Now one thing that would be really tempting to
do is to try and modify state directly, as in typing this dot State DOT count equals
one, or saying something like plus plus, or this is something that you will actually never
do, you're never going to want to directly modify the original version of state. You
might remember in the introduction to state, I talked about how state is kind of like the
clothing that you wear. Well, when it comes time to change your clothing, you don't modify
your clothing, right, you don't paint your clothing a different color, you don't cut
a T shirt, and so on buttons, so that you can have a button up shirt instead.

But what
you do is you completely replace your old clothes with your new clothes, or rather the
clothes you were wearing with the clothes that you want to wear. And this is essentially
the same thing we're going to do with state. You also might remember that I talked about
some kind of goodies that we're going to get from react component. And that's the reason
we're extending react component. Well, one of the things that we're going to get is a
method called set state.

And anytime you want to change state, you're going to use this
method set state. And it's a method or function, so I'm going to call it and there's actually
two different things that you can pass to set state. Let's first look at the easier
one to understand. What I can pass to set state is a new version of state, while state
is just an object as we see up here. So I can pass to set state an object, and I can
say, the count. Now, one might have already figured out what's
going to be the problem with this. But let's see if this works. So once again, my button
has an unclick, that will run this dot handle click when it's click, this dot handle click
uses the set state method that comes from react component. And it provides a new version
of state, okay, like your new t shirt that you're putting on. And it says now the count
should be one, I'll click the button. And we run into a very common error says, cannot
read property set state of undefined.

This brings us into a realm that's actually kind
of hotly debated with react. And I'm going to give you a very simple solution to this,
that may not make a whole lot of sense at first. Essentially, anytime you create a class
method that you want to use set state on, you're going to need to bind this method to
your own class. If you're not really familiar with binding, I'm not too worried about that
right now, just know that anytime you write a method that uses a set state, you'll want
to bind it and the way you bind it is inside of your constructor, we're going to say this
dot handle click equals this dot handle click dot bind this, like I said, this is probably
pretty confusing if you're not familiar with binding.

But essentially, what it does is
it makes sure that the handle click method is bound to the context of this as it exists
within this class. I'm going to refresh this and click my Change button again. And awesome.
Look, our state changed from zero to one. Now this is where the problem that you may
have figured out already comes into play. If I click Change, again, it looks like nothing's
happening. But in fact, it's actually doing what I told it to do, right? When I click
the Change button, it sets the state to the count. And the count is now one. Well, it
was already one and I'm changing it to one. So it's actually not changing. Therefore,
I can't see it changing on the display. So that brings us to the second way that I could
use set state, if I don't care about what the previous version of state was.

Passing
in an object is a really nice simple way to provide a new state. But a lot of times we
actually do care what the previous state used to be. In this case, we want to know what
the previous state was. And we want to add one to it. So anytime I need to know what
the previous state was, I can also pass a function to set state that function is going
to receive in its parameter, the previous version of state. This is really important.
And it might be tempting to think that you can just access the previous version of state
using this dot state, which sometimes will work but oftentimes will not. And so it's
really important to always pass previous state or whatever variable name, you want to give
this to your function.

Now because it's an arrow function that just has one parameter,
I can get rid of my parentheses around that parameter. And what my function should return
is a new version of state. Okay, so before we provided just a new version of state directly
as an object literal, but this time we're providing a function that returns that object
literal. The benefit of doing it this way is we have access to the previous version
of state. So in my function, I'm going to return an object, that object should have
a count property, so that I don't break my this dot state count down here. And I want
you to take a second and see if you can figure out what the value of that property should
be. So positive lesson and give that a try. So remember, previous state represents the
old version of state. And the old version of state is an object. So I can access the
previous version of state by saying proof state. But that's the whole object, I just
want to count property. And I'm not going to say plus plus, because that's directly
modifying the old version of state.

But instead, I'm going to just add one to it, we computer
will do is it will figure out what the count used to be, they will add one to that. And
it will set that as the new count property of my new state object that's getting returned
from this function. Now, when I save this, and refresh, and I click Change, I can click
it multiple times. And it will continue to increase the number that's displayed on the
screen. And this is really cool. I mean, it seems kind of lame, because all I'm doing
is increasing a number. But this opens up so many possibilities. And you're going to
see from here on just how much we're going to be able to do with react. Now that we have
the ability to have components, maintain their own data and state and actually change their
own data using set state. I mentioned before that you are allowed to pass state down to
other components as props, for example, having a child component of some kind that receives,
you know, your account, your state. And if we were to define this child component, we
would see that it's receiving a prop called count, the value of which is the current state
of its parent component app.

Well, what react will do is anytime this value changes, anytime
it sees that there's a child component that's receiving a value that changes, it will rerender.
This component, it will run that components render method, once again, or if this is a
functional component, it will just run that function again, so that that component can
reflect the new version of props that it's receiving.

And in this case, it will change
every time the state count changes on the app component, which as we just made it do
happens every time we click the Change button. So right now child component isn't actually
defined. So I'm going to get rid of that before I get a syntax here. And let's do a quick
recap of everything we did. We have our h1 displaying our state, which just has a count
property, we initialize that count property to zero, we added an event handler to our
button that runs a method called handle click handle click is a method defined on this class.
And because handle click is using the set state method that comes from the parent class
react component, we need to make sure to bind it, which we can do inside of our constructor.
And once it's bound, we can run set state, which can either take an object literal, which
is the new version of state that we want to pass to it.

Or if we care about what the previous
state used to be, we'll pass it a function that takes the previous state as a parameter.
And that function should return the object literal that represents the new version of
state. Now I just rattled off a lot of jargony stuff. So I want you to spend some time with
this state is going to be extremely important for you to understand. And we're going to
be using it pretty much through the rest of the course, though spend some serious time
with this, I'd highly recommend as I have in the past tried deleting this entirely writing
it from scratch. And we're probably a good stepping stone to that is rewinding this video
to the beginning and seeing if you can add all of this stuff again, you're also welcome
to try adding different events that may also change state in play with the state that's
getting changed, maybe you want it to increase by more than one or something like that, I
don't know. One really good exercise is to have a button that will double the number
and another button that will have the number.

So there's plenty of things that you can try
to do with this. So use your creativity and your imagination, see what you can come up
with. But spend some real time with this and play with it. Then in the next lesson, we're
going to get a chance to practice this. Okay, we've come to a pretty beefy part of
our to do app, we're going to make it so that when we click the checkbox, it actually makes
a change to our state. And this actually is a little more involved than it may sound but
it's really not too bad. up near the top. I've written down what your challenge is and
This will help you accomplish this task. And I've also stubbed out the handle change method
and written some pseudocode inside here. So you have some hints, essentially to help you
accomplish this. And just so there aren't any weird bugs, I've also bound this in the
constructor for you. So your challenge is going to be to take this stubbed out, handle
change and actually implement it so that when somebody clicks the checkbox, it makes a change
to your state and updates the item that they checked so that the completed property flips
from either true to false or false to true.

And then you're going to make sure to pass
the handle change method down to your to do item. And then over in your to do item, you'll
need to implement the on change with the new method that you've passed to it. So I go back
here to app. Pause now and go ahead and get started. Okay, so I might do this a little
bit out of order. But I think the very first thing I'm going to do in my handle change
is just to console log something. Say we changed. And since we're getting the ID, let me just
go ahead and add the ID to my console logs, so I can make sure that that's working. And
then I think what I'll do is hook up parts two, or complete parts two, and three, and
just see if I can get this console log to happen. And then we'll go ahead and add this
logic. And so part two says that I need to pass the method down to the to do item components.
So right here, I have my to do item, which gets a key and the item.

And let's go ahead
and pass down a handle change was passed down this dot handle change. And then over into
do item, it's now receiving a prop called handle change. So props that handle change.
And notice that it says it's going to be taking the ID as a parameter. However, we know that
events when they fire, they actually receive an event property. And so it won't be good
enough to just say props dot handle change, because because this is not going to receive
an ID property, it's going to receive the event object instead.

And so what I can do
is say, Well, this is the function that's receiving the event here. And what it does
is it calls props dot handle change. And now I can pass whatever properties I want to this,
I want to say props.item.id. Since I'm not actually using this event, in this case, I'm
just going to get rid of that, it'll just be an empty function that calls props dot
handle change and passes the ID to it. So let me update my page. And we'll open the
console and just see if my console is working. Okay, change to change three, one, notice
that it's matching up with the ID of the item that I'm clicking. So this is ID of one ID
of two ID of three. And if I click the clean Gecko tank number three, it says Edit change.
Number three, awesome. So we've made some good headway there by finishing parts two
and three. But let's get to actually updating our state.

This is the trickier part. The
part that's tricky about this is that we need to deal with the entire array, because we're
saving an array in our state. And we never want to modify state directly, it won't be
as easy as just looping through this array, finding the item with this ID, and then flipping
it because that will actually modify the existing state. But instead, we can essentially do
that same thing. And just make sure that we return a brand new array where almost all
of the items are exactly as they used to be except one item has changed its completed
property from true to false or false to true. And a great way to do that is to use the dot
map method, because this returns a brand new array. And so what I can do is I'm going to
start my set state.

Because I do care what I have in my previous state, we're going to
use the function way of updating state and receive my previous state. And then what I'll
do is I will use map to loop over my proof state.to dues array and look for a to do with
the ID that is given here in the method. And so I'll create a variable that says maybe
updated to dues. That's going to be my old version of to dues.

And sorry, this shouldn't
be this that state but rather create State DOT map. And we're going to look at each one
of the two dues in this array. We'll run this function and we're
going to say if print to do that we're looking at has an ID that's equal to the ID we received
from our parameter up here. Then we know this is the to do item that we want to flip the
completed property of So I can say the to do dot completed, should equal the opposite
of whatever it currently is. And whether or not we actually did that flipping of the completed
property, we're going to return that to do that makes it so that it puts this to do item
in our new array in the same index have the original array.

And all of this is my map.
And so what my set state needs to do is actually return a new version of state, which is just
an object. And our state is an object with a to dues property. So I'll say to dues now
be the updated version of to dues, the array that we just created. Let me clean this up
a little bit, get rid of these comments, this, and let's try flipping these awesome. And
it looks like everything is working the way it should.

So as a recap, we are looking at
our previous state, and we're creating a new array that almost perfectly mirrors what it
used to be except one of the items, which has the same ID as this function received
from the on change handler that is happening when we click these checkboxes. That one item
is changing from true to false or false to true. And then this brand new array is essentially
replacing the old array that we had up here, and it gets rendered to the page. Then we're
taking this handle change method, and we're passing it down to every one of the to do
items that we create in our map down here.

And those to do items are receiving the handle
change. And anytime it's checkbox gets checked, it calls on change. And that has an anonymous
function, which then calls handle change and passes this items ID so that we can correctly
identify which in the array we need to flip. And as a reminder, the reason the checkbox
is actually showing up or not showing up is because of this checked property checked determines
whether the checkbox should be checked or not. And it says if the item is completed,
then it should be checked. And if the item is not completed, and it shouldn't be checked.
And essentially what we have now is a working to do app, we're going to do some small tweaks
to it. But great job.

Hopefully everything that we've covered so far makes sense. And
we'll be revisiting this soon to talk a little bit more about styling, but feel free to celebrate
a little bit and whenever you're ready, we'll go forward. One of the really nice things that we've mentioned
about react is how we get to essentially just write vanilla JavaScript. And react is taking
care of a lot of stuff behind the scenes, will with the stuff that's going on behind
the scenes, every single component that we create, is actually going to go through a
series of phases or milestones during its time being alive in your react application.
Often this is analogous to a human being who is born has life milestones, and dies. Similarly,
every react component will undergo a series of events when it's being rendered and updated.
Now I've divided lifecycle methods into two parts, because the React team has just recently
deprecated or gotten rid of three of the original lifecycle methods that we're about to talk
about.

And instead of going through every single one of these individually, I'm actually
mostly going to just talk about the ones that are the most important to you right now as
you're learning react. And then as you continue to learn, you can play with some of these
other ones as well. For for reference, I'm going to post here a URL to a site that does
a really good job explaining the lifecycle methods that were a part of react before version
16.3.

Check out those changes that happened in 16.3, you can check out this website, which
is the official blog of the React team. With that being said, let's start talking about
the lifecycle methods that were most likely or most commonly going to use. The first is
one that you're actually already familiar with. And it's a little bit of a gray area,
because this is oftentimes not listed as a lifecycle method. But the render method, right
here is something that we've been using, as we've talked about class based components.
And one analogy that I like to use is that it's like getting dressed for the day. Its
job is to determine exactly what gets rendered to the screen, which in turn is how the component
is displayed to the world. Now the render method can be called many times, anytime react
determines that something changes like state or props, which might affect how the component
is supposed to display, React may run the render method once again. Similarly, you may
have had days where you've decided to change your clothes and look a little bit different
to the world based upon what you're about to do.

So hopefully by now that one's pretty
straightforward. The next lifecycle method that I want to talk about is called component
did mount and these lifecycle methods are defined just like other methods inside of
your class. Here. So I might say component did Mount camelcase, like this component did
mount is a lifecycle method that's essentially like saying you were just born the component,
this component did just mount to the screen, the very first time the component shows up,
React will run the component did mount method.

This method will only run once while the component
is showing up on the screen. Things like a rerender, which changes the way that the component
is displayed does not rerun component did mount. And that's because the component doesn't
actually unmount and remount. Most common use case for component did mount is to do
things like an API call when you need to get data from some kind of external source. For
example, maybe this component is actually a to do list. And I need to get the list of
to dues from some kind of server or database. Before I'm able to accurately display my to
do list. As soon as the component finishes mounting, I can get the data I need to correctly
display. We're going to see this in a future lesson. But just know that that's one of the
most common use cases for component did mount.

The next lifecycle method I want to talk about
right now is called component will receive props component will receive props is kind of like
when someone gives you a gift. This component could be receiving props from a parent component.
And every time this component is receiving props, it will run this component will receive
props method, and component will receive props will not only run the very first time the
component is mounted. But it will also run every single time a parent component decides
to hand props to a child component. For example, if a parent component decides to change the
props that it's passing down to this component, one thing we can do inside of component will
receive props is check to see if the new incoming props are even different at all from the existing
props.

Oftentimes, we will then say if they are not different, just don't do anything.
But if they are different, maybe I have some kind of calculation to run or state to set
or something like that. To receive those new incoming props component will receive props
receives a parameter called next props. And it's just a parameter so you can call it whatever
you want. But oftentimes, we put next props. And sometimes you'll see something like an
if statement that says if next props dot whatever property you're looking at, does not equal
the existing props. Then do something important here. So there's some
good use cases for component will receive props. However, as I mentioned, this is actually
one of the lifecycle methods that's going to be deprecated, or actually is deprecated.
Starting in 16.3. Until react 17 comes out they've renamed this with all caps unsafe
underscore component will receive props.

So if you really need to use this, you can still
do so. But once react 17 comes out this is going to be completely removed in component
will receive props will no longer mean anything special. So just be aware of that. It's a
good lifecycle method to understand. If you're looking at legacy code. For going forward,
this won't be a part of react anymore. Another cool lifecycle method is called should component update. And in our person analogy, I like to think
of this as making a decision as to whether you need to change your clothes or not. Behind
the Scenes if react has any kind of question at all as to whether a component needs to
rerender it will always choose to rerender it just in case without any logic specific
to your applications needs behind that decision. I think I said in the past that sometimes
react will rerender a component even if nothing about that component has changed.

Well, that
can become kind of an expensive or rather slow operation. If you let that happen to
every single component in a large application. Should component update gives us the developer
a chance to optimize our app, we can implement some logic here that allows the component
to determine whether or not it's important for it to even think about updating. To help
make that decision. This is going to receive the incoming props and the incoming state,
which we'll call next props in next state. And in the body of the function we need to
either return true if we do want it to update or we can return false if we don't want it
to returning false Should component update is what will make your application more performant.
But you'll just want to make sure that you actually don't want this component to update.
Otherwise, it could really introduce some weird and hard to debug bugs into your code.
Less lifecycle method we'll talk about right now is component will unmount.

Just like in
life, all good things come to an end and your component will eventually unmount from the
screen or disappear altogether from the screen. The main use case for component will unmount
is to do some kind of cleanup or tear down of anything that you've set up, it could potentially
lead to clutter in the DOM or in your application. One of the most common use cases for this
is if you in component did mount set up like an event listener, for example, you wanted
to run some code every time somebody scrolled on the screen, this would be a chance to remove
the event listener, that that's just one example. In general, it's a place to tear down or clean
up your code before your component disappears. I'm going to move to this after that, so that
it's obvious. It's just an example. And that's actually all the lifecycle methods, we're
going to cover in part one here, there are a number of other ones that are important
to understand.

But for now, they're more advanced than what we're planning on getting into in
this course. And so I'd recommend if you're interested in learning more about them, going
up to this link up here. Now this link was written before 16.3 was announced. So also
take a look at the second link here, which will talk about the three lifecycle methods
that have been deprecated. As well as the two new lifecycle methods that are introduced
in their place, which we're going to cover in the next lesson.

You had a chance to go over this link here,
which is the announcement of react 16.3. And the changes that came with it, you will have
read about the three lifecycle methods that have been deprecated. One we talked about
already, this component will receive props, that's going away. A couple more lifecycle
methods that are also being removed our component will mount I'm just going to comment that
out right away, as well as component will update shall also comment out those three
component will mount component will receive props and component will update are being
deprecated or removed from react. In its place, we're receiving two new lifecycle methods
that we can use. One is called get derived state from props. Now there's one change about
get derived state from props. And that's that it's a static method. So we have to include
the word static beforehand, get derive state from props receives props in state and should
return the new updated state based upon the props. And I don't plan to go too much more
into this.

And the reason is because the React team has actually written a blog about how
you probably don't need derived state. A lot of times this has been misused and caused
weird bugs or performance issues in people's applications, when in reality, there's actually
a better way to go about what they were trying to do. The idea behind get derive state from
props is for like it says in the blog, the rare cases when your component needs to take
incoming props it's receiving from its parent, and set its own state based upon those props.
But again, the React team kind of discourages the use of this method. And so I'm not going
to talk too much about it. And we probably won't be using it in this course. However,
if you're interested in learning more about it, here's a link to the docs on get derive
state from props.

And the last lifecycle method, the new one that's being introduced is called
get snapshot before update. You can think of get snapshot before update as a lifecycle
method that allows you to sort of create a backup of the current way things are. When
I say backup really all you'll be saving is some kind of data of some sort, probably an
object with multiple points of data inside of it. And that object would be called the
snapshot because it's like a snapshot of the way your application is right now. Again,
the React team says that it's not a super common lifecycle method that you'll end up
using. And so we're not going to talk too much more about it. But once again, here's
the documentation if you're interested in learning more about it. So that's essentially
it for lifecycle methods for now, as you get more and more advanced in the applications
that you're building with react, you'll definitely want to become pretty familiar with these
lifecycle methods. For this course, we'll pretty much plan on sticking to component
did mount and render.

And if we end up meeting another one, then I'll make sure to talk more
about it at that time. Feel free to read through some of these articles. And when you're ready,
let's move on. You know, one of the hardest things about
teaching react is that you learn a number of tools that can be used in a variety of
ways. But you aren't necessarily constrained to just one way of using a tool. The other
thing is react uses so much vanilla JavaScript that a lot of what you can do with react is
done a number of different ways, using just vanilla JavaScript. Conditional rendering
is where this kind of comes into full view.

So I just wanted to start with that caveat,
before we get into this, because I don't want anyone to think that the way I'm about to
show you conditional rendering is the only way it can be done, I'm going to cover a number
of use cases, but there's for sure going to be other ways to use it that are totally legitimate.
So I've done here is I've added a class based component, it has state with a property called
is loading that is either true or false. This is something that's oftentimes used when you're
making a call to an API. And in the meantime, you want something to show up, perhaps that
call to the API will take three or four seconds.

And you don't want the user to think that
your website has crashed. And so you'll maintain something in state that says, hold on just
a second we're loading right now. And conditional rendering will be used to actually display
something on the screen that tells the user that you're currently loading something in
the background. We'll talk about component did mount in a second. But now in the render,
you'll see that we are rendering a component called conditional, which I'm importing up
above, and I'm passing a prop to it called is loading, which is the current version of
state. And then over and conditional, we're going to be adding what gets displayed on
the screen here for now. But before we get there, I want to be clear of what's happening
with our component did mount. Remember that component did mount is a chance for us to
run some code right after the component, our app component in this case mounts on the screen
for the very first time.

And what I'm doing here is kind of faking an API call, I've set
a timeout, which will wait one and a half seconds before running the code that's in
the function I provide it. And what's happening in that function is I'm changing the state.
So that loading is false. Think of this as a fake way to pretend that we're making a
call to an API that takes 1500 milliseconds, or one and a half seconds to come back with
data. At which point we're saying we are no longer loading because we finished loading
the data from the API. And once we talk about using fetch to get data in a future lesson,
we're actually going to be doing this for real, but I just wanted to make sure this
wasn't confusing before we move on. And actually, this is a good time to talk about the lifecycle
methods once again, because once set state changes is loading to false, our component
or conditional component, is now receiving a different Prop, because it's receiving is
loading of true when it first loads. And then when state changes and is loading as false.
It's receiving a new Prop, or rather, it's receiving the same is loading prop with a
different value.

And so what will happen is when the state changes, our render method
will run again, because something has changed, which means the conditional component will
also rerender. Now conditional is just a functional component, which means the function will just
run again. And whatever we're returning from here could potentially change because props
are going to be changing. When we get to the end of this lesson, I'll highly encourage
you to play with it because this is a really important topic.

Okay, so my conditional component
is receiving a prop called is loading. And before we get anywhere else, let's see if
our set state is working. I'm going to fix the syntax error by actually having something
render here. And I'm going to console log props.is loading. Notice that and I'll refresh
this again, notice that immediately, what happens is it shows up as true. And then 1500
milliseconds, or one and a half seconds later, it re console logs false.

And that's because
over an app, after 1500 milliseconds, it changes state to false, and that's when conditional
re renders or runs again, and the props that it's receiving changes. So first, it logs
true and then it locks false. Well, let's talk about conditional rendering. Essentially,
all that means is that I'm going to load something on the screen if a condition is true. In this
case, instead of an h1 that says temp. What I might do is say if upstart is loading is
true, then what I want this component to return is an h1 that says loading.

But if props that
is loading is not true or in other words, I can put that inside of an else once you to return
and have different text. And notice what happened when I refreshed, I'll do it again. At first
it says loading. And then it changes to the different h1 that we have here that says some
cool stuff about conditional rendering. The app component starts with is loading is true,
and therefore renders a conditional component where is loading prop is true.

And then the
conditional component checks if props that is loading is true. And first, it loads this
h1 or renders this h1, then when props.is loading changes to false because the state
of the parent component changed to false, the conditional component that we have here
runs once again and it notices that prompts that is loading is no longer true. And therefore
what it returns is this h1 instead, this is just using plain JavaScript. And if statements.
One thing that I personally prefer, because I'm returning from my function in my if statement
is I don't actually need my else here.

This will simplify my code a little bit. And this
return will only run if my if statement does not evaluate to true. And therefore it's kind
of an implied else. Well, this is a perfect time to talk about a common way to do this
kind of if else rendering using something called a ternary. operator. If you're not
familiar with turn Aires, this is not even a new feature in iOS six, this is something
that's been around for a while. And it's very commonly used in react applications. When
it comes to conditional rendering. Essentially, the way it works is you provide a condition
and then a question mark, you provide a statement if it's true, followed by a colon, and then
a statement. If it's false, in our case, our condition is, is props.is loading equal to true.

And then I like to read it like an English
sentence with the question mark props that is loading is true. If so then I want this
h1 otherwise, is what my colon means I want this h1. Well, I'm going to have a syntax
error here. And that's because when we're doing this inside of a component, we have
to do this inside of our return. So I'm going to delete what we have here, I'll delete my
comment, I'll add a return. put this inside of my return. Now, technically, this works.
If I refresh, you'll see it shows loading, and then some cool stuff about conditional
rendering. But this looks really strange to me as because we're not immediately returning
a parent JSX element, which we usually want to do.

So I'm going to wrap this whole thing
in a div. And then when I refresh, you're gonna see that there's another error we have
to fix. Notice that it's literally interpreting as text, the stuff that I shoved inside the
div. So if I want this to be interpreted as JavaScript, I need to wrap it in curly braces.
And now when I refresh, we're back to working. What's nice about this is that when I inevitably
have other things on my page, like some kind of navbar, which I'll represent with another
h1 here, maybe a footer, I can still be rendering conditionally parts of my page.

Another simplification
that I can make here is because is loading is already a Boolean, I technically don't
need the triple equals true, I can get rid of that. And this will test the truthiness
of props, that is loading, I'll refresh and you'll see it works the same. There we go.
Now, I put in this navbar, and footer as demonstration purposes, but I want to remind you, there's
so many different ways that you can structure this, that it's really hard to teach all of
them. For example, usually you won't have your navbar and your footer inside of a child
component of your app, these would likely go in your app component or somewhere similar.
That's a parent of this little conditional component.

And another thing is I've put this
conditional rendering here inside of the conditional component, just so we could see it all in
one place. But the truth is, our app component is probably the one that should be in charge
of the conditional rendering. The reason is whatever we put in our conditional component
should probably just be able to display when it's told to display it. If our app is in
charge of determining if something is loading, then it's probably the one that should determine
what should be rendered down here in the render method. So the way that I would actually probably
structure this in this specific case, when we're talking about having a loading thing
pop up on the page is right here, I would put my conditional this.state.is loading,
question mark, and if so, display our loading word. But otherwise, display our component.
Which means this conditional component wouldn't even need a prop called is loading.

In this
particular case, and over in conditional j s, I would just display the stuff that I wanted
it to display. And we see that it's still working this way. Obviously, the navbar and
the footer are gone. But the point is, this function should only really know what to do
when it's supposed to display. And our app component being the one that's maintaining
whether something is loading or not, can determine in its render method, which should display
here. In part two of conditional rendering, we're going to see some other ways that this
can work. But before doing that, I'd really encourage you especially since this is the
first time we're using component did mount in a real way to play with this code, spend
some time playing with the different ways we've already talked about here with conditional
rendering.

And once you're ready, let's move on to part two. There's actually only one extra little part
with conditional rendering that I'd like to cover right now. And that has to do with using
the logical AND operator, you may be used to using the logical AND operator to refer
to something on the left and something on the right as billions in determining whether
the entire condition should be considered true or false. So for example, true and false
would be false. Because with the AND operator, both sides need to evaluate to something truthy
in order for the whole thing to be true. Well, in reality, under the hood, what JavaScript
is doing is with the AND operator, it's determining the truthiness of the thing on the left. And
if the thing on the left is truthy, it just immediately returns the thing on the right,
which means when it's true and false, it returns false, because that's the thing on the right.
If the thing on the left is falsie, then it just returns false right from the beginning.
And so the AND operator can be a way to conditionally render something if a condition is true, or
just render nothing if it's false.

So with this little example that I've created, I've
added some unread messages in state as an array of strings. And you can see here it
says you have to unread messages because the length of the race too. But a lot of times,
you wouldn't necessarily want it to say you have zero unread messages, you may just want
it to instead not have any h2 there at all. Okay, using the ternary that we learned in
the last lesson, I could say something like wrap this whole thing in curly braces, and
then say, essentially, if this dot state unread messages that length greater than zero, then
render this array, but otherwise render nothing. So I could just say no, let me clean this
up a little bit. It's a little easier to read. But I can simplify this a little bit by getting
rid of my ternary. And my No, and just saying, check the truthiness of this dot State DOT
unread messages dot length is greater than zero. And so in other words, if that's true,
and render this part, however, if it's false, it will just render nothing.

And we can see
on our screen, there's nothing there. Once I add some unread messages back shows up. So the AND operator isn't strictly necessary,
because you could most of the time, just use the ternary where one of the results is no,
but this can really kind of simplify it just a little bit. And you may be seeing this every
now and then in the code that you look at with other people's react code. So that's
pretty much it with conditional rendering. Let's go ahead and move on.

Okay, let's practice some conditional rendering.
So here your challenge is given a stateless functional component, just this app component
down here, I want you to follow whatever steps it takes to add some state to it. I want you
to then have that state keep track of whether the user is logged in or logged out. Then
you should have a button that will change That state. In other words, a button that
logs them out if they're logged in or logged them in if they're logged out. And there should
be some text on the page that says whether they're logged in or whether they're logged
out. If you want an extra challenge, make it so that the button will actually display,
log in if they're not logged in and log out if they are logged in.

So as usual, give us
your very best shot. And we'll give you a few hints if you need them in just a few seconds.
But in the meantime, pause the video and try it out. Okay, really quick, some additional hints
that you might need, because this is actually putting together quite a few of the lessons
that we've talked about recently. So one thing is in order to add state, you'll need this
to be a class based component. And part of that is you'll need to add a constructor method
to that class based component for keeping track of whether the user is logged in or
not, you could use a Boolean is like in the Boolean either true or false. Adding a button
that logs the user out will require an event listener, which would be your unclick. Probably,
and then both the extra challenge and challenge part number four would require some conditional
rendering. So if you're feeling a little bit stuck, feel free to pause it again and try
it out.

Now that you have some hints as to how to complete each step. And we'll go through
this together in just a few seconds. Okay, let's try this out. So we need to make
our component into a class based component because well, actually, for a couple of reasons.
One is we want to keep track of state, which means we are required to have a class based
component. But we're also going to be writing an event listener. And technically, I could
just write another function that handles that. But personally, I prefer to have a class based
component and put my event handlers inside of the class itself. Okay, so to change this
to a class based component, we need to change function to class, it rid of our parentheses,
will extends react component return needs to be inside of a render method. We'll move
it there. And to add state to it, we know we need a constructor method.

Always call
super First, add a property called this dot state which is an object we'll initialize
it with is logged in of true or actually the start false. Okay, so that is steps number
one and two. Now we need to add a button that will change is logged in to true or false.
And so there's a couple things we can do. One is inside this div, let's get rid of that
and we'll add a button. And for now, I'll just say log in. And we'll play with this
a little bit later with the extra challenge. Now I need to add an event listener to this
so that the button being clicked actually does something. So add an unclick equals a
call this dot handle click. So anytime This button is clicked, it will call this classes
method called handle click well that doesn't exist yet.

So let's create it. Right here,
I'll add a handle click. And I'm probably going to run into a binding error here. So
I might as well bind this now. Let's say this dot handle click equals this I have a quick
dot bind this. Before I get too far, sometimes I'd like to have little sanity checks along
the way. I'm just going to put a console log here. Now we can check if I click the button
if it will console lock I'm working. Refresh the page and I get this login button. And
when I click it, okay, our console log is working just fine. And that's awesome. Now
the thing I want handle click to do is change false to true or true to false depending on
which one it currently is. And anytime I'm going to change state, I need to run this
dot set state. And remember, there's two different ways that I can set state two different things
I can provide to the set state method. Take a second to think of what those two things
are and which one is going to be most useful in this case.

So I can either provide set
state, just a brand new version of state, and it will smartly combine and replace the
current version of state. But since in this case, I actually need to know whether it currently
is logged in. Rather, if logged in is false or true, I need to instead provide a function
that has the previous state asked to it so that I can use that previous state to determine
what the new state should be. My function is going to return the object literal Where
is logged in, the value of is logged in is the opposite of whatever it used to be. This is a really concise way to change a Boolean
from false to true or true to false. Technically, you could also do an if else statement that
says if proof state.is logged in is true, then return an object Where is logged in as
false. Else return an object Where is logged in is true. But this way, I just say Just
give me the opposite of whatever it used to be. Now, we don't currently have a really
great way to see what the current version of state.is logged in is.

But I can do this
extra challenge right now and make the button say login or logged out depending upon what
the current version of status. So I might do that right here in the render. And the
first thing that comes to mind is just to have some button text saved in a variable.
So I can initialize this variable, and then I can say it equals, I'll use a ternary to
determine whether it says log in or log out. So if this.state.is logged in is true, I want
the button text to be logged out. If they're logged out already, I want it to say, login.
Man, instead of hard coding a login here, I will put button text.

Hopefully this will
actually show us whether they're logged in or out on the button, it says login, I click
it, and then it says log out. So I know under the hood, my state is actually changing. Awesome.
Okay, Part Four to display text that says log logged in or logged out, depending on
the current version of state is actually pretty straightforward. It's about the same as what
we already have. And so I might say, let display text equal essentially what we have here is
instead of log out and log in, it would be logged out. Or sorry, log in because if they're
logged in, then I want it to display a login logged in. Otherwise, no, no, but I have this display text. I could
put maybe an h1 here uses the display text. So the button says log in because it's a command
to log in, and it says I'm currently logged out. Then when I click it, it says click this
button to log out because you are currently logged in. And that's it for this practice,
then as much time as you need to really understand exactly what's going on.

And when you're ready,
let's move on. Alright, we've reached the final part of our
to do app and we're just going to hammer out this last little styling piece. And we'll
be done. So your challenge is notice we're here in the to do item component, what you're
going to do is make it so that the items that are completed look a little bit different
than the items that are incomplete. I'd recommend maybe graying the text out doing a line through
it, maybe turning it to italics or something like that, I'm probably going to do all three.
But whatever kind of styling you want to add, go for it and pause the lesson. Now give that
a try. Okay, so I'm thinking this will be pretty
straightforward. inside of my function here, I'm going to create a inline style to be called
completed style. And let's change the font style to be I like essentially, the styles
represent anytime that one of the items is completed, they will get this style. We'll
make it metallic and then we'll make it maybe a light gray color.

And we can put a line
through it with text decoration. And then the thing that I want to style is
the paragraph here that has the text of the to do. So I'm going to add a style property. And
I need to do some conditional rendering here that determines whether or not I should apply
these styles. So I'm going to say if props dot item dot completed is true. I'll just
do this inside of a ternary then I want you to apply the completed style. And if it's
false, then I'll just say no, which essentially means Forget it. I'm not actually going to
do any styling here. So if I Save and refresh this. There we go. My completed items are
grayed out, they're italicized, they have a line through them. If I make it incomplete,
it essentially takes those styles out. Awesome, great job on the to do app, hopefully, you
actually took the time to try and do a lot of this yourself. If you haven't, I really
highly recommend going back and actually doing these. Again, you might remember one of my
strong philosophies is that you'll never actually learn to create these applications unless
you actually do it by hand, just watching somebody else do, it isn't really going to
cut it.

Now coming up soon, you'll get a chance to build an entire app from the beginning.
And catching up on things like this to do app and actually trying it yourself is going
to really make that task a lot easier. Once you're ready, let's go to the next lesson. In our past lesson about lifecycle methods,
we talked about a lifecycle method called component did mount, I want you to take a
second and see if you can remember what component did mount does. component did mount is like
a hook in our react component that allows us to run some kind of code immediately after
the component first mounts to the DOM. I mentioned when we were talking about lifecycle methods
that one of the most common uses for component did mount is to get data from somewhere so
that your component can do what it's supposed to do.

As a quick refresher, I can add a lifecycle
method right here as a class method has to be spelled correctly though it has to be component did mount and let's just take a look, if I do a quick
console log, see that it ran our console log and it ran the console log immediately after
the component finished mounting to the DOM. Well, like I said, right here is where we
would get any kind of data that's required for this component to display what it needs
to display or do what it needs to do. And so for this lesson, we're going to be using
a couple tools that are really helpful for doing that. The first one is a built in JavaScript
tool that's more or less new, called fetch. and fetch is a nice, easy promise based way
to perform HTTP requests, so that we can get any kind of data that we need.

I'll put up
near the top here, a link to the MDN docs on the global fetch function. Another tool
we're going to use is an API called the Star Wars API. Heavy school, we really like the
Star Wars API, because it is cores enabled, which means that there are no issues with
our front end application getting data from their database, you can find the homepage
for the Star Wars API right here. Pretty easy to use. And the data that comes back is pretty
fun to play with. So feel free to take a look at that website, too. And another resource
that I figured out, add here is a medium article that talks about promises just in case you
aren't feeling as familiar with promises as maybe you should. But the truth is, there's
a million articles out there about promises. So you may have to read through a few of them
and just practice them yourself until you feel comfortable with them.

Okay, so let's
get started with this inside of my component did mount I'm going to use fetch, which I
use by just typing fetch. And this is a global function. So this should just work. And here,
I'm going to put in the URL where I'm going to be getting the data from. So I'm going
to put in the Star Wars API endpoint here. And we're going to search for slash people.
And we'll just get the person with the ID of one, which happens to be Luke Skywalker.
And that's all we need to do to use fetch to get some data for us. And I'm going to
resolve the promise by using a dot then, which will receive a response that is not quite
yet in the format that we need it to be in. So I'm going to use a method called dot JSON,
which will turn this into a JavaScript object for us.

And next in my promise chain, I can
chain on another dot then which will actually receive the data that we want. At this point,
I'd like to do something just like console log the data. So you can see if that worked,
we'll refresh this. And it looks like we got some data down there. It's an object with
some properties, like a name property, which we see is Luke Skywalker and some other properties
that describe Luke Skywalker.

Now that I have some data and need to get this to display
on the screen Somehow, I want you to pause the video and just try thinking through what
that would entail. How are we going to get this data that we just received from our fetch
call to actually show up inside of our browser? Well, now that my component has received the
data, if I don't save it somewhere, it's going to disappear. And if you remember the way
that we save data, Within a component is by state.

So right here in state, I'm going to
add something like character, maybe, instead of equal to an empty object, I chose an object
because I know the data that's going to come in is going to be an object. And then right
here where I'm receiving my data, I want to make sure that I save it in my state. So I'm
going to set state what's the video again, and see if you can write the set state that
we're going to need to do in order to save this data to our component state. Anytime
we want to change the state, we're going to call this that set state. This case, I really
don't care what the previous state was, because I just want to change this state character
to be the data that I just received. So I'm going to provide an object here, say character is the data that I got.

Now, unless I'm inspecting
this with my dev tools, I don't currently have a way to show that this is actually working.
So down here, in our render, I'm just going to choose one of the properties probably name
and see if that will show up on the screen. inside of my curly braces, I'll say this dot
State DOT character, dot name, refresh the page and see what happens. Hey, now this API
call is fairly quick. It made the call, waited for a response, got the response, set the
state and then displayed Luke Skywalker on the screen all pretty quickly.

But if the
person using this app has a really slow internet connection, or the API is really bogged down,
or for whatever reason, it's taking a long time for this request to complete, there's
actually going to be nothing that shows up on the page until that request is done, which
is a little bit off putting for a user. So although this doesn't directly relate to this
lesson, fetching data from an API, this is a great place to talk about having some kind
of loading message that lets the user know that the data is on its way.

Now usually,
I like to use some kind of fancy loading spinner or something like that. But for now, let's
just make it display the word loading until that data comes back. This will illustrate
a little bit of the power of saving state in your component and updating state as you
go through a really simple way to do this is to add to my state, a Boolean as to whether
or not we're loading, I'll start by saying it's false. And then right before we perform
our fetch, I'm going to change it to true. Pause the video and see if you can figure
out how to change loading to true. Okay, remember, anytime we want to change state, we're going
to use set state.

And I don't care again, what the old state was, I'm just going to
provide an object and say, loading is true. Now what we need to do is figure out how to
display the word loading. If state says that the data is loading. Pause the video again,
and see if you can write something down inside a div that shows the word loading if this
dot State DOT loading is true. Right now I have this dot State DOT character dot name.
Here, you can see really quickly when I load this, that there's a moment where it's blank.
So what I could do is right before my return, I could say something like text equal to and
then provide an if else statement. Or I could shorten that by putting a ternary statement
here.

So I'm going to say simply, is this dot State DOT loading true? If so I want the
text to say, loading. Otherwise, I want the text to say this dot State DOT character dot
name. And instead of having this done here, I can put in my paragraph or whatever element
of text I want. And I'll say it before I refresh this, I want you to try and think like the
computer and see if you can figure out what's going to happen. Let me refresh this. And
what's going on here. It says that it's loading constantly. To thank for saying it, why would
it be doing that? Why is it consistently saying loading rather than changing it to the character's
name? Well appear we set loading to true, but we never again set loading to false.

And
so this is always evaluating to the string loading. So now pause again and see if you
can figure out how to fix this bug. This one's pretty easy here. When we're setting state
of the character. We're also going to set the state of loading back to false. Let's
refresh. You'll see it said loading for just a short
amount of time and And then it resolved to Luke Skywalker. Awesome. Okay, so we have
successfully used component did mount as a place to fetch our data from an external API,
so that our component can do what it's supposed to do. In theory, this components job is to
display one of the characters from the Star Wars API. And it needed the data from the
Star Wars API. To do that. We've also implemented a loading feature that lets the user know
whether it's currently loading or not, so that they don't just give up on our site and
leave.

I also think this is a good time to take a step back and remember how awesome
it is that react is so declarative, if you were doing this with vanilla JavaScript, or
jQuery or something more imperative, rather than simply having a ternary, that checks
the current state of your loading variable and deciding whether it should display loading
or not. And then just say whatever that is display the text. Instead, you would have
to manually get an element by its ID, change it to loading, start the API request, and
the data came in, you would have to get the element by its ID, again, you'd have to change
some other kind of style, you'd have to change the word to display the data that just came
in.

Whereas here, we simply get to be more declarative and deal with state and say, whether
we're loading or not tell it when to say that it is loading, tell it when to say that it
is no longer loading, and react will handle the rest. So this is pretty cool. But it does
require a completely different way to think about web development. A few minutes to play
with this code, feel free to go check out the Star Wars API and try getting some other
resources, see if you can get different things to show up on the screen. And when you're
ready, let's go to the next lesson. Let's talk a little bit about forms in react forms
tend to be actually a really important part of having a web application. And I found from
teaching students at vi school that it's actually a rather tricky part of react, because we
do things a little bit differently than we're used to when it comes to forms.

So I'm going
to do something a little bit different in that I want you to do a couple things before
continuing on with this lesson. The first thing is I want to make sure that you understand
state as well as you can, you don't have to be an expert with it. But as long as you have
been able to follow along with everything we've talked about so far in state, and been
able to complete the challenges, you should be good. If not, please go back and spend
some extra time with state. The next thing is I want you to actually pause this video
and go to the React documentation on forms, I put the link right here.

And this does a
pretty thorough job talking about the concept of forms in react. Once you've done that you
can move on. So with forms in react, we actually do things a little bit different than we're
used to with vanilla JavaScript. In the vanilla JavaScript Dom API, you create your form in
the HTML. And once the user decides to submit the form, you go through all of your form
inputs, and gather all the data together pretty much at the last second. And that's when you
would do any kind of form validation that you need, and so forth. Well, with react,
we're going to do it a little bit differently. Instead of waiting until the very end, right
before submitting the form together all of the information, we're actually going to constantly
keep track of all the information in state, which means on every keystroke, we're actually
going to update state so that we can always have the most updated version of what the
user is typing into the form.

To really illustrate this, let's just start with a single text
input. Down here, instead of a div, I'm going to render a form. And we'll put a
single input inside of there. Give it a type of text. Let's give it a placeholder for now, just
to keep things simple. Let's see we're gathering the first and last name of person. We'll start
with first name. Okay, so like I said, normally, our form might have a button that says submit
the form. And at that point in the vanilla JavaScript Dom way of doing things, we would
gather all of the information typed into all the inputs. But in react, we want to watch
for every single change to this input box. So think for a second how we might do something
like that. Well, input boxes have an event that can get fired called on change. So what
we might do is every single time the input changes in the input box, we will run a function.
Let's call it this dot handle change.

This function obviously doesn't exist yet. So let's
create it. Now my goal is to make it so that every single time somebody types in here,
I actually update state and I want to do a couple things. I want to Grab the current
value of this input box every single time it changes. And I want to then update state
to reflect what the current value of that input boxes. Well, first of all, my state
currently doesn't have anything saving anything right now, right? So I'm going to add a property
called first name will just started as an empty string.

Now I have something that I
can update every time the handle change function runs. Okay, well, to update, I use this dot
set state, anytime I want to change the state. Truthfully, I don't care what the previous
state was, I'm just going to provide an object here that says the first name property should
become something. Well, what am I going to put here? Well, I need this to be the current
value of my input box.

If you're familiar at all with vanilla JavaScript Dom API, then
you know that when events fire, they pass a pre determined parameter into our function.
We don't get to choose in this instance, what's actually going to be here, it's always going
to pass to us information about the event that fired. And this event has some really
important information. For example, I can get access to the value of the input box by
saying event got target. Target represents the element in which the event was fired dot
value. And that's the value of the input box. So what I've done here is I've said every
single time a character is typed into this input box, run the handle change function.
And the handle change function changes the state, so that the first name property of
state is updated to reflect whatever the current value of this input box is. I can't open the
dev tools and inspect state inside of scrambler.

And so I'm just going to create a little h1
that will display whatever the state is. So we can see it. And now I'm actually going
to run into a little error. You'll see that it says I can't read the property set state
of undefined, see if you can figure out what I'm missing. Anytime we have a class method
that's calling set state, we need to make sure we bind it inside the constructor. And
so inside the constructor, I'll put this dot handle change equals this dot handle change
that by end of this.

Okay, so let me refresh this again. And I will start typing and you'll
see every single character is upgrading state. Okay, well, I have something that's going
to violate the DRI principle, don't repeat yourself principle. Now what's going to happen
if I want to create another input for my last name. So I've made another input, that is also running
my handle change function. Let me initialize a last name property in my state. And I added
my h1 to show what the last name property of state is. Okay, so I have a first name,
last name, first name works great. But what happens when I type in the last name? Notice
it just gets rid of everything from the first name. That's because I've hard coded into
my handle change that it's updating the first name property of state. Obviously, one way
around, this would be to make a whole extra function called handle last name change or
something like that. And make this on change be a different function altogether. But that's
not going to work in a larger form that may have like 50 inputs or something crazy like
that.

Now instead, what we're going to do is we are not going to hard code first name
here. And we're going to give a name property to our inputs. That perfectly matches what
our state is. First Name, capital N, and last name, capital N. And remember, up in our handle
change, we have this event that we're receiving, well, this event has a bunch of information
about the input that is firing this event. For example, we grabbed the value of the input
box. But I can grab any part of the input object that I want, not only the value, but
I can also grab the name property. And so to the left of my object here in the property
name here. I can say event dot target, which is my input box.

Got name, which is the name
property. This isn't quite right, right, because this is a syntax error. If I want this to
actually represent the first name, property or the last name property, I need Make sure
to wrap this in square brackets. And this works because the name property is a string.
And if I'm describing a string property name inside of an object, I can wrap it in square
brackets. This is just a principle of JavaScript that you may or may not be familiar with.
And so now when I refresh this, anytime I type into the first name box, I get a change
to my state in first name. And anytime I type into my last name box, I get a change to the
last name. Okay, as a quick aside, this same principle here is going to work whether I
am using a type of text, or anything else that's text based like an email, or phone
or number, all of those are essentially going to use this exact same handle change function.
And you need to make sure that you give it a name property that perfectly matches the
property and state and that you pass your on change function to it.

Now I'm actually
splitting forms into a two part lesson. And in the next one, we're going to talk about
some of the other types like checkboxes, radio buttons, text areas, and select boxes. But
before we get there, there's one more thing I want to touch on. And that's the concept
of a controlled form. If you did what you're supposed to do, and went over and read the
React documentation on forms, you read about controlled forms. The idea is that we actually
want what's displayed inside of our form to perfectly match up with what is in our state.
Right now, state is being reactive, as in every time the input in the box changes state
updates, according to what's in the input box.

Well, with a controlled form, state actually
directs what is inside and showing up inside of the input box. This is kind of a splitting
hairs distinction. But it really jives well with the idea that state should be the single
source of truth, it doesn't have to be that complicated, the only thing we really need
to do, especially with these text inputs, is add a value property. and the value should
always be this dot state, dot, and then whatever property that box is holding, first name, last name. And when single elements start to get too
long like this, I like to put each of these attributes into their own lines. Okay, that's
a lot better.

Okay, now we can see that everything, I'm going to refresh this, everything is still
working essentially the same as it was before. But now what is showing up in this input box
is because of what the current version of state is, in other words, I'm forcing the
value or what shows up inside of the input box to exactly match what state is also going
to give you one quick best practice that will help you avoid a really difficult to debug
bug that could come up in the future. In this case, we're not seeing it. And I'm not going
to worry too much about explaining what that bug is exactly. But a really good idea is
instead of directly accessing the name and value properties, by drilling into the event,
that target object here, you can save yourself a lot of grief by simply pulling those values
out of the target before you set any state. Using some basic object D structuring, I can
say name, value equals event dot target. Then down here, I can just say name, value. If
this is something that you're actually super interested in understanding, you can look
into reacts synthetic event.

And you may get a better understanding of why this is important.
But it can be really helpful to make a copy of the name and value before you run setstate.
Okay, that's enough for this part of the lesson. Take some time to go over this again and digest
it, feel free to practice with it. We're going to talk about forms part two next, and then
we'll have a practice that goes over both of these parts together. So far, we've talked about some of the most
basic input types when it comes to forms, anything text based is essentially going to
act the same way that we've talked about in the previous lesson.

But unfortunately, forms
are a little bit more complex than that. And with some of the other elements that you can
use, things start to get a little bit more complicated with react, but it's not too bad.
So let's walk through it. Down here, I've made some notes about some of the elements
that I'd like to talk about the first one and probably the easiest to understand is
the text area element. If you've used the text area element in regular HTML before,
you know that it is not a self closing tag, like the input element, but instead has a
closing tag. If I refresh this page, you can see that it's essentially like an input box,
but it's a little bit taller and the user has the ability to make it bigger or smaller.
We also have the ability to change the default height and width with properties called rows
and columns and in regular HD Well, if you wanted to pre populate some text in here,
you would do so by typing it in between the opening and closing tags, or rather the inner
HTML.

Well, what react has done is they wanted to make text area much more similar to the
input element. So in react, there's a major difference in the text area element in that
it is a self closing element. This is actually really nice, because we are able to use the
value property now. And we can use it exactly the same way as we were with an input. This
is nice for consistency. And it also makes it really easy to update the value of the
thing inside the text area by updating state. So you can see if I were to add some default
value in here. That's what shows up in my text area element. And that's it with text
area. Let's move on to checkboxes. checkbox is just a type from input. So input type equals checkbox. But one of the major differences is that you
are not going to use a value property like we did with text area or input.

Instead, the
idea of a checkbox is that it's either checked or it's not checked. This means that we are
going to add a checked property here and I'm going to start putting things on their own
lines will have a checked property. And this is going to be determined by some kind of
Boolean because a checkbox is either checked or it's not checked. And so checkboxes typically
maintain Booleans in state. For this example, maybe we are checking if the person that we're
referring to is friendly. Now in state, I haven't yet defined this.
So I would come right up here to state. Ad n is friendly, and maybe we'll initialize
it with true for refresh this, you'll see that I now have a checkbox and it starts out
by being checked. We'll notice that if I click it, it's not letting me uncheck it. Think
for a second why that might be? Well, down in my check box, I've told it that it is checked
if this.state.is friendly is true. And essentially this true value is being forced upon this
input.

And so even if the user tries to uncheck it, React will say, Nope, it is actually checked
because this value is true. So you might have noticed something popping up in the console
that says that I've provided a value prop without an unchanged handler, essentially
rendering a read only field. And that's what we're seeing here. It's Read Only I can't
make changes to this because I haven't taught it how to make changes and how to change state.
Well, this is where things get tricky, because what I don't want to do is add an unchanged,
that is looking to something like handle checkbox method. Right? It would be nice if I could
just use my existing handle change method to handle changes on a checkbox. And so we're
gonna see how you can do that. First, I'm going to put this to handle change.

And just
like our other inputs, I'm going to give this a name property that is the same as the thing
in state is friendly. And now Give me a second to make this look a little better in our form
over there. Okay, that looks better. And now the tricky
part comes in. Because in an input box, we're keeping track of what's being typed into the
input box.

You might remember from our handle change, we are grabbing the value event dot
target dot value, an updating state with the new value. Well, our checkbox doesn't have
a value, it has a checked property. And the checked property is actually going to return
either true or false. So what we're going to need to do in order to use our same handle
change function for our checkbox, is we need to check if the element that is being interacted
with in the form is a checkbox or not. And so there's a couple things that we need to
pull out. First of all, notice how we have type equals checkbox. Type is a property that
we can pull from event target. So besides just the name and the value, if it's an input
or a text area, you can also grab the type. And then just like we discussed how checkboxes
don't have a value, but instead have a checked property, we can pull that from event target
as well.

And so now we know that I can check if the type is a checkbox, I won't be able
to do this, this dot set state because I won't have a value property. But instead we'll need
to change the name which is is friendly to whatever the current value of checked is.
You could do an if else statement, or I could just do a ternary here. So I can say is the
type equal to checkbox? If so, we're going to update state in a certain
way. But if it's anything other than a checkbox, we'll use our existing This dot set state. Now here, we will also
run a set state. And we are going to access the name property. But instead of using value,
we're going to set it to whatever the value of checked is.

Let me open this up a little
bit so that it's a little bit easier to read. And now when I refresh, let's see if I'm able
to update my checkbox. Now when I click the check box, it's going through my handle change,
it's seeing that the type is a checkbox. And so it's running this, this that set state.
And when I go over to my other input boxes, I can still say, name, and it's updating state in a different way.
And while we're at it, to get rid of the warning that we have in our console, let's add an
on change to our text area, so that it stops yelling at us.

Excellent. Well, now let's
talk about radio buttons. Because radio buttons are kind of a combination of the input type
text, and the checkbox. What I mean by that is that they are going to use both a value
property and a checked property. So I'm going to make a copy of my checkbox, so that I can
quickly get something prototyped up, I'm going to change the types here to radio, let's give
the name of maybe its gender. And now notice that I'm giving the same name to both of my
radio buttons.

What this tells the DOM to do is to make sure that I can only choose
one of these two radio buttons, wherever they're also going to have value, the value will be
slightly different. So maybe first one is male, and the second one is female. And I'll
update my label here. And let's put some breaks in there. Now notice
what happens when I go over here. Again, I can't change them. But if I click on his friendly,
notice that it chooses one of these two to be checked. This is kind of quirky. And the
reason is, first of all, because I copied and pasted, which sometimes leads to funny
bugs, it's still saying that it's checked if his friendly is true.

But this is where
radio buttons are a little bit different, because I can't just say it's checked if some
value in state is true, because radio buttons jobs aren't to maintain true or false values,
right? That's what the checkbox is for. Instead, I want this to be checked if the value of
this dot State DOT gender is equal to male. And similarly, if this one is equal to female,
I don't have gender maintained anywhere in state, so I'll need to go update my state
up here.

Maybe we'll just start gender as an empty string. Now, when I choose this,
it will let me choose one or the other. And under the hood, it's maintaining a gender
of either male or female. Again, since I can't pull up the dev tools in scrambled, let's
go down here and just display something here. Okay, and we should probably use some kind
of conditional rendering. So this doesn't show up until one of these is chosen, but
that choose male and female, it's updating state, and therefore updating the text that
we're seeing down here.

I think this is probably a good point to mention that a lot of this
stuff may seem really complicated and different from each other. And it's just important to
know that you're not necessarily expected to have all of this memorized. Honestly, I
end up coming back to some previous examples that I've written just so I can remember this
syntax. This is probably also a great time to mention that there's a really excellent
library out there called Formic.

There's a few of them, but I'm just gonna put the name
right here. So you can take a look. Formic basically takes all of the pain out of writing
react forms, it's a library that you can install and just use their API to make your life dealing
with forms much nicer. Okay, the last form element that we're going to talk about is
the select box. And in regular HTML, you're probably used to having a select with options.
And fortunately, React has chosen to use the value property again, so that we can easily
determine which of the select elements is chosen. And also to very easily be able to
update state, though for example, maybe we are deciding what our favorite color is. We'll
have a state property called favorite color, and the value of this whole element is going
to be whichever of these options we choose. First thing, let me put favorite color up
in my state. And we'll just start it off as blue. Okay, and then down here, I'm going
to make sure that I'm watching for a change on my select box.

So unchanged, I'm still
going to run my handle change, I also need to give it a name, just like I did with my
input boxes will make sure that this matches the name and state. And then the only other
change I need to make is make sure that my options also have value. And the value here
is going to be whatever I want the different options to be. So this will be the value under
the hood.

And then the text here in the inner HTML is what will be displayed in the select
box. And that's probably good enough. Oh, and it looks like I put my slash in the wrong
place here. Okay, let's give this a break. So it's on its own line. And maybe put another
label here. And yes, I understand this form is very ugly
right now. But my click my drop down box, you'll see I have my options.

And before I
select something, let's just put another thing down here. So I can see that state is updating. Okay, notice that my state initialized correctly.
And when I change this, it's changing the value of state. what's so cool about the way
that react has chosen to implement the API regarding elements and forms is that it makes
it so that we can write a single on change, rather handle change. It had to do one workaround
with the checkboxes simply because the philosophy behind checkboxes is so different than all
the other elements. But essentially, we're reusing this one handle change, and it's working
for all the elements in our form. Yeah, I totally get that this is a lot to digest,
we're gonna do a practice right after this, that should help cement this information a
little bit.

Don't feel overwhelmed so much with understanding or rather learning all
of the syntax of every one of these elements, that may distract you from all of the other
coolness that react has to offer. Instead, don't be afraid to just practice this a couple
times, and then come back to it whenever you need to, eventually, you'll gain a muscle
memory that will help you remember all of this. One last thing that I failed to mention
in the previous lesson was how to actually submit this form or do something at the end
of filling out this form. Kind of two general ways that you could do this in either way,
it's going to be a good idea to put a button in your form of some type.

Now in html5, the
button element if it's found within a form, acts like the old input type submit, if you're
familiar with using that, where you would give it a value that displayed the text on
the button, and so forth. I personally really dislike the way that input is used in so many
different ways. And so I never use the input type submit myself. Instead, buttons in html5,
if they're found within a form. When they're clicked, they are a submit button. And they
will fire the on submit of the form itself. So when you want to do something, when you're
finished with the form, one thing you could do is to just add an on click on your button.
Personally, I like to handle that action on the form itself. And so I will have an on
submit handler. And we didn't write this but it would be just as easy as creating another
method that's called handle submit and doing something like submitting the form to an API
or something like that. Okay, take a deep breath, you've basically finished all of the
most important parts of forms.

We've talked about input type, text, and other text based
inputs like numbers and passwords and so forth. But we've also learned how to handle checkboxes,
radio buttons, and select boxes and text areas. Okay, let's move on to the next lesson, which
will be a practice of forms. So let's practice building forms. Your challenge
is to wire up the partially finished travel form below so that essentially it works in
react.

This challenge is actually one that we use at vi school and the URL for the original
challenge is right here, you'll probably want to go there so that you can see exactly what's
supposed to be done. Now in this goal will use this as in plain HTML forms challenge
so it doesn't really have anything to do with react, but I'm just adapting it for react
for this lesson.

So pause this lesson, go take a look at this website. Learn some more
about what you're trying to accomplish in this form, and give this a go. Alright, so there's a lot of different ways
that we could approach this, I think what I might do is initialize everything with state
first, and then start wiring things up one at a time. Okay, so I know that my state is
going to have a first name. Last name.

We'll also do age, which actually have a little
bit of a question myself on, but I'm just going to initialize it at zero for now, and
then try something a little bit later. Let me scroll down here, I know I'm supposed to
have under and I have a select block for location, I'm pretty sure this is supposed to be destination.
So I'll say destination, then a checkbox for dietary restrictions.

Now, what's actually
going to be there for dietary restrictions is a number of checkboxes. And because they're
checkboxes, it's possible that they will check multiple boxes. And so if I'm going to have
multiple dietary restrictions, what I might do is choose to take this as an array. And
okay, that seems to be the last thing because here's my Submit button. Now that I have my
state initialized, I'm just going to start putting some of the things that I know will
need to exist in my existing elements here.

So we'll start with my inputs, I know that
I'm going to need a name property for each one. Now I'm going to need a value for each
one. Actually, this is going to be determined by state. So this will be this dot State DOT
something I know each one is going to want to be able to change. So I will have an on
change will probably call it handle change. While I'm added I'm going to put everything
on its own line. Okay, so the names will need to match the parts of state that they're representing.
So this will be first name, last name, and age. And I'll actually have the same thing
for state. So this will be first name, last name and age. So that looks like I lost my
curly braces there.

Now maybe before I go creating a bunch of extra elements, I may
finish this part off and make my handle change method. Right here, I will need a handle change.
I'm going to take an event. And before I forget, I should probably find this I know that I
like to pull some of the elements from the event that target.

So for this right now,
I just need name and value will add to this later when we get to the checkbox. And I'm
going to set state here whatever name I'm concerned with changes
to the new value. Okay, so the buggy thing here is that this starts with a zero. Let's
go down and see if these three inputs are working correctly. So with your name, going
to put this dot State DOT first name, base, and this dot State DOT last name.

If I type in these boxes and see if it's working
great. The same for age. And it already says zero. But if I change this to something different.
Okay, that works. And now the thing I actually wanted to test was to see if react complained
when I started this as No. And it does. Okay, and it looks like it just doesn't like that
the value on the input is no. So it recommends using an empty string. But part of me going
out and doing a bunch of research this will just have to do for now. Okay, so after a
refresh, you can see I don't get my zero age anymore, which is smart, we wouldn't want
that showing up as a default of our form. And it looks like so far, so good. Let's go
down and fill in some of these new elements here. Let's start with the radio buttons for
gender. I like to wrap my radio buttons in a label that said that the person could also click
on the text of male or the text of female and select the associated radio button because
the text is a parent of the radio button.

So I'll just put the label as a parent of
my radio button which is an input Type radio. And I like the text to be on the right side
of the radio button myself so that the radio buttons are nice and lined up on the left
side. And remember the radio buttons were kind of a combination of checkboxes where
they have a checked property and also the text inputs where they have a value property.
So I'm going to be adding a lot of stuff to this radio button, I'm gonna go ahead and
start putting things on their own lines already.

And then we'll say response has a name, which
will be a gender value, in this case, it will be male. And we're also going to have the
checked property. This one is a little bit trickier because it's going to say this radio
button is the selected one. If this that state that gender is male, then we'll have our on
change to be our this dot handle change. And let me go ahead and just copy this and change
it to work for female as well. Another great here. Hey, let's refresh the page and see
what we got male and female, and it looks like I can check those. Let me see down here,
if that's working. So under your gender, we'll put a start state that gender doesn't start
as anything and choose male. And there we go. Change it to female. Perfect. All right,
we're cruising.

So let's do our select box now says the select box for our locations or destinations.
And this is going to be a select box. And we know we're going to have some options in
here. And let's put before options. Obviously, this
is not a great airline that's flying to only three or four locations, but whatever. Now
I remember that our select and our options all take a value property. They're a little
bit different from each other, but I'm going to go ahead and just add a value. Okay, the
value on my options is simply what state should be if this option is the one that's chosen.
So this is where I'm going to put my actual locations. So I might say something like Germany. And I'm going to keep this lowercase for the
extra value just to stay consistent with how I have things elsewhere. Let's do Norway, the North Pole. And why not, say the South Pole. The value
of the select box is not the options that we have, but rather the chosen option.

So
this will be determined by state as part of a control perform. We are calling this destination.
Then just like our other ones, we need to make sure that this has a name, say his destination
again, it needs to match the property and state. And we'll have our same on change,
which is the standard change is getting long. So let's put it on its own lines. And down
in the Display area, we will put destination from state. Now you'll notice here that it
has automatically selected the first one, but doing so has not actually updated state.
So my destination is still empty.

If I want to Germany, I would actually need to switch
to Norway, and then back to Germany to actively choose this as my option. And so what a lot
of people will do is they'll just put an option at the top that maybe we'll leave empty and
put something like something like that. Okay, Germany gives me Germany and I can actually
actively switch to any one of these that I want. Okay, well, we've saved probably the
more difficult one for last. And that's our checkbox. I feel like I've had some clarity
since I first started state. At the beginning of this lesson, I created an empty array for
my dietary restrictions. And I'm thinking it's actually going to be easier if I save
this as a sub object where I have an option for each one of my dietary restrictions and
the value is going to be a Boolean. So instead of trying to manipulate my bullions into some
kind of text value. Instead, I'm just going to create an object.

And each one of these
will represent a Boolean of some kind, I will probably want each of these to be unchecked
as a default. So I'll just say each one is false. The is kosher. Free. That should be
good enough. So now I'll need three checkboxes, each one representing one of these three properties
down here in my form. Again, I will wrap everything in a label type of checkbox. Name, the vegan unchanged will continue to be this handle
change, which if you remember, we're going to need to update in order to correctly handle
the checkbox. And then I need something to direct whether or not this is checked. And
this is going to be a little extra nested level here.

So it's going to be dietary restrictions.is
vegan. And as part of my label, I'll just put a label that says vegan. Okay, so I'm
actually just going to create a few of these and update them. So I have is vegan is kosher. And this one was lactose free.
Okay, let's take a look and see what that looks like. Okay, awesome. Now notice that once again,
I'm not able to change any of these checkboxes. If you didn't get this far, when you did this
yourself before we started doing this together, pick the time now to see if you can update
our handle change so that it can handle the changes in a checkbox.

Okay, so once again, the checkboxes don't
have a value property. And currently, our handle change only is able to update things
with the value. But we know that we're going to have to check if the type is checkbox.
So I'll need to pull the type from my element. And I'm also going to want to see if property
is true or false. Or rather just see what the check property is, then what I need to
check is if the type is a checkbox, I'm actually going to do my
set state on its own line, it's gonna get a little more complicated.
Remember that in this case, I can't just say to set the state of name checked.

That's because I've chosen to have a nested object here.
Apparently state does not have a property called is vegan or is kosher. Instead, it
has a property called dietary restrictions, which has a property called is vegan, or is
kosher. Now normally, React is smart enough to know that if I'm updating just one part
of state like the destination, it will combine that with the rest of state.

However, I'm
not 100% sure offhand, if I update just one part of a nested object, if it will also update
the rest of state. So I'm going to be live testing this here with you. Let's give it
a try. First thing is this won't work either way. So this will have to be dietary restrictions.
Be an object, and we will update the name. Before I can test this, I need to finish my
ternary because this is broken Currently, there will say otherwise. This dot set state
name value just like we had before ever feeling this isn't going to work, but let's give it
a shot. So no errors so far. That's good. You know, just put something in here, we'll
see that my name is working.

Now if I check vegan, it doesn't seem to like it, it thinks
that I'm changing something from a controlled form to an uncontrolled form. And that has
to do with the way that date is updating out Fortunately, I think I should be able to use
the object spread notation, which means what I can do is pass in the previous state. If
you remember when we talked about that state how I can either provide a brand new version
of state or I can provide a function that receives the previous state as a parameter
and uses that to update state. I'm going to change this to the second way and I return
a new object and inside of dietary restrictions, going
to take all of the property These from proof State DOT dietary restrictions, and then update
the rest. And it actually looks like maybe scripted does not have the ability to do object
spread notation.

It really depends on what version of ECMO script you are transpiling
using Babel. In this case, it seems like the object spread notation doesn't work in scrubba.
But at this point, I think it kind of worked myself into a corner. One workaround that
I can do and probably will do for now is to just get rid of my sub object, dietary restrictions.
And make each one of these their own property on state, we just got promoted. which case, I can probably simplify this quite
a bit and go back to the way it was. So we'll get rid of dietary restrictions, we'll get
rid of this name checked. And now that is vegan is kosher, and is lactose free are kind
of first class citizens here in state, I can simply update by its name and determine whether
it's true or false.

Let's try this. Okay, we're doing some live debugging here, it says
that it cannot read property is vegan, of undefined. And notice that I still have my
checked saying this dot State DOT dietary restrictions. We don't need that anymore.
Or handle change and try again. Okay, so now I should be able to enter something as a first
name, which shows up in my name, and then choose some of these. And oh, we haven't updated
our dietary restrictions display yet. Down at the bottom, let's just see if we can get
this to work your dietary restrictions, say, vegan.

State that is vegan. And we'll just
do the same with kosher and lactose free. You'll notice that it looks
like they're starting out empty. If I had checked them, it's not actually displaying
any text here. Isn't is react does not display Boolean true or false as text on the screen
unless you go out of your way to make it text. But one quick workaround that I could do is
I could put another ternary here that says you should display Yes, if it's true.

No,
if it's false, then here, I actually get the nose showing up. Let me put these each in
their own paragraphs, so that they don't mash together this way. And you'll see vegan, no
kosher, no lactose free No. When I select some of these, those have changed. Yes. Or
another fun practice that would just be a regular JavaScript challenge is to try to
get it to display the words vegan, kosher and lactose free is a comma separated list.
I won't do that here. Because I've already taken up time just trying to debug this with
you. If you want, you can pause the lesson and give that a shot might be kind of a fun
challenge. And with a little bit of workaround, and having to change a little bit of our state,
we have been able to successfully build our form. It's obviously not very pretty, but
it seems to be working. So if I fill everything out, not 9999, as it turns out, looks like
oh, I have to select the destination.

Let's go to Norway. It looks like everything has
filled that correctly. I mentioned at the beginning of learning forms, it's a kind of
complicated process. And forms in general are very important when it comes to web applications.
Obviously, they're not always going to be filling out lengthy or forms like this. But
if you think about it, anytime you click a checkbox, or anytime you have a radio button,
or a signup form, or a login form, or anything like that, a lot of that is using forms. So
really understanding this is going to help you be a better developer for web applications
that users can interact with. So although I said it's not necessarily important to have
each input type syntax memorized, it's still a really good idea to practice this, play
with it, see if you can really understand it so that when the time comes to build the
form in your react app, you can do so relative ease.

Thanks for your patience while we went
through and debug some of this stuff. Hopefully, that was a good exercise in general. When
you're ready, let's move on. So when we built the travel form in react,
you may have noticed that a lot of the time we were scrolling up and down and we have
an component here that's 146 lines long. Now you'll notice that A lot of this space is
being used as display logic, right? It's showing the form, it's displaying UI, it's creating
elements, all of this happening inside of the render. But then we also have a place
where we're maintaining state. And we have our handle change function, which is doing
some business logic.

You know, there's been a study done that shows that a programmers
ability to understand the code that they're looking at diminishes dramatically, when the
file that they're looking at is one in which they have to scroll to see everything. And
I've noticed that with my students as well, if I have code that's too long, and I'm scrolling
around the screen all the time, it's very easy to become disoriented and lose your place,
and makes it much more difficult to actually understand what you're looking at.

It would
be nice if we separated our concerns between the UI logic or the rendering logic, and the
business logic that actually mandates how the rendered logic changes. And so this idea
emerged a few years ago of having a presentational component and a smart component or component
that's in charge of the business logic. There's a lot of different names that you'll hear
presentational and container components, smart components and dumb components, containers
and components. But they all refer to essentially the same thing. The idea is that you have
one component whose job it is to maintain state, and to have the methods that update
state. And then for that component to essentially delegate all of the UI logic or presentational
logic to another component. That's called the presentational component. That presentational
component will only be in charge of receiving props and displaying things correctly. If
you'd like you could read den epor mobs, medium blog post where he talked about presentational
and inner components at this URL.

And if you're unfamiliar with Dan Abramov, he's one of the
primary developers of the React framework. So let's take a minute to organize some of
the code that we've written here. First of all, I currently have everything happening
inside of my app component. And I just did that for simplicity. But in reality, I want
my app to render my form, and let my form do all of the for me things. So I'm going
to create a new component called, let's just say form dot j, s. And I'm essentially
going to take everything here, put it over and farm, clean up a few things. palette form, and export form. And then over
in app, we will make sure to import the form. And since our form is handling all of our
state and everything, we basically can change this into a functional component that just
renders the form. So maybe I'll go ahead and do that. That's pretty simple. And you'll
see that everything is showing up the same. And remember way back when I kind of talked
about how I like my app to be sort of a table of contents where I could put a header above
this and a footer below this and whatever main elements and then delegate the rendering
of those main UI components to the other components.

So our problem is essentially still the same
with form j s, because we still have one component that's doing all of this stuff. So what I'm
actually going to do is I'm going to create another component, this one we will call form
component, that j s. But essentially, you could call these whatever you want, you could
have form container dot j, s and form component dot j s, you can even put them into a folder
called form and make form j s actually just index j s and then have form component dot
j s, I've seen it done a bunch of different ways. And for clarity, right now, I'm actually
just going to rename form to form container so that it's obvious which one we're looking
at.

And that just means over an app js, I'll need to update this to form container. And
we're still working. Okay, opening the form container, I'm essentially going to take all
of the rendering logic, let's get this whole return statement. I'm going to take it out.
While I still have it in my clipboard, I'm going to go over to the form component and
create just a regular functional component. Thank you receive props. And let's paste our
whole return in there and fix some of our indenting.

Awesome. One thing you might notice
that's broken because we copied this from a component that was a class based component.
We have stuff like this dot State DOT first name and this dot handle change. Well, this
functional component doesn't have a handle change method and it doesn't have any state.
Instead, it's going to be receiving everything through props. So we'll come back and fix
this in a minute. But over on our form container, you now have an empty render. And what we're
going to do is let the form container delegate all of the UI stuff to the form component.
So at the top, I will need to import form component, the form component file, and simply
render a component. Like we said, we're gonna have to pass a bunch
of stuff through props down here. But already, we can see that my form is quite a bit simpler
than it used to be.

Okay, well, let's wire up our form components so that it has all
of the same information because it right now if I refresh this, you'll see that we have
some problems. And so what I actually need to pass are all of these properties in state.
And I also need to pass my handle change method. So let's start with the handle change method.
And I might as well just keep the name the same. That over in my form component. In props,
I'm receiving a prop called handle change, which means every time I have this dot handle
change, I need this to instead, say props dot handle change.

That's a good start. We still have problems
because we have no state in this component. So let's go back to the form container. And
I have a number of different options, the most annoying of which is I could pass down
first name, which is this dot State DOT first name, and then do this for every one of these
properties. But it's really that's pretty obnoxious, right? Because my form component
is now going to have maybe like seven or eight extra lines. Another option is I could just
pass everything, the whole state object down as a property called something like data to
the start state, this is leagues better than what we had just tried to do.

But it does
mean that in our form component, we're going to have, instead of this dot State DOT first
name, we'll have props dot data dot first name. And truthfully, that's not so bad. And
in fact, in my personal development life, I have tended towards this, where I pass an
object down and I just give it a name, it does mean that I have a little bit of extra
typing where I say props dot data dot first name, instead of finding a way to just have
props dot first name.

But as we discovered, when we were doing the travel form, screenbid
doesn't do so well with the object spread operator. But if you have the correct ECMAScript
versions supported in your project, you could simply say, pass down all of the properties
of this start state. Doing so would allow you to in your form component, say props dot
first name, props, dot last name, and so forth. Again, I have actually leaned towards sending
down an object, simply because it makes following the prompts a little bit easier for myself
in the future and other developers. But I've seen it used both ways. So it's really just
up to you here in screen. But I believe I'm going to have to do something like this. So
now let's go over to our form component and update everywhere it says this, that state
change this to props dot data.

Let's see if we have any problems, says nothing was returned
from render usually means a return statement is missing. Yeah, I think in my form container,
I Yep, I got rid of my return, which we cannot do. So we're gonna put the return back. And
we have one more error, it looks like it says that I probably forgot to export my component,
which Sure enough, I did. export our form component. And it says react is not defined.
And that's because I forgot to import react. And you might remember way back in the beginning,
the reason it says that is because JSX is normally not valid JavaScript. And so I actually
need the React library in this file so that it knows how to handle JSX. And our form is
backup. Let's see if it's working. Good news. Choose the destination. And say we have some
allergies or preferences and we're male. And yeah, it looks like everything else is working.
Perfect. And as such, we still have a quite large form that we have to scroll a little
bit in.

But this entire file is only caring about the UI component of our form. Whereas
over in the form container is only caring about the business logic of the form. This
way, we have a nice separation of concerns. And it allows us as a developer to essentially
have an easier time when we need to make changes to this file, we don't have to scroll up and
down over hundreds of lines of code. Now, one thing that's probably good to point out
now is with libraries like Redux. And with the recently released context API, notice
that the container component split of components here, like we just did is not actually used
quite as often, especially when you are injecting context or global state from Redux or something
like that into your components. When you do that, a lot of the business logic is delegated
to another place entirely. Which kind of means that you end up writing a lot more functional
components to simply consume the data that lives in Redux or in some global context or
something like that. But as you're developing your applications, this can be a really great
way to separate some concerns, if you find that you have a lot of business logic, and
a lot of display logic happening all inside the same component.

Hey, with that, under
our belts, we are ready to move on. Alright, we've made it to our capstone project, where
we're going to build the meme generator that we talked about at the beginning of this course.
Now, the way this will work is part of the time, I will put comments here that will give
you some direction for you to build out parts of the UI yourself, at which point like I
have in the past, I will give you time to pause the lesson and do that afterwards, we'll
go through that together. And there will be other times where I'm just building things
on my own and kind of explaining what I'm doing. Now notice that we're starting almost
completely from scratch, the only thing that I have included already is a bunch of styling
that I've pre written. And the reason I did that is because while this isn't a course
on styling, and just for time sake, so that it's not too boring, but over an index js,
we have nothing here.

So get excited, this is gonna be fun. And let's get started. Okay,
so the first thing you need to do is to create that boilerplate code that will get react
to render something on the screen. And the thing you'll render should be an app component,
which you'll need to create separately. Pause now and give that a try. Okay, let's
get rid of this comment.

And we'll say import react from react, React DOM, from react dash
DOM. We'll use react Dom to render our app component, which doesn't exist yet. We're
gonna put it at the root. we'll import app. And this is basically the
boilerplate we need for there. So let's create our app. Yes. There we will also import react from
react or export our component. Let's start by making a functional component called app.
Which we will have returned something so we can see that it shows up on the screen. Awesome. Okay, let me type up some
comments for the next thing that you're going to do. Okay, so you need to create two new components
header and meme generator, the header is only going to display things and the meme generator
will be calling to an API and holding on to data.

So let that information help you determine
what kind of component you're going to create. And as always, each of those components should
be in their own file of the same name. Pause now and try that. Okay, this one's pretty
straightforward. So let's create a new file called header dot j. s. And a new file called
meme generator. Yes, these comments are in the header import react from react. export the header. And since this is going
to be component that just displays things, we'll make it a functional component. Now, always I'll just put something that says header. And over in meme generators, since this will be
holding data and making calls to an API and so forth. This should be a class component.
We'll still need to import react from react and since it's going to be a class I'll go
ahead and just import opponent as well export the meme generator and create my meme
generator class that it will need a constructor which calls
super.

And I mentioned that it's going to hold some state. So I'll just put some empty
state there. And I will also put my render. So that as before I have something showing
up. Now that I've created both of those over in my app j s, I can import them. I'll go
ahead and use them here, I'll need to wrap everything in a single element.

We'll make an instance
of our header of our meme generator. Awesome, good so far. Okay, over in my header, I'm
just going to begin putting some stuff here. So I know that I
want to use the semantic html5 tag header. And I want this to have an image. And we will
set this as our source which is a troll face. And we'll give it an all property of problems.
too long for this line already.

So I will separated, we'll just have a paragraph that
says and I save this. Okay, you'll see my styles have kicked in because I used the header
tag. And I'm going to go ahead, I didn't do a great job making this responsive. So I'm
just going to make this window a little bit bigger. If that has overlaid your code a little
bit, you may want to make sure you maximize the window here, first grandpa and go a little
smaller probably. And this is everything we're going to do with the header for this project.
So we're going to go to meme generator, and pretty much everything else we do will just
be in this file. So now it's time for you to get your hands back on the keyboard. So
I will write up some comments here for what you're going to do next. Okay, we'll just take this one small step
at a time. So all you're going to do is initialize state to save the following data, top text,
bottom text, and a random image. And I've provided the URL to the first image that you'll
use.

So pause now and do this. It sounds pretty straightforward. So to initialize state, I'm
going to build up this object here and save top text, which is text, but I'll just start
it as an empty string. Bottom text, also an empty string. And my random image, which I'll
just say, IMG is the image I provided. They were not rendering this anywhere. So we can't
really display this. But that's okay. This is good for now. Let me delete these comments. Okay, I have
another challenge for you. Let me write up the comments now. So we're going to be using an API that provides
a bunch of meme images.

And your task is to make an API call to that API, which I've provided
the URL to, and save the data that comes back, which you'll find under response dot data
dot meems, to a new state property called all meme images. And the data that comes back
is going to be an array. Let's pause now and give this a try. When we're getting data that
we expect our component to have at the beginning, we're going to use the lifecycle method component
did mount.

As soon as the component mounts, we're going to use the native fetch function.
And we're going to call to the URL that I provided. And this will return a promise that
we need to turn into a JavaScript object. We will call the JSON method on that. Then
we'll get the actual response that will be useful to us. And I'm going to pull the memes
array from response dot data. And then like it says, we need to save it to a new state
property called all meme images. So I'm going to initialize that as an empty array, and
start, and then I will set state. And I don't really care what the previous state was. So
I will just say all meme images. Now B means that we just pulled just so I can see that
this data is here, I'm just going to console log, the first item in this meme, and take
a look at what that shows me. Cool.

So I've got an ID, a name, and a URL, which is what
we're going to be using is this URL property. Awesome. can delete these comments here, if
you remember back from the demonstration of what this meme generator will look like, there's
going to be two input boxes here that allow you to input the top text and the bottom text
on the image. So what I'm going to do now is just stub out a form. And then I'll have
you create the input boxes. So I'm going to wrap everything in a div building a form.
And for my styling, I'm going to give this a class name. informer. And we'll create a submit button.

It says
Jen, all right, and then I'm going to put some comments here for what your task is next. So now that I'm inside of my form element
in JSX, in order to write these comments, I have to put the curly braces. So that basically
tells the system that I'm back inside of JavaScript, so I can write these comments. So what you're
going to do, you can delete this when you're ready, what you're going to do is create two
input fields, one for the top text and one for the bottom text.

And remember that this
form should be a controlled form. So you'll need to add any of the attributes to these
inputs that you'll need in order for that to still work. Don't worry at this point about
creating your on change handler, because that will be the next thing that you do. So pause
now and try this. Okay, so this is just creating two inputs, so we will make two inputs. And
save time, I'm going to do this in both places, we will have a name attribute which one of
them is going to be top text. And the one is going to be bottom text. In both of these
should be a type of text, I will give them a placeholder. So I don't
need to worry about having labels. Take up text and say button text. And then for this
to be a controlled form, I need to make sure that I set the value equal to whatever the
current value of state is.

Up text, bottom text. Now the last part that I mentioned you'll
be doing next is to write the on change handler. And since these are both text inputs, you
won't have to worry about checkboxes or anything like that. So this one should be fairly straightforward
reference, let me write the comments up here. Create the unchanged handler method here and
it should make sure to update the corresponding state property on every change of the input
box. Pause now and do this. Okay, as I mentioned, this is going to be a fairly straightforward
one, we're going to have a handle change that will receive an event. And to fix my syntax
errors down here, I will add this to this dot handle change.

And that method will need
to be bound in my constructor. And while we're at it, I'll just put a console log here. See
if this is working. Let me get rid of that console log from the means console. And our
method is correctly firing. I want to pull the name and value properties from event target
so that I can get the name of state that I'm supposed to update top text or bottom text
and then whatever is actually typed into the box and I'm going to update my state. Now
I don't care about the previous state So I can just provide an object and I can say whatever
the name is it the value that we pulled from the box. Okay, and we'll get a chance to see
that that's working pretty shortly. If you want, you could pause now and there, right
a console log or put something in your render that shows whether or not this is working.
But we'll just move on.

Next thing I'm going to do is have a place to display our meme.
Now remember, we're receiving an array of all the memes that this API has. And what
we're going to do is make it so that when they hit the gen button, it just chooses one
of those images at random to display in the area below. So I'm just going to build the
area below right now. Make it a div. And for my styling, I give it the class name of meme.
Have the actual image here. source is going to be what we've saved in state as the random
image.

And I'll just put an empty alt property for now. And then for the text itself, I'm
going to have a couple of H twos which have a class name of up and bottom. And all they're
doing is displaying saved in state objects, text and text. Okay, so my image is showing up. This is the
random image that we initialized here. And let's see if my text is working. One does
not simply walk into Mordor and you'll notice that every keystroke, my text is showing up
correctly, which means I'm correctly setting the state on every keystroke. And the time
has come for you to do the last challenge of this Capstone. So let me write out some
comments. I wrote these purposefully a little bit vague
so that you had to think back and look at your notes or go back and look at previous
lessons, whatever it might take, going to create a method that when the gen button is
clicked, chooses one of the memes from our all memes images array at random makes it
so that image that it randomly chose is the one that shows up in our meme display image
area down here.

Now remember, the property on the chosen image in the array is dot URL.
You write that here. That URL is the property that is the string of where the actual image
is hosted. This is your final push, give that a try. Okay, so we could make it where I have
an onClick handler for my button. But because this button is inside of a form, I personally
think it's more semantic to have this be an on submit of the form. We'll call this handle
Submit. So this is where we will create that function. Need to grab the event, because
we don't prevent the default into try and refresh our page, which will be annoying.
So we don't want that to happen. And while I'm at it before I forget, let's bind the
handle submit in our constructor. What we have now is just a basic code challenge. Oh,
I will just pseudocode some of this, I'll say I need to get a random number, which represents
index the array and get the meme from that index.

Once I have that meme, I'm going to
set my random image property to the URL the random item I grabbed. I've broken this problem
into smaller parts, we're going to get a random number so that I can make sure that it's one
of the indices in our array. We'll make sure that I multiply whatever the random number
I get by the length of the meme images array. And now that I have that random number, it
should be easy to get a random meme just just the index of the all meme images Random number
that we just got. And all I'm concerned with is the URL property. So I'm just going to
snag that right now. And I just need to update state now. We'll use set state. I don't care
what it used to be.

And I know that I'm upgrading the random image property, and the value will
be the random meme image. Let's save this and see what we get. Oh, you'll notice that
some of these are funnier than others. But point is we have a random meme generator,
we've written the top text, the bottom text, it's randomly choosing from the array of images
that we pulled from the database online, we now have a completed meme generator. Just
because I'm OCD about this stuff, I'm going to get rid of these comments. This would be
a perfect time to check this code out, see if you can play with it make a better one,
be try to get the gist from a different API.

And although it sounds really obnoxious, one
of the best things that you can do to practice stuff like this is delete all of this code
and try it again from scratch. Feel free to take a break at this point, you've really
accomplished a lot of great things by following through this course and learning the things
that you've learned, I have just a few more topics that I want to cover before we finish
up this course.

Oh, as always, when you're ready, let's move on. Because react is maintained by Facebook, and
quite a few developers over at Facebook, as well as the open source community react is
progressing really quickly. If you've ever tried to watch tutorials of react from more
than maybe two years ago, you might notice that it's quite a bit different now than it
used to be. And we even had a lesson on how react version 16.3 introduced some new lifecycle
methods and also started the process of deprecating some other lifecycle methods will react 16.6
was just released. And there's even more new functionality now and a lot on the horizon
for react version 17 and onward. So I thought I would make this quick lesson about some
of the more modern features that you can use when you're creating react apps. And a lot
of these features will work or won't work, depending on which versions of ACMA script
you're supporting in your project.

But as long as you're using a transpiler, like Babel,
you'll be able to use pretty much the most modern versions of ECMO script and therefore
use some of these things. Now, I didn't do enough research to know which of these are
just experimental or which of these are definitely going to be included in reactor in JavaScript
in general. So you may want to just be aware that any one of these at any given point may
just disappear and not work anymore.

But it's pretty widely used. And I'm fairly certain
a lot of this will be included inside of either react or JavaScript itself. Now one of the
major changes is that our methods can be written as arrow functions. And I believe that scrim
that may complain a little bit about this. But if you're doing this in your own environment,
this should be okay. I can change this to be an arrow function, which looks like a very
small change. But in fact, what it does is it gives it a lexical this inside, which means
that it doesn't create its own this context, but instead uses the this of its surrounding
environment.

Basically, what this means is I no longer have to bind my methods in the
constructor anymore. So I could get rid of this. And because this is an arrow function,
and it's using the this from the class, everything should just continue to work. So that's a
really easy and convenient update that you can make to your class methods. Now, another
one that's a little more dramatic, but also really nice is the ability to create class
variables, just like we're doing here with this dot state. But doing so outside of a
constructor, so I can create this class property by simply saying state equals an object.

And
I guess in this case, to be consistent, we would have a first name, which is an empty
string. And doing this essentially allows me to get rid of my constructor entirely.
The last time I checked, this was still a proposal in JavaScript, but it looked like
it was heading towards being included into the language as a permanent resident. So I
haven't researched this recently, but just take this with a grain of salt and know that
again, this may not be included, but it's looking like it will be we can simplify this
a little bit, since it's just a one liner. So those are both really nice, fairly simple
changes that we can make.

I mentioned once again, the changes to the lifecycle methods,
I created a lesson that you've probably already gone through that talks about some of those
new lifecycle methods. So if you need a refresher, go back, watch those again. But Down here
at the bottom, I've included some resources to some of the more either advanced react
topics or brand new react topics. So for example, in react 16.3, they introduced a kind of public
non beta version of their context API, I've had a chance to play around with the context
API, and I'm a total convert. In fact, a Wii school, we have opted to drop Redux in our
curriculum, and OPT instead for using the context API.

And there's a number of reasons
to do so that doesn't mean that Redux no longer has a place. But for our purposes, the context
API does everything we want, and it's quite a bit simpler to learn. And then there's some
advanced react topics such as air boundaries, render props, higher order components. All
of these can be found directly inside the React docs, which you can see all of the links
here just go directly to the React docs.

And in fact, in the menu bar, they're all part
of an advanced react sub section, that would be a really great resource for learning more. I've also included here, a link to the React
router homepage, the React router is a great way to make single page applications using
a very declarative library, which is react router. It's very widely adopted and used
in most larger applications that are single page applications. Then, at the time of this
recording, these topics react hooks react, lazy, memo, and suspense are all brand new
additions to react. I haven't looked too much into lazy and memo.

But I know suspense has
to do with asynchronous loading. And hooks have to do with a way of essentially including
and modifying state in a functional component. And in fact, if you look at some of these
changes that react is making, it's looking like they're heading towards a place where
react will almost completely be written in functional components. And class based components
will not officially be deprecated. I think they even say in their docs that there's no
plans to remove class based components. But it seems pretty clear that they're moving
in a direction that they are encouraging the use of functional components more and more.
Hopefully, I'll get a chance to update this course, to include some more topics as they
become released. And as I become more familiar with them, but for now, just know that react
is changing constantly.

And it's always a good idea to be checking the change log to
be engaged in your community and watching for these changes, because it can be really
beneficial to you and your career to be up to date on the most advanced and most modern
react features. So we just went through and created the meme
generator together. And before that, we had done a multi part series on creating a to
do app, but to do apps, honestly, are pretty boring. And the more you do them, the more
boring they get. And so I decided to include here some resources that you might use to
come up with ideas for apps that you might want to build yourself, I was going to come
up with a list of my own ideas. And then I came across Free Code camps lists that they
have built over the years. And each one of these is an entire blog post with a whole
bunch of different ideas that you can use. So I would honestly just recommend visiting
these websites, reading through the ideas that they have, and either picking one or
using that as inspiration for ideas for you to come up with.

Alright, you've made it. Now there is so much
more to learn about react. But you now know all the building blocks, you need to start
building react apps for yourself. So let's look at a quick summary of the core concepts
we've talked about in this course, we talked about JSX, and how it's a wrapper around JavaScript
that allows you to write your UI using a familiar syntax. html, we noticed that there were a
couple slight differences here and there. But for the most part, it helps writing components
feel very familiar. We talked about two different kinds of components that you can make a functional
component and a class component and what each one of those is capable of. Basically, if
you need state or lifecycle methods, you will have to use a class based component. Otherwise,
it's a pretty good practice to just stick with a functional component. In fact, going
forward react is kind of looking like there'll be releasing features that allow everything
to be written as a functional component if you want.

We talked about some basic ways
to style react. If you're using CSS classes, you'll need to use class name inside of your
JSX in order to assign a class to that element. Or you could write your CSS as a style object
directly in your JavaScript, which can be helpful if you need them to be dynamic, or
you just generally prefer to style right there inside your component. We talked about props
which are the primary way to pass data down the component tree and we covered state, which
allows your components to hold on to and modify the data.

Anytime you want to change state
you'll need to use these sets The method, we talked about conditional rendering, using
various vanilla JavaScript techniques, you can determine which parts of your UI you want
to show up at any given time. And oftentimes, this is done based on some variable that's
held in either state or props. And we spend some time learning about forms in react and
how to gather input from users in form elements.

And there is so much more about react that
I would love to cover, but we're going to have to save all that other good stuff for
another course. For now, thanks so much for letting me guide you through learning one
of the best frameworks out there..