Good evening!
If you like
Arduino UNO or Raspberry Pi boards,
then this video is for you.
Here you see
few lines of a program
that controls an LED
If I add to this program few new lines
we get a system that
reacts to a button pressing.
This program
is quite similar to those ones
that are used for Arduinos.
But here these few extra lines
were needed because
I wanted to make here a C++ program.
We who use computers understand
that computers need to be
shut down nicely.
You know that
one shouldn't just disconnect
the power supply of a computer
as we are used to do with Arduinos.
And for instance at this program here
the connecting of a certain GPIO line
down to the ground
indicates to this computer
that it should now
start shutting itself down.
But otherwise in this video
we are going to use
the input and output pins
of the Raspberry Pi microprocessors
precisely in the same manner
as the Arduino UNO people
use the input and output pins
of their microcontrollers.
And here you see my personal reason
for today's video.
I'd like to use the power, the flexibility
and the network connections
of a computer to control
for instance this kind of Arduino UNO shields.
So, let's start experimenting!
I bought this Raspberry Pi 2 board
a year ago for about 20 $.
At that time I thought
that it was quite expensive
and I must emphasise that
there are several cheap and good alternatives
for the Raspberry Pi.
But if you absolutely
want to buy a Raspberry Pi,
I'd suggest you to get this Raspberry Pi Zero
that after few months
should be priced at 5 $
or to buy this Raspberry Pi 3
that is the latest version
and unfortunately costs about 35 $.
The total price would be even higher
if we would setup the Raspberry Pi
by using the easiest way that needs
a separate display, keyboard and mouse
that are connected to the Raspberry Pi.
This my Windows 10 computer
is quite new and practically it is still
at its factory settings.
So it is a good environment
for these kind of a tutorials.
And we see that this Windows 10 computer
already has a very good user interface,
and I wasn't at all
willing to bear the cost of any
extra display or keyboard or mouse
just for turning
such a tiny Raspberry Pi board on.
So, in this video
I want to show you that all you need
to get your Raspberry Pi working
is an Ethernet cable, some 5V power source,
and one microSD memory card.
From the description below you will find
these good setup instructions.
Let's place those instructions
onto the right side
of my Windows 10 computer's screen.
And we are let to know
that for a Raspberry Pi we need
an at least 8 GB microSD memory card.
At eBay they cost about 1 or 2 dollars.
And if your computer doesn't have
any microSD card reader
you need to buy one.
At eBay they cost less than 1 $.
So, connect your microSD card
first into a Windows 10 computer.
If that card already has some of your important
files
copy those important files to somewhere else.
Because next we
delete all the files that possibly
were stored
into that microSD memory card
At the Windows file manager
right click the microSD card 's icon,
choose Properties and check
the file system of your memory card.
If the file system isn't FAT32
use this freeware program
and see these instructions
to re-format your disk.
When file system is FAT32
there shouldn't be any need
to format it anymore.
Write down the letter that at your computer
is after the name of the microSD card.
You'll need to remember
that capital letter after a while.
So, an Arduino UNO has a bootloader,
my laptop computer here has Windows 10 operating
system
and respectively a Raspberry Pi needs
some kind of an operating system.
As an example we download and use this
Raspbian Jessie With Pixel
operating system.
Choose the .zip file, download it to your
Windows computer's download folder,
right click that .zip file
and choose the "7-Zip" program
to unzip that file for instance
to that very same download folder.
And you see that a new file with an .img ending
has appeared into your download folder.
Next you'll need this
Win32DiskImager freeware program.
Download it.
It is an .exe file, so to run it
you just double click that downloaded program
and allow it to make
changes to your computer.
Make sure that the hard disk's Device letter
is the same letter that you wrote down a minute
ago.
Click that blue icon,
navigate to your download folder
and double click the file that you just unzipped
and that has the .img ending.
Click the Write button.
And before you confirm
your choice by clicking the Yes button
check once more
the hard disk's Device letter.
If the letter of the hard disk is not the
same
as the one that you wrote down,
you probably
would damage your computer now.
The size of this operating system is
somewhat more than 4 GB.
The progressing of the writing process
can be seen here
and it will take from 10 to 40 minutes,
depending of the type of your microSD card.
When the process is ready click the OK button
and then the Exit button.
Next we must enable
the desired remote access
that uses the Ethernet cable.
To do that navigate in the file manager
into your microSD card.
The hard disk has still the same letter
but now you see that its name
has changed to "boot".
Double click that "boot" disk
and you see in that disk
several folders and files
of our brand new Raspbian operating system.
Below the last one of those files
there is an empty area.
Right click over that empty area
and choose to add a new text file.
At the suggested name of that file
leave that point "." as it is
but delete the "txt" ending.
Don't write any new ending to that place
and chance the proposed name of that file
to "ssh", written in small letters.
Hit the Enter key and then confirm your choice
by clicking the Yes button.
And now your Raspberry Pi
is going to accept the Ethernet connection
that we are going to take after a while.
So, we are ready with the microSD card.
At the file manager
right click the hard disk icon
that still has the name "boot"
and choose to Eject the card.
And now it is safe to
remove the microSD card from the reader.
Place the microSD card
into the Raspberry Pi's memory card slot
so that the small metal pads of the card
are facing towards the green surface
of your Raspberry Pi.
You should feel a click when the card is
in its right place.
Your Windows computer is probably
already connected to your home router.
So, take the Ethernet cable
and connect also your Raspberry Pi
to the same home router.
And finally we must somehow
power up our Raspberry Pi.
It needs up to 750 mA of current.
These mobile phone's power banks
and these phone chargers
all have 5 V output and seem to be able to
give
the needed amount of current.
Any of these power sources will do.
There is only one micro USB socket
on the Raspberry Pi 2 board.
Connect the power source to that socket
with a suitable USB cable.
So, let's now try the Ethernet connection.
To take that connection
you need to know the ip address
that your home router has given
of your Raspberry Pi.
So, download this freeware
Advanced IP Scanner program.
It is an .exe file, too.
So, just double click that program file,
choose the installation language,
press the OK button,
choose to
Run the portable version of this program,
choose to accept
the end user license agreement,
press the Run button
and in this final screen press this Scan button.
Among the scan results
write down
the several numbers and three dots
that come after that "raspberrypi" word.
Now go to this web site,
click this link and install this PuTTY program
by using everywhere its default settings.
Open the PuTTY program.
Type into this box the ip address
that you wrote down a minute ago.
Click "Open",
click the Yes button of this popup window
and now you see that
the Raspberry Pi is working and that it is
talking to us!
For this operating system
the default username is always "pi"
and the default password is "raspberry".
Write them here with small letters
and change them later to your own ones.
Now write to the PuTTY's command line
"sudo raspi-config".
That is Linux command
where the sudo means that
we like an Administrator
or "as a SuperUser want to DO" something.
In other words
we emphasise to the computer that
we are the person
that is allowed to do anything and everything
to this our own computer.
And the actual "raspi-config" command
obviously stands for
Raspberry Pi Configuration.
We now get to a simple menu.
At this line we could
screen size
change the username and password
to our own ones.
But I don't change them today
in order to make this video
easier for you to follow.
Using the arrow down key
navigate to this line and hit the Enter key
to ensure that whole of the microSD card
will be at our disposal.
After that hit the Enter key once more
Using the arrow down key
navigate to this line of Advanced Options
and hit the Enter key.
And continue with the arrow down key
to navigate to that VNC line.
Those letters stand for
Virtual Network Computing.
Hit the Enter key
and in the next screen hit
the tabulator key of your keyboard
so that the  option turns to red.
And then hit the Enter key.
And the hit the Enter key once more
to confirm your that choice.
Using the tabulator key
go to the  option and
hit the Enter key.
We are asked to reboot
and by hitting the tabulator key
and finally by hitting the Enter key
we answer  to that question about rebooting.
My laptop computer starts complaining
that it has just lost the connection.
And that is understable
as we have just shutdown our Raspberry Pi.
Click that OK button
and close the PuTTY's black window, too.
Now download a VNC Viewer from this site:
That site seems to notice
that I am using a Windows operating system
and that my computer can handle 64 bit computing.
The web site proposes me an .exe file for
downloading.
I click that file and when it has been uploaded
I double click the .exe file.
I am asked confirm here that "I have read…"
this text
and click OK.
I usually don't allow any of my programs to
send
data from my computer by their own,
so I click to unchoose this
"Send anonymous…" option
and then I click that I "GOT IT".
And finally at the program itself
write to the address line
the ip address of your Raspberry Pi
and now you have
an excellent graphical user interface (GUI)
to your Raspberry Pi.
Choose Raspberry Application Menu →
→ Programming → Geany Programmer's Editor
There choose
File → New (with Template) → main.c
Into that empty line #29 write
printf("Hello Youtube");
using this syntax.
Now move the cursor
over the brown icon that looks like a building
brick.
Click that icon to "Build the current file".
You are asked to
save this your new project somewhere.
So, navigate for instance
to the Desktop folder
and at the topmost line
give some suitable name
for your current program.
For instance "Hello.c"
and then click "Save" button.
You hear a sound
and see a message from the Compiler
that the compilation has finished successfully.
Now move the cursor over this other icon
that looks like a white paper aeroplane.
Click that icon to "Run the current file".
An LXTerminal window appears
and there on the first line we see
the desired words
"Hello Youtube".
Our first C program seemed to be a success!
And from this USB memory stick I show you
the program that was blinking the GPIO13 pin
in the beginning of this video.
It is a C++ file
and I copy it into the desktop, too.
As we know this program uses GPIO pins.
It needs a specific library for that purpose.
So, Choose Build → Set Build Commands
and at this box tell to the compiler
about an additional library
and the name of that library.
And do the same for this second box as well.
And because such a GPIO pin library
obviously uses
quite fundamental features of a computer
the compiler needs the authorities
of a SuperUser to do such things.
If I now compile and run this program
everything goes as earlier.
The LED blinks
and the system reacts to a button pressing.
Here I use these other wires
in order to shutdown the whole Raspberry Pi.
And after such a decent shut down
it is now safe
to detach the power supply of a computer.
By re-connecting the power supply
the Raspberry Pi starts running again
and the only thing that is left for us today
is to make our C++ program
to start running automatically
after each new power up.
So, look at the desktop folder
where we saved the .cpp file.
As we did the compilation and building
with the default settings
we now see that in that same folder
there is a new file
that hasn't got any extension at all
but has otherwise the same name as our earlier
.cpp file.
That is the executable file
that the compiler and builder
have just made for us.
Copy the path to that file
by right clicking that file and then by choosing
Copy Path(s)
Open the terminal window
and write "sudo nano /etc/rc.local"
using this syntax
and you get into this simple text editor.
Hit the arrow down key
so that your cursor gets to this first empty
line.
Write to that line "sudo",
then hit the spacebar once
and press simultaneously the
Ctrl+Shift+V keys
to paste the path of our executable file
into the ending of that command line.
To "WriteOut" and to save
this modified version of our text file
press Ctrl+O,
accept the suggested old filename
by hitting the Enter key.
And finally "Exit" from that text editor
by pressing Ctrl+X.
Now click
Raspberry Pi Application Menu →
→ Shutdown → Reboot
and see how our blink program starts running
by itself
after every new power up.
In this video
we used the latest Raspbian Jessie image,
so this our system is relatively up-to-date.
But if you later want to update your system
and if you want to do the upgrading
through your Ethernet connection
see the description of this video
for some good advice.
So, thank you for joining me today.
Most of us have started using Arduinos
because the world of Arduino UNO
is so easy to enter in.
I hope that today's video encourages you
to get acquainted with
microprocessors and other microcontrollers,
too.
Have a nice evening!
Good bye!
