Review: input and output devices
 

Review: input/output devices

  • Input device = a device that enable a human user to enter binary input data to a computer in a human-friendly fashion

  • Output device = a device that enable the computer to display binary (encoded) data stored in computer memory to a human user in a human-friendly fashion
 

I will discuss one commonly used input device and output device and show you how they work.

Commonly used input device and output device

Most commonly used input device:

Most commonly used output device:

Function of a (English-style) keyboard

A keyboard allows human users to enter English characters (represented by the ASCII code) into the computer memory:

 
 
  • Example: when the user presses the "A" key on the key board, the key board will send 01000001 to the computer system --- 01000001 is the representation of the letter "A"

A keyboard provides this interface function in a humanly-friendly way by showing the symbols A, B, C, ... etc on the key pad

How a keyboard works

When the user presses a key (e.g.: H):

the keyboard will transmit the corresponding binary ASCII code to the computer system

Note: the keyboard inputs are stored in the memory (in Java: in a String typed variable)

How a terminal works

The computer sends an ASCII code (stored in its memory) to the terminal (device):

When the terminal receives the ASCII code (e.g.: 01001000), the terminal circuitry will draw the symbol (character) that corresponds to the ASCII code (H)

Very important fact about the keyboard

Very important fact that you need to remember about the keyboard:

  • The key board always uses the ASCII codes to convey information from human user to the computer

      • You cannot enter data in other codes through the keyboard !!!

  • Specifically, when you type true on the keyboard, the computer:

      • will receive the ASCII codes 01110100(=t) 01110010)=r) 01110101(=u) 01100101(=e) and
      • will not receive the boolean value 00000001

  • And when you type the 15 on the keyboard, the computer:

      • will receive the ASCII codes 00110001(=1) 00110101(=5) and
      • will not receive the 2s complement code 00001111

Illustrated: what happens when you enter true on the keyboard

When you type true on the keyboard, the computer system will store the following 4 ASCII codes in memory:

In contrast:   recall that the Boolean value for true is represented by the 00000001 !!

Illustrated: what happens when you enter 15 on the keyboard

When you type the number 15 on the keyboard, the computer system will store the following 2 ASCII codes in memory:

In contrast:   recall that the byte value for 15 is represented by the 00001111 (in 8 bits) !!

See what you actually enter when you type a number into the keyboard

Type a true or a number and see what is stored in computer memory:

  • Type input: (this simulates what the computer will receive)
       

  • The computer program will receive the following:
       

Try: true, false, 15, -15