Assignment1F - Fall 2024-25
Assignment1F - Fall 2024-25
Student Information:
Special Instruction: Questions may be copied from here through copy-paste. Online submission via
TEAMS is allowed.
Assessment Rubrics:
No
Excellent Proficient Good Acceptable Unacceptable Secured
COs-POIs Response
[10] [8-9] [6-7] [4-5] [1-3] Marks
[0]
All the problems are All the problems are All the problems are not
All the problems are All the problems are not
solved correctly. The solved correctly. The solved correctly. The
solved correctly. The solved correctly. The
simulation processes are simulation processes are simulation processes are
simulation processes simulation processes are
clearly described, and not clearly described, not clearly described,
are clearly described, not described, and No
results are generated by and results are and results are
and results are results are generated by responses
combining all possible generated by combining generated by combining
CO3 generated by combining mostly at all or
input patterns with all possible input several wrong or less no
P.a.4.C.3 combining all possible wrong input patterns copied
appropriate outcomes. patterns with of input patterns with
input patterns with with inappropriate from
A few necessary appropriate outcomes. in/appropriate
appropriate outcomes. outcomes. Almost all others
drawings and A few necessary outcomes. Some
All necessary drawings the necessary drawings
computations are drawings and necessary drawings and
and computations are and computations are
missing but no wrong computations are computations are
shown correctly. missing or wrong.
drawing. missing or wrong. missing or wrong.
Comments Total Marks (10)
1
Final Assignment 1, Fall 2024-25
1. Compute the travel time of the sonar wave as per the following program codes of Arduino if the object is
38.58 cm away from the sonar sensor. Determine the number of LEDs that are turned ON. If we want the
system will display a message for any distance that how many LEDs are turned ON/OFF (for example, “Two
LEDs are turned ON and One LED is turned OFF”) then write the necessary changes that are required to be
included in the following program. Draw the relevant circuit diagram using Proteus and show its simulation
results including the serial monitor’s outputs.
const int trigPin = 8; // define the pin numbers
const int echoPin = 9; // define the pin numbers
void setup() {
Serial.begin(57400); // Starts the serial communication.
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
pinMode(2, OUTPUT); // Sets pins 2, 3, and 4 as the Output pin
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
}
void loop() {
digitalWrite(trigPin, LOW); // Clears the trigPin
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 microseconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) * 1e-6 * 340 * 100; // Calculating the distance
distanceinches = (distance / 2.54);
// Prints the distance on the Serial Monitor
Serial.print("Distance = ");
Serial.print(distance);
Serial.print(“cm; ”);
Serial.print("Distance = ");
Serial.print(distanceinches);
Serial.println(“inches”);
digitalWrite(4, HIGH); }
delay(300); // Wait for 300 millisecond(s)
}
2. Compute the duty cycle and sketch the waveform obtained at port D of the Arduino. Identify the modes of
operation and compute the operating frequency of that mode based on the following program segment.
Identify the Timer of the Arduino Microcontroller. The system clock frequency is pq MHz. Draw the relevant
circuit diagram using Proteus and show its timing diagram.
DDRD |= (1<<PD5);
pinMode(5, OUTPUT);
OCR0B= (150+a+b); // Load OCR0B for setting its duty cycle
// Configure TCCR0A and TCCR0B registers for the mode and pre-scaler
TCCR0A |= (1 << COM0B1) | (1<<WGM01) | (1<<WGM00);
TCCR0B |= (1<<CS02) | (1<<CS00);
3. Compute the duty cycle and sketch the waveform obtained at port D of the Arduino. Identify the modes of
operation and compute the operating frequency of that mode based on the following program segment.
Identify the Timer of the Arduino Microcontroller. The system clock frequency is rq MHz. Draw the relevant
circuit diagram using Proteus and show its timing diagram.
DDRD |= (1<<PD5);
pinMode(5, OUTPUT);
OCR0A = (200+ a + b + c); // Load a value in the OCR0A register
OCR0B= (100 + d + e); // Load a value in the OCR0B register
// Configure TCCR0A and TCCR0B registers for the mode and pre-scaler
TCCR0A |= (1 << COM0B1) | (1 << COM0A0) | (1<<WGM01) | (1<<WGM00);
TCCR0B |= (1<<WGM02) | (1<<CS01) | (1<<CS00);
4. Find the baud rate for the three operating modes when the oscillator frequency, fOSC = ac MHz (put side-by-
side), and register data is, UBRRn = 010110101110. Calculate the baud error and comment on whether there
will be any communication errors or not. Standard Baud rates are 300, 600, 1200, 2400, 4800, 9600,
14400,19200, 38400, 57600, 115200, 230400, ... bps.
5. For the following program, determine the output and the SPI clock frequency when the oscillator frequency,
fOSC = ar MHz (put side-by-side). Determine the slave state at the end of the program. Draw the relevant
circuit diagram using Proteus and show its simulation results including the serial monitor’s outputs.
#include <SPI.h>