Objectives
Group assignment: probe an input device's analog levels and digital signals
Individual assignment: measure something: add a sensor to a microcontroller board that you have designed and read it
Group assignment
In group assignment, we focused on analyzing input devices by probing their analog and digital signals using an oscilloscope. We tested the INMP441 MEMS microphone, which produces a digital signal, and the PS2 joystick module, which outputs an analog signal. The oscilloscope was used to measure and visualize voltage variations from both sensors.
Group assignment pageInput Devices
Sensors
Sensors are devices that detect and measure changes in their surrounding environment and convert them into electrical signals. These changes can be in the form of light, temperature, pressure, motion, humidity, sound, chemical composition, or other physical properties. Sensors play a crucial role in modern technology by enabling automated systems, data collection, and real-time monitoring.
As my final project consist of proximity sensor and digital clock I wanted to explore these sensors.
Proximity Sensor : A proximity sensor is a non-contact sensing device designed to detect the presence or absence of an object within its range without requiring physical interaction. These sensors operate by emitting electromagnetic fields, infrared signals, or sound waves and analyzing their reflections or disruptions caused by nearby objects. Their non-invasive nature makes them particularly useful for applications involving fragile, sensitive, or hazardous materials where direct contact could cause damage, contamination, or interference.
RTC module : An RTC (Real-Time Clock) module is an electronic component that maintains accurate time and date, even when the main power supply is unavailable, by using a built-in battery backup. It consists of an integrated circuit (IC) with a timer, a crystal oscillator for precise timekeeping, and a backup battery to ensure continuous operation. RTC modules are widely used in embedded systems, IoT devices, data loggers, and security applications like alarm systems and surveillance cameras, where reliable timekeeping is essential.
Designing the PCB
To design the PCB I used ATTINY 1614 microcontroller. The microcontroller needs an additional programmer. The design consist of a power LED and three connectors of which two are used for sensor modules.

To check the connection use Ruleschecker tool

Open the schematic editor. We need to specify the design rules

To trace route use the shortcut X or use the route tracks tool in the right panel. Click on edgecuts and using rectangle in tools option draw the outline. Rightclick on the outline and use shape modification option for reshaping outline. You can add text using text tool.

Check the traces using rules checker tool. from file -> Fabrication outputs -> gerbers , we get the gerber format. the gerber files are uploaded in gerber2PNG software to convert it to png format.

Milling the PCB
Open Mods CE. Upload the trace layer. I used 0.2mm 60 deg V bit. Millling was done in Modela MDX-20 3D Milling Machine. I set origin as x:6 and y:4. Set the zero position (X, Y, and Z-axis) manually. Adjust milling parameters like spindle speed, feed rate, and depth of cut based on the material and tool specifications.

we can view the trace toolpath

Stick the copper-clad board in a double sided tape

Secure the board in the bed. The double sided tape keeps the board firm in bed

Click send file option in mods to start engraving the trace

After engraving the trace, we have to cut the outline. The outline layer is oploaded in mods CE.We use 1/32" bit.

The toolpath is shown below.

Using send file option initiate the cutting process.

Use a vaccumcleaner to remove dust and debris. Use a scraper to lift the board.And here is the final result.

Mistakes
Initially the tool depth wasn't enough to engrave properly.So I had to stop the process. I used the down button in pannel key to make sure the engrave is in right depth.

Assembling the PCB
Interactive HTML BOM is generated in KiCad and the components were taken from inventory.
.jpeg)

The components are soldered into the PCB

ATTINY 1614 Pin out diagram

VL53L0X module

