Week 06 – Computer hardware & Pi Commands

Lesson Overview

Topic: Computer Hardware System

Activities & Due Dates[Activity 4] Explore Advanced Raspberry Pi Commands


Content 1 – Components of computer hardware

  • Motherboard
  • The central processing unit (CPU)
  • Memory
  • Read-only memory (ROM)
  • Random-access memory (RAM)
  • Secondary Storage
  • Hard Drive Disk (HDD)
  • Solid Storage Disk (SSD)
  • Memory Cards- SD, USB and memory stick
  • Outdated
  • Compact disk
  • Tapes
The components of computer hardware

Content 2 – The processor: The CPU

  • CPU (Central Processing Unit)
  • Executes the instructions in a software program
  • Communicates with other parts of the computer system, especially RAM and input devices
  • Modern CPU chips have multiple “cores“
    • Key: having 4 cores is not 4x faster than having 1 core
    • i.e. 4 cars does not get you there faster than 1 car
  • Mobile CPU – Core M
    • Small, lightweight, and low power for small computers

Content 3 – RAM – Random Access Memory

  • RAM (Random Access Memory) = integrated circuits (chips) used to temporarily store software (programs, instructions) and data
  • “primary” storage for the CPU
  • Temporarily stores for the CPU:
    • Acts like a whiteboard
  • Software
    • operating system software
    • application software
    • e.g. open an image in Photoshop
      – image data loaded into the bytes of RAM
  • Data
    • Data (documents, spreadsheets, etc.)

Content 4 – RAM Speeds – CPU and RAM

  • Why does the CPU use RAM?
  • The CPU is very FAST!
  • The CPU needs the instructions (software) and data as quickly as possible
  • If the CPU has to wait, so does the user
  • Why doesn’t the CPU use permanent storage like disk drives?
  • Too slow
  • EXAMPLE:  Spellchecker
Computer RAM and CPU

Content 5 – ROM – Read Only Memory

  • ROM (Read Only Memory) = integrated circuits (microchips) that are used to permanently store start-up (boot) instructions and other critical information
  • Read Only = information which:
    • Fixed by manufacturer
  • ROM permanently contains:
    • start-up (boot) instructions
  • Firmware = software program which is stored permanently on a microchip, such as the software on the ROM chip
ROM – Read Only Memory

Activity 1 – Make & Remove Directory Command

  • Mkdir will create a new directory with the name you specify after the command. Use mkdir and then use ls to see the directory you created
Mkdir Command
  • Remove a directory
    • rmdir will delete a new directory with the name you specify after the command. Use rmdir and then use ls to confirm the directory you deleted
  • Change or move directory name
    • Mvwill changes a file or directory name with the name you specify after the command. Use mv and then use ls to see the directory you moved or changed

Activity 2 – Change the working directory

  • Cd is used to change the current working directory. Specify the directory or directory path after the command. You can also use the tab key to autocomplete the directory and file names in the console.
Cd command
  • To navigate back one directory use cd .. To return to your home directory use cd ~
Change working directory

Activity 3 – Run GUI applications using command

•Create and open a simple text file with leafpad myfile.txt This creates a text file called myfile.txt and opens it in a text editor called LeafPad automatically.

Running Leafpad App using command
  • View text files using the CAT command
    • Use the ls command to see the new text file. If you want to view the contents of the text file without opening LeafPad back up, use the cat command followed by the file name
Ls command

Activity 4 – Copy files in Raspberry Pi

  • Cp will copy your file to the specified directory. In this example, you can type ls /home/pi to see the copied file
Cp command

Activity 5 – Make folders and files

  • Move to “Home/Pi/Documents”
  • Type “mkdir Hello Pi”
  • Delete “Pi” folder
  • Change the “Hello” folder name to “Hello_Pi”
  • Copy the “myfile.txt” file into the “Hello Pi” folder
  • Remove file
    • Rm will remove the specified file or files. Add the argument “-v” (verbose) to have an explanation of what is being done printed to the console.
Rm command

Activity 6 – Additional commands

  • Sudo means Super-User DO and is followed by a command that requires the super-user to complete.
  • Apt-get is a package manager that you use to install, update, and upgrade your software.
  • Wget is used to access files from the internet.

Activity 7 – Change File & Directory Permissions

  • You need to set permissions for the shell script file. Type ls -l to see the permissions for the files in myfile.txt
  • R = read, W = write, X = execute
File Permission
  • Change Permission
Change file permission

Activity 8 – Get your IP Address

  • Cmd Ifconfig
  • Find wlan0 and read inet address
  • Send a ping to your classmate
  • Ping “your classmate’s IP address”
  • “Ctrl+C” to return to the command line
  • Ping to test connectivity between two nodes. You can ping hostname of IP address using the below command

Closing – Explore Bluetooth devices around you

  • Your Raspberry Pi can scan Bluetooth devices around you using the command below
Exploring Bluetooth devices