0% found this document useful (0 votes)
28 views6 pages

Mechatronics Lab 1

for help in the lab

Uploaded by

bhagyapatel000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views6 pages

Mechatronics Lab 1

for help in the lab

Uploaded by

bhagyapatel000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Mechatronics: Progress Report 1

Course Number - Section : ECOR1044 - B1B


Group Number : 1044-D2-25
Date Performed : March 4 2024
Date Submitted 2024

1. a) Overview: The Raspberry Pi is a compact computer powered by a 'system on a


chip,' enabling users to explore various programming languages. It operates within
an open-source environment, primarily using Linux distributions, and supports
Python programming. It is equipped with multiple interfaces, including Serial, SPI,
and I2C. The Serial interface features receive (Rx) and transmit (Tx) pins for
communication with serial devices. The SPI (Serial Peripheral Interface) is designed
for synchronous data exchange with peripheral devices, utilising five Raspberry Pi
pins: MISO (master in, slave out) for sending data to peripherals, MOSI (master out,
slave in) for receiving data from peripherals, SCK (Serial Clock) for data
transmission synchronisation, and CE0/CE1 (chip enable) pins for device
management. The I2C interface facilitates synchronous data transfers between
hardware modules using two pins. Raspberry Pi offers diverse applications, such as
programming education, gaming systems, media streaming, VPN servers, and more.

b) Commands

1. Mkdir : this command makes a new empty directory and it’s syntax is ‘mkdir
[file name]’

2. Man : this command provides the manual or help page and it’s syntax is
Man [command]’

3. Tail : this commands syntax is ‘ tail [name]’ and its function is to show the
end of a file name

4. Touch : this command's syntax is ‘touch [file name]’ and its function is to
open the existing file or create a new file if one does not already exist.

5. Cp : this commands syntax is ‘cp [from] [to]’ and its function is to copy a file
and moves it to a new desired location
c) Access Procedure: The Remote Desktop application was initiated on the primary
PC, followed by logging into various windows as instructed by the lab manual. This
process led us to open the terminal on the Raspberry Pi, where we were introduced
to essential Unix/Linux commands such as pw, ls, cd, mkdir, touch, and rm. These
commands are fundamental for checking and navigating directories, as well as
creating and deleting files, aiming to familiarise us with directory management for
future tasks. Subsequently, we utilised the 'Thonny IDE' program on the Raspberry
Pi to interact with a 10-pin LED panel connected to the Raspberry Pi board. Through
Thonny IDE, we accessed the GPIO interface using the Raspberry Pi's dedicated
library. The GPIO interface facilitates communication between the computer and
external hardware. We employed specific GPIO functions, including setmode(),
setup(), output(), and cleanup(), to establish a reference pin, configure pin
input/output, send output signals to a pin, and reset the pins, respectively.

d) The modular implementation of a binary counter is advantageous for system


testing because it allows for error detection in smaller, more manageable
increments. This approach reduces the need to comb through potentially hundreds
of lines of code to identify a mistake. By testing each increment individually,
pinpointing the source of errors becomes simpler. This feature is particularly
beneficial in the development of larger software projects, like applications, where
identifying errors quickly can significantly enhance efficiency and shorten
development cycles, addressing a growing concern within the industry.

e) The Experience with working with the raspberry pi for the first time was very
pleasant as it related programming which is often an abstract thing that is intangible
to something physical such as the display lights so it was exciting to see the code
working in real time.

6.1
16.
File Directory: /Directory/home/pi/Desktop/Patel
File NAme: Bhagya

6.2
5.
5 times

2. Citations
H. Mishra, “Raspberry Pi Interfaces,” IoTbyHVM - Bits & Bytes of IoT, Apr. 10, 2020.
https://iotbyhvm.ooo/raspberry-pi-interfaces/ (accessed Nov. 08, 2023).

“What is a Raspberry Pi? | Opensource.com,”


opensource.com.https://opensource.com/resources/raspberry-pi#:~:text=The%20
Raspberry%20Pi%20is%20a
“Beginner’s Guide: How to Get Started With Raspberry Pi,” PCMAG.
https://www.pcmag.com/how-to/beginners-guide-how-to-get-started-with-raspberry-
pi