The VL53L0X contains a 940 nm infrared (IR) vertical-cavity surface-emitting laser (VCSEL) that emits a short pulse of laser light.This laser pulse travels toward the target object. When the laser pulse hits an object, it gets reflected back toward the sensor.The Single Photon Avalanche Diode (SPAD) array in the VL53L0X detects the returning photons.The SPAD is highly sensitive and can detect even a single photon of light. The sensor measures the time delay between emitting the laser pulse and detecting the reflected signal.
Pinout:
- VIN – Power supply (typically 3.3V or 5V)
- GND – Ground
- SDA – I²C data
- SCL – I²C clock
- XSHUT – Shutdown (optional, digital input)
- GPIO1 – Interrupt output (optional)
Connection:
Connect VIN to 3.3V/5V, GND to ground, SDA and SCL to the respective I²C pins on your microcontroller. You may optionally use XSHUT for enabling/disabling the sensor or GPIO1 for interrupt signaling.
RTC module

The working principle of a Real-Time Clock (RTC) module is based on a crystal oscillator and a battery backup to maintain accurate timekeeping independently of the main power supply. The module uses a quartz crystal oscillator, which provides a stable frequency that is divided down to generate precise one-second time intervals. An internal counter keeps track of seconds, minutes, hours, days, months, and years, with some models also handling leap year adjustments. When the main power is available, the RTC operates normally and synchronizes with the system via an I²C interface. If power is lost, a small backup battery ensures continuous operation, preventing time resets.
Pinout:
- VCC – Power supply (typically 3.3V or 5V)
- GND – Ground
- SDA – I²C data
- SCL – I²C clock
Connection:
Connect VCC to 3.3V or 5V, GND to ground, and use the SDA and SCL lines to connect to your microcontroller's I²C bus.
Inspection
To check the connection I checked the PCB under a microscope and checked the connections with multimeter.

Mistakes
I lost an LED while soldering. The components are very small and need careful handling.
programmer

I used the programmer that was avilable in the lab made by Saheen Palayi. The links are given below. The programmer consists of FTDI board and FTDI to UPDI converter. It is then connected to computer with a USB port.
FT232l FTDI ProgramerCH340 typr C Programmer
UPDI Converter
Programming
VL53L0X Sensor module
To program in Arduino IDE I followed the steps in group assignment, week 4
week4 groupassignmentTo install board manager for the attiny1614 (Megatinycore),
- Open Arduino IDE > Files> Preferences > Click on icon at the side of text field> Copy and paste board manager URL
https://saheenpalayi.github.io/Megatinycore-libs/package/package_drazzy.com_index.json


Choose the correct programmer and the chip to ATtiny 1614. I uploaded an example program and it worked.
I used chatgpt for code reference. Prompt:write a program for VL53L0X with ATTINY 1614.
This code reads distance measurements from a VL53L0X time-of-flight (ToF) distance sensor and prints the values to the Serial Monitor in centimeters. It uses I²C communication (via the Wire library), which works with microcontrollers like the ATtiny1614.
#include <Wire.h> // Include Wire library for I2C communication (used by ATtiny1614) #include <VL53L0X.h> // Include the Pololu VL53L0X sensor library VL53L0X sensor; // Create an object of the VL53L0X class to interact with the sensor void setup() { Wire.begin(); // Initialize I2C communication Serial.begin(9600); // Start serial communication for debugging (use SoftwareSerial on ATtiny1614 if needed) // Initialize the VL53L0X sensor and check if it's detected if (!sensor.init()) { Serial.println("VL53L0X Init Failed!"); while (1); // Stop execution if sensor initialization fails } sensor.setTimeout(500); // Set timeout for sensor readings (in milliseconds) sensor.startContinuous(); // Start continuous ranging mode (sensor will keep measuring distance in the background) } void loop() { // Read the distance from the sensor in millimeters uint16_t distance = sensor.readRangeContinuousMillimeters(); // Check if a timeout occurred during reading if (sensor.timeoutOccurred()) { Serial.println("Timeout!"); // Print timeout message } else { // Convert distance from mm to cm and print it Serial.print("Distance: "); Serial.print(distance / 10); // Convert mm to cm Serial.println(" cm"); } delay(100); // Wait for 100 milliseconds before taking the next reading }
And the result
I wanted to add a programmable LED. The 13 th pin of microcontroller was used for the purpose. The pin is called pin 10 in arduino. I tried the blink program given in the examples and it worked.My idea was to vary the intensity of the brightness in led according to distance. The program I used is given below
Chatgpt prompt :Write an Arduino code using a VL53L0X time-of-flight distance sensor and an LED. The LED's brightness should increase as an object gets closer
This Arduino code reads distance data from a VL53L0X Time-of-Flight (ToF) distance sensor and controls the brightness of an LED based on how close an object is.
#include <Wire.h> // I2C communication library #include <VL53L0X.h> // Pololu VL53L0X distance sensor library VL53L0X sensor; // Create sensor object int LED = 10; // LED connected to pin 10 (PWM-capable pin) void setup() { Wire.begin(); // Initialize I2C communication Serial.begin(9600); // Start serial communication for debugging pinMode(LED, OUTPUT); // Set LED pin as output // Initialize the VL53L0X sensor if (!sensor.init()) { Serial.println("VL53L0X Init Failed!"); while (1); // Stop if sensor not detected } sensor.setTimeout(500); // Set timeout for sensor readings sensor.startContinuous(); // Start continuous measurement mode } void loop() { // Read distance in millimeters uint16_t distance = sensor.readRangeContinuousMillimeters(); // Check if reading timed out if (sensor.timeoutOccurred()) { Serial.println("Timeout!"); } else { // Print distance in centimeters Serial.print("Distance: "); Serial.print(distance / 10); Serial.println(" cm"); } delay(100); // Small delay between readings // If object is within 20 cm, control LED brightness if (distance / 10 < 20) { // Map distance (20 cm to 0 cm) to brightness (0 to 255) int brightness = map(distance / 10, 20, 0, 0, 255); brightness = constrain(brightness, 0, 255); // Ensure brightness stays within valid range analogWrite(LED, brightness); // Set LED brightness } else { analogWrite(LED, 0); // Turn off LED if object is farther than 20 cm } }
RTC module
I followed a tutorial to program RTC module. The program is given below. This Arduino code is used to read and display the real-time clock (RTC) data—such as the current date, time, and day of the week—from a DS3231 RTC module using the uRTCLib library.
#include "Arduino.h" #include "uRTCLib.h" // Include the uRTCLib library for DS3231 RTC module // Create an RTC object at I2C address 0x68 (standard for DS3231) uRTCLib rtc(0x68); // Array to convert numerical day of week to a string (for display) char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; void setup() { Serial.begin(9600); // Initialize serial communication for debugging delay(3000); // Optional delay to allow time for the Serial Monitor to open URTCLIB_WIRE.begin(); // Begin I2C communication (usually calls Wire.begin()) // Set the RTC time and date ONCE, then comment out to avoid resetting on each upload // Format: rtc.set(second, minute, hour, dayOfWeek, dayOfMonth, month, year); // Example below sets time to: Friday, January 13, 2022 at 12:56:00 rtc.set(0, 56, 12, 5, 13, 1, 22); // Uncomment only when setting the time } void loop() { rtc.refresh(); // Update values from the RTC module // Print date and time in a readable format Serial.print("Current Date & Time: "); Serial.print(rtc.year()); Serial.print('/'); Serial.print(rtc.month()); Serial.print('/'); Serial.print(rtc.day()); Serial.print(" ("); Serial.print(daysOfTheWeek[rtc.dayOfWeek() - 1]); // Convert day number to name Serial.print(") "); Serial.print(rtc.hour()); Serial.print(':'); Serial.print(rtc.minute()); Serial.print(':'); Serial.println(rtc.second()); delay(1000); // Wait for 1 second before refreshing the time }
Files
design filesConclusion
This week, my assignment covered PCB design, milling, assembly, and programming using the ATTINY 1614 microcontroller. By integrating a proximity sensor and an RTC module, I gained a deeper understanding of how embedded systems function in real-world applications. Throughout the process, I encountered challenges, such as ensuring proper milling depth and soldering tiny surface-mount components, which required careful adjustments and troubleshooting. Working with these sensors gave me an insight into my final project
Hero shot
