Raspberry Pi Simulator Guide
Explore the world of Raspberry Pi simulation with insights on GPIO, libraries, setting up pins, controlling LEDs, and determining pin status. Learn the importance of simulators and key functionalities using Python libraries for time-related operations. Get hands-on experience and enhance your understanding of Raspberry Pi simulation.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
Lab 12 - Raspberry Pi Simulator
Reminders Last week s lab is due today at 11am today (Blackboard ECE 1020-10 Assignments Lab 11 Make sure to exchange contact information with your partner for the final project Guidelines for the final project will be posted to the Blackboard page (ECE 1020 30) soon
What is GPIO? - General-purpose input/output Digital signal pin controllable by the user -
Rpi.GPIO - A library that allows the user to control general-purpose input/output on a Raspberry Pi. Useful Link: raspberry-gpio-python / Wiki / Home
Time library - A library that provides user with time-related functions, such as determining current time or sleeping program for given amount of time - sleep(x) suspends execution of the program for x seconds. - time() returns the current number of seconds since the epoch. Note, if you call time() twice and take the difference between the two values, you can determine how many seconds elapsed between the two function calls. Epoch: the point where time starts in computing systems. The gmtime(0) function call will return the time and date of the epoch. - Useful Link: https://docs.python.org/2/library/time.html
Libraries import RPi.GPIO as GPIO import time
Setting up GPIO Pins GPIO.setmode(GPIO.BOARD) # Tells the raspberry pi that the user is using GPIO GPIO.setup(3, GPIO.OUT) # sets pin 3 to output GPIO.setup(5, GPIO.IN) #sets pin 5 to input
How to make LEDs on pins flash - On the simulator, the output pins can have an LED - To make them flash you can write (assume 3 is the output pin) GPIO.output(3, GPIO.HIGH) time.sleep(1) GPIO.output(3, GPIO.LOW) time.sleep(1)
Determining whether an input pin is on or off - Input pins on the simulator can be turned on or off by checking or unchecking the output pin s box. The code below will print that pin 5 is on when the box is checked or pin 5 is off otherwise if GPIO.input(5) == GPIO.HIGH: print("Pin 5 is on") else: print("Pin 5 is off")
Today we will be working with an online raspberry pi simulator. Go to this link to access the simulator - - - The example from previous slides will be preloaded onto the link. Please explain what happens when you run the code You can run the code by pressing the play button on the lower right hand corner
Todays Objective - - - - Write a code where pins 5 and 7 are inputs When pin 5 is pressed, tell the raspberry pi to make pin 3 LED blink When pin 7 is pressed tell the raspberry pi to make pin 3 LED stay on Otherwise print I love ECE! Hints: - - Use the time delay function Use a for loop to make your code continuous