“The Ultimate Raspberry Pi Commands Cheat Sheet,” MUO, Aug. 01, 2020.
https://www.makeuseof.com/tag/raspberry-pi-commands-cheat-sheet/

Experiment code:

a)
6.3

#import RPi.GPIO as GPIO #Library for the GPIO Pins


#import time #Library for time-related tasks

#leds_on = [23, 24, 25, 8, 7, 1, 12, 16] #creates a list of the GPIO Pins in order of
when they need to turn on

#leds_off = [16, 1, 8, 24, 12, 7, 25, 23] #creates a list of the GPIO Pins in order of
when they need to turn on

#GPIO.setmode(GPIO.BCM) #Sets the way we reference the GPIO Pins


#GPIO.setup(leds_on,GPIO.OUT) #Sets All GPIO Pins needed to an output pin

#for x in leds_on: #iterates through the loop 8 times


#print ("LED on") #Prints when the LED turns on in the console below
#GPIO.output(x,GPIO.HIGH) #Sets the voltage of Pin x 'HIGH' (3.3V)
#time.sleep(1) #Pauses the program for 1 second

#for x in leds_off: #iterates the loop 8 times


#print ("LED off") #Prints when the LED turns off in the console below
#GPIO.output(x,GPIO.LOW) #Sets the voltage of Pin x 'LOW' (0V)
#time.sleep(1) #Pauses the program for 1 second

#GPIO.cleanup() #Resets the GPIO Pins that we used

6.4.1

#import RPi.GPIO as GPIO #Library for the GPIO Pins


#import time #Library for time-related tasks

#leds_on = [23, 24, 25, 8, 7, 1, 12, 16] #creates a list of the GPIO Pins
#GPIO.setmode(GPIO.BCM) #Sets the way we reference the GPIO Pins
#GPIO.setup(leds_on,GPIO.OUT) #Sets All GPIO Pins needed to an output pin

#x = int(input("Write the number here: ")) #get the number to convert to binary
#bin = [0, 0, 0, 0, 0, 0, 0, 0]#empty binary
#if x in range(128, 256): #only runs if x is in range
#for i in range(8): #iterates through the loop 8 times
#if x % 2 == 1: #if x is odd
#bin[-(i+1)] = 1 #changes the binary index to 1 from 0
#x = x // 2 #changes x to a new number
#for y in range(8): #iterates through the loop 8 times
#if bin[y]: #if the binary digit is 1
#GPIO.output(leds_on[y], GPIO.HIGH) #Sets the voltage of Pin x 'HIGH'
(3.3V)

#time.sleep(3) #Pauses the program for 3 second


#for y in range(8): #iterates through the loop 8 times
#GPIO.output(leds_on[y], GPIO.LOW) #Sets the voltage of Pin x 'LOW' (0V)

#GPIO.cleanup() #Resets the GPIO Pins that we used


6.4.2

import RPi.GPIO as GPIO #Library for the GPIO Pins


import time #Library for time-related tasks

leds_on = [23, 24, 25, 8, 7, 1, 12, 16]

GPIO.setmode(GPIO.BCM) #Sets the way we reference the GPIO Pins


GPIO.setup(leds_on,GPIO.OUT) #Sets All GPIO Pins needed to an output pin

for x in range(255): #runs for each binary number up to 254


bin = [0, 0, 0, 0, 0, 0, 0, 0] #empty binary
for i in range(8): #iterates through the loop 8 times
if x % 2 == 1: #if x is odd
bin[-(i+1)] = 1 #changes the binary index to 1 from 0
x = x // 2 #changes x to a new number
for y in range(8): #iterates through the loop 8 times
if bin[y]: #if the binary digit is 1
GPIO.output(leds_on[y], GPIO.HIGH) #Sets the voltage of Pin x 'HIGH' (3.3V)

time.sleep(0.5) #Pauses the program for 0.5 second

for y in range(8):#iterates through the loop 8 times


GPIO.output(leds_on[y], GPIO.LOW) #Sets the voltage of Pin x 'LOW' (0V)

GPIO.cleanup() #Resets the GPIO Pins that we used

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy