Mechatronics Lab 1
Mechatronics Lab 1
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.
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).
“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
#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
6.4.1
#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)