\documentclass[a4paper,12pt]{report}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage{listings}
\usepackage{xcolor}

\lstset{
  language=C,                % programming language
  basicstyle=\ttfamily\small,    % font style and size
  keywordstyle=\color{blue},     % keywords color
  commentstyle=\color{gray},     % comments color
  stringstyle=\color{red},       % strings color
  numbers=left,                  % line numbers on the left
  numberstyle=\tiny\color{gray}, % line numbers style
  stepnumber=1,                  % line number step
  numbersep=5pt,                 % distance between line numbers and code
  backgroundcolor=\color{white}, % background color
  frame=single,                  % frame around the code
  breaklines=true,               % automatic line breaking
  tabsize=4,                    % tab size
  showspaces=false,              % don't show spaces as special characters
  showstringspaces=false,        % don't underline spaces in strings
  captionpos=b,                  % caption position bottom
  escapeinside={(*@}{@*)},       % for LaTeX inside listings
}

\graphicspath{{res}}

\begin{document}

\begin{titlepage}
    \centering
    \vspace*{1cm}

    \Huge
    \textbf{EES 1031 Electronics and Embedded Systems Lab}

    \vspace{0.5cm}
    \LARGE
    Academic Year 2024/2025

    \vspace{2.5cm}

    \Large
    \textbf{Practical 03}\\
    \textbf{Interfacing and Driving Two-Digit Seven Segment LED Displays}

    \vfill
    \begin{tabular}{rl}
        Name: & GLNN MANJUSRI\\
        Index No: & AS20240927\\
    \end{tabular}

\end{titlepage}

{\centering
    \Large \textbf{PART A}\par
}


\section*{Activity A-01}
\textbf{Explain how you can produce analog voltages between 0 V to 5V using a potentiometer.} \\

\section*{Activity A-01}
\textbf{Explain how you can vary the light intensity of an LED or the speed of a DC motor using a potentiometer. } \\

\section*{Activity A-01}

\textbf{What is pulse-width modulation (PWM) and how does it work?} \\
\section*{Activity A-01}
\textbf{Derive the Root Mean Square (RMS) voltage for a pulse signal.} \\
\section*{Activity A-01}
\textbf{What pins can we use to generate PWM signals in the Arduino Uno, and what are the initialized frequency/ period of the PWM signal for each pin?} \\
\section*{Activity A-01}
\textbf{Explain how you use the Arduino function “analogWrite()” to generate PWM signals with duty cycles of {0,10,25,50,75,100} \%, and calculate the theoretical Vrms for each case (using PWM 3 pin).} \\

\newpage

{\centering
    \Large \textbf{PART B}\par
}
\section*{Activity B-01}
\textbf{Write an Arduino sketch to generate the above PWM signals and measure the Vrms for each case.} \\
\section*{Activity B-02}
\textbf{Write an Arduino sketch to control the light intensity of an LED using the PWM signal. Then modify the code to vary the light intensity (PWM signal duty cycle) via an analog input coming from the potentiometer. } \\
\section*{Activity B-03}
\textbf{Construct a circuit to control the speed of a DC motor using a PWM signal and explain how the circuit works. } \\
\textbf{Do not provide the power to the motor directly from the microcontroller. Why?} \\
\section*{Activity B-04}
\textbf{Now, construct a circuit to control the DC motor speed and the direction (H bridge). Explain how the circuit works. Write an Arduino sketch to demonstrate the DC motor controller. } \\

\newpage
\includegraphics[width=\textwidth]{led-radio}

\lstinputlisting{./src/b-4.ino}

\newpage
\end{document}

