Answered You can hire a professional tutor to get the answer.

QUESTION

Week 3 Lab 3 Name: Raspberry Pi/GERTBOARD Objective Introduce the student to the GERTBOARD input/output interface for the Raspberry Pi.

Week 3                                           Lab 3                Name:

Raspberry Pi/GERTBOARD

Objective

Introduce the student to the GERTBOARD input/output interface for the Raspberry Pi. The purpose of the lab is to allow students to get experience on how a computer can interact with simple peripheral devices, such as switches and light-emitting diodes (LEDs). The student will gain experience making software changes, to make hardware perform in a desired fashion.

Parts Needed

Raspberry Pi version B+

GERTBOARD

Introduction

Computers are designed to process data from external input devices such as keyboards, mice, switches, lights, scanners, and sensors. Computers control various output devices such as monitors, printers, LCD displays, motors, and solenoids.

Procedure Part 1

Connect the GERTBOARD to the Raspberry Pi.

Connect the computer monitor, mouse, and keyboard to the Raspberry Pi.

On the GERTBOARD make the following connections.

Place small black jumpers on 74244 driver outputs B1–B8.

Connect two long jumpers from GP25 to B1 and GP22 to B2.

Plug in power to the Raspberry Pi.

After the Pi boots up, key in username pi, and password raspberry.

At the command prompt, key in startx.

Double click LXTerminal.

Open Python v. 2.7.

The Python Shell will appear.

On the top menu, click FILE, NEW WINDOW.

Key in the program below. The Raspberry Pi will read the condition of switch S1 on the GERTBOARD. If the switch is pressed, a Logic 0 is sent to GPIO pin 25. If the switch is untouched, a Logic 1 goes to pin 25. A message is sent to the computer monitor indicating the state of the switch. The program will pause asking if the operator wants to continue checking the status of the switch. Type y for YES or n for NO (program will terminate).

Hit F5 to compile and check for syntax errors, when the system asks if it is OK TO SAVE, save the file as YourNameWk3part1.py in /home/pi directory.

The Python Shell should indicate “RUNTIME ERROR: NO ACCESS TO /DEV/MEM. TRY RUNNING AS ROOT.” If this is the only error and no syntax issues occur, you are ready to run the program.

On the Raspberry Pi desktop, launch LXTerminal.

At the command prompt key in: sudo python YourNameWk3part1.py

If the switch is not pressed, the message on the screen will display:

Pin 25 is a logic 1.

Continue checking pin 25?       y or n

On the GERTBOARD, LED D2 should be on, LED D1 will be on.

Press and hold S1 on the GERTBOARD, on the keyboard, key in y and press the enter key. While S1 is pressed, D2 LED will be off, LED D1 will be off, and the message on the screen will be

“Pin 25 is a logic 0”.

Continue checking pin 25?       y or n

Instructor signoff ____________________________

Hold the CTRL key and press c to terminate the program.

Move the long jumpers that are connected to (B2/GP22) to (B3/GP23) and (B1/GP25) to (B2/GP24). Now the S2 switch (middle switch) will be monitored for a key depression. The LEDs to observe will be D2 and D3.

Modify the program to initialize GP24 for input using internal pull-up resistors and GP23 for output. Change the print instruction so the program will display the following.

“Pin 24 is a logic (0 or 1 state)”

Continue checking pin 24?       y or n

Hit F5 to compile the program.

Go to LXTerminal, hit the up arrow to retrieve the previous command and hit the ENTER key.

Instructor signoff ____________________________

Part 2

From the Python Shell upper menu, select FILE/NEW WINDOW.

Key in the program below.

Connect two long jumpers from GP25 to B1 and GP17 to B2. These connections will connect switch S1 to GPIO pin 25 (input) and LED D2 to GPIO pin 17 (output).

Use the same procedure in Part 1 to save the file as YourNameWk3part2.py

If S1 is pressed on the GERTBOARD, LED D2 will flash ON and OFF at 1- second intervals. If the button is released, the output will be OFF.

Test the program to make sure it works. On the keyboard, hit CTRL-c to terminate the program.

Change the long jumpers to the following.

(B1/GP25) to (B3/GP24)—switch S3 connects to GPIO pin 24, input.

(B2/GP17) to (B1/GP22)—LED D1 connects to GPIO pin 22, output.

Modify the Python program to reinitialize the GPIO port pins so when the program runs, D1 will flash ON/OFF when S3 is pressed. Change the delay time to 500msec [replace sleep (1) with sleep(.5)].

Go to LXTerminal and run the Python program to verify the software/hardware modification is functional. Hit CTRL-c to terminate the program.

Submission Instructions

Connect Ethernet cable to the Raspberry Pi. Go to Desktop, open Web browser. In the address area, type http://devryu.net. Put in eCollege username and password. Open course. Go to Dropbox, attach your Python Files, then Submit. On a PC, complete Lab 3 datasheets and save as FirstNameLastNameWeek#Lab.docx and submit to the Dropbox.

Type sudo shutdown –h now, hit the ENTER key. Disconnect power from Raspberry Pi.

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question