Professional Documents
Culture Documents
Assignment-A1
(UNIT –I & II)
answer:-
CODE:
def maxchambertemp(data):
# Initialize the maximum temperature and chamber number
max_temp = -float("inf")
max_chamber = ""
return rotated_lst
node_values = [1, 0, 1, 0, 1]
rotated_values = nodeonoff(node_values)
print(rotated_values)
A1 3.4 Run the python program in your laptop and take the screen shot of the
output of the python program showing that there are no errors
CODE:-
import serial
import time
This code imports the serial and time modules, which are needed to
communicate with the Zigbee module over the USB port and to add
delays, respectively.
The code then configures the serial connection to the Zigbee module,
which is connected to the /dev/ttyUSB0 port and has a baud rate of
9600.
Next, the code opens the serial port and sends a command to the
device to turn on the LED. Then, it waits for a response from the device
and reads it. Finally, the code prints the response and closes the serial
port.
b'LED ON\r\n'
This is the response that the device sends back to confirm that it received
the command and that the LED has been turned on.
You need to write program in python for reading the serial data and display
the output on the Python shell. Make your code readable and understandable
to others. If your code is well-written, indented and annotated, it is easier to
understand, debug and maintain.
CO1 C
In your solution you are expected to answer the following.
A1 4.4 Run the python program in your laptop and take the screen shot of the
output of the python program showing that there are no errors.
CODE:
import serial
while True:
# Read a line of data from the serial port
line = ser.readline()
4.1
a) The Python module that provides interfaces to the serial port is called
serial.
b) The method that reads the serial port is readline().
c) The functions that are required to format the data for displaying depend
on the specific data being read from the serial port and the desired formatting.
For example, you might use the strip() function to remove leading and
trailing whitespace from the data, or the format() function to insert the data
into a string with a specific layout.
4.2
RFID module
| |
V V
5V -------- V
|
V
Ground
|
V
Tx ------Rx
|
V
Raspberry Pi
4.3
import serial
while True:
# Read a line of data from the serial port
line = ser.readline()
J.Chinmai
B19EI005