Wednesday, June 11, 2025

Electronic Dice With 7 – Segment Display

Aim

The Aim of this project is to learn, study and create different ICs in digital logic and designing and create a unique project. This project gives us an immense knowledge of electronic components which are important to know.


Introduction

Electronic dice is simple electronic circuit with a push button that can be used like a normal dice in games. The dice works by switching Light Emitting Diodes (LEDs) on and off just like the pattern of dots found on a traditional dice.

Playing with dice needs us to pick up a dice and make sure that it is unbiased. Making a block as a dice and cutting it clearly to make sure that it is unbiased is all an old story. The dice becomes biased if the shape is not cut well. Also, the dice can become biased due to deformations. If it is a wooden die, it can deform due to dampness in the atmosphere or due to mechanical stress. To solve all these problems which we have with a conventional dice, we have made a dice circuit which solves all the problems of a conventional dice.

Electronic LED dice is nearly unbiased. There is no chance to cheat as the circuit operates and pulsates at such a high speed that the circuit is almost imperceptible to the human eye. There is also little maintenance and there is hardly any impact on aging of the circuit. The frequency may vary a bit with change in power supply voltage and varying the resistor, aging of the active and passive components but still the randomness will be preserved without any trouble.

The main brain of this project is IC 4017 with the help of IC 555 toggles the LEDs at a decent speed. IC 4511 is used to display and provide the specific LED a Number. The main work is that when we press the switch, it starts series toggling and when we release the switch it stops at a random digit next to the sequence giving you a random number as that for dice.

The clock pulses are given to a counter cum decoder circuit IC 4017 with the seventh output given to reset. It has nine possible outputs out of which, the seventh is given to reset because we only need a count up to 6 as a dice has six faces only. The first six outputs are given respectively to the LEDs so that the respective LED will glow for the corresponding count. If the count is 1, LED-1 will glow. If the count if 2, LED-2 will glow and so on until the sixth count. When the count is six, the sixth LED will glow and after that for the next clock pulse the counter will advance and the count increments to seven. In this count, the circuit resets itself as the seventh count is given to the reset pin which is PIN-15.


 







Components Used

  1. Breadboard
  2. IC 4017
  3. IC 4511
  4. IC 555
  5. Push Switch
  6. 2 * Resistors (10kΩ)
  7. 1 * Capacitor (1µF)
  8. 6 * LEDs
  9. 7-Segment Display
  10. 9 * 1N4148 Diodes
  11. Connecting wires
  12. 9-V Battery
  13. Battery Clip



Application

  • Designing and implementing a digital instruction-assisted system
  • It can be used as a normal dice in any board games
  • It can give any random value from 1 to 6.





Circuit Diagram

Block Diagram



Pin Configuration

  • IC 4017 – CMOS Counter

IC 4017 or CD4017B is a 5-stage Johnson Counter having 10 decoded outputs. Used to build all kinds of the timer, LED sequencers and controllers circuits. Pin 16 is positive power supply and pin 8 is a ground. The power supply range of 3 volts to 16 volts and Maximum power supply voltage at pin 1 must not much than 18 volts. Pin 13 has Clock enabled pins to controls the clock. When it is “0” logic, the clock is enabled and the counter advances one count for each clock pulse. When “1” logic, the clock input is stopped, and the counter does nothing even when a clock pulse arrives. Pin 14 is the clock triggers one count. Pin 15 is the reset pin. Normally, it is “0”. When made “1”, the counter is reset to “0”. Pins 1-7 and 9-11 are the decoded output pins. The active count pin goes high and all others remain low. Pin 12 is Carry output, for the clock input of an additional counter or an external circuit that the count is complete.






  • IC 555 –  Timer

The 555 timer datasheet specifies that 555 IC is a highly stable device for generating accurate time delays or oscillation. Additional terminals are provided for triggering or resetting if desired. In the time delay mode of operation, the time is precisely controlled by one external resistor and capacitor. For a stable operation as an oscillator, the free running frequency and duty cycle are accurately controlled with two external resistors and one capacitor.












  • IC 4511 – CMOS BCD to 7 Segment Latch Decoder Driver

The 4511 datasheet specifies that this IC is a BCD to 7-segment latch/decoder/driver with four address inputs (DA to DD), an active LOW latch enable input (EL), an active LOW ripple blanking input (BI), an active LOW lamp test input (LT), and seven active HIGH NPN bipolar transistor segment outputs.












  • 7 Segment Display


A seven-segment display (SSD) is a widely used electronic display device for displaying decimal numbers from 0 to 9. They are most commonly used in electronic devices like digital clocks, timers and calculators to display numeric information. As its name indicates, it is made of seven different illuminating segments which are arranged in such a way that it can form the numbers from 0-9 by displaying different combinations of segments. It is also able to form some alphabets like A, B, C, H, F, E, etc.
















Friday, December 27, 2024

Building a 4x4x4 LED Cube Controlled with STM32F401

LED cubes are an excellent way to learn about electronics, microcontroller programming, and creative visual effects. This project involves building a 4x4x4 LED matrix and controlling it with an STM32F401 microcontroller. The 4x4x4 LED cube consists of 64 LEDs arranged in 4 layers, with each layer containing 16 LEDs. Using multiplexing, we light up individual LEDs or create dynamic patterns without requiring 64 GPIO pins.


How the 4x4x4 LED Cube Works

  1. Hardware Layout:

    • The cube is structured in a grid where each LED is connected to a row and column.
    • Each layer has a common cathode, and the columns connect the anodes.
  2. Multiplexing Control:

    • Only one layer is powered at a time, and the LEDs within that layer are controlled using the column connections.
    • By rapidly switching between layers (persistence of vision), we create the illusion that all LEDs are on simultaneously.
  3. STM32 Control:

    • GPIO pins control the rows and columns, while timer interrupts or DMA handle multiplexing efficiently.

Components Required

  1. STM32F401 Development Board (e.g., Nucleo F401RE)
  2. 64 LEDs
  3. 16 Resistors (for current limiting)
  4. 4 NPN transistors (for layer switching)
  5. 4x4x4 LED matrix structure
  6. Breadboard and wires

Circuit Design

LED Cube Connections

  • Anodes (Columns):
    Each column is connected to a GPIO pin through a current-limiting resistor.
  • Cathodes (Layers):
    Each layer is connected to the collector of an NPN transistor. The transistor base is controlled by a GPIO pin through a resistor.

STM32 Connections

  • Use 16 GPIO pins for columns.
  • Use 4 GPIO pins for layers via transistors.
  • Configure additional pins for debugging or input (optional).

Code Implementation

STM32CubeIDE Setup

  1. GPIO Configuration:

    • Set 16 pins as outputs for controlling columns.
    • Set 4 pins as outputs for layer selection (with transistors).
  2. Timers:

    • Use a timer to manage layer switching (e.g., every 2 ms).
  3. Interrupts or DMA:

    • For efficient LED control, use interrupts or DMA to update the column data.

Example Code

#include "stm32f4xx_hal.h"

#define NUM_LAYERS 4
#define NUM_COLUMNS 16

uint16_t column_data[NUM_LAYERS][NUM_COLUMNS] = {
    {0x1, 0x2, 0x4, 0x8, ...}, // Pattern for Layer 0
    {0x10, 0x20, 0x40, 0x80, ...}, // Pattern for Layer 1
    ...
};

volatile uint8_t current_layer = 0;

void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
    if (htim->Instance == TIM3) { // Timer 3 handles multiplexing
        // Turn off all layers
        HAL_GPIO_WritePin(GPIOx, LAYER_PINS, GPIO_PIN_RESET);
        
        // Set column data for the current layer
      for (int col = 0; col < NUM_COLUMNS; col++) {
        HAL_GPIO_WritePin(GPIOx, COLUMN_PINS[col], 
        (column_data[current_layer][col]) ? GPIO_PIN_SET : GPIO_PIN_RESET);
        }
        
        // Turn on the current layer
        HAL_GPIO_WritePin(GPIOx, LAYER_PINS[current_layer], GPIO_PIN_SET);
        
        // Move to the next layer
        current_layer = (current_layer + 1) % NUM_LAYERS;
    }
}

int main(void) {
    HAL_Init();
    SystemClock_Config();
    
    // Initialize GPIO and Timer
    MX_GPIO_Init();
    MX_TIM3_Init();
    
    HAL_TIM_Base_Start_IT(&htim3); // Start timer with interrupt
    
    while (1) {
        // Main loop can be used for updating patterns or other logic
    }
}

Pattern Generation

Patterns are defined by updating the column_data array. Examples include:

  1. Static Patterns: Light up specific LEDs.
  2. Dynamic Patterns: Rotate LEDs in a wave, spiral, or bounce effect.
  3. 3D Animations: Create flowing shapes, letters, or symbols.

Tools and Techniques

  1. STM32CubeMX: Configure GPIO pins and timers easily.
  2. HAL Library: Simplifies hardware interaction.
  3. Debugging: Use a serial interface or LEDs to debug patterns.

Videos

1. Prototype Testing Video




Conclusion

Building a 4x4x4 LED cube using STM32F401 is a rewarding project that combines hardware design, microcontroller programming, and creative coding. With multiplexing, we efficiently control all LEDs with minimal GPIO usage, creating mesmerizing visual effects. This project is a stepping stone to creating larger LED cubes or integrating more advanced features like Bluetooth control or music synchronization.

Take the first step, and let your imagination light up!

DPOAE-Based Ear Testing Using MATLAB and Amplifier

Distortion Product Otoacoustic Emissions (DPOAE) testing is a non-invasive way to assess cochlear health. This technique uses sound frequencies to stimulate the inner ear and measures the resulting otoacoustic emissions, which indicate whether the cochlea is functioning properly. In this project, I developed a custom DPOAE testing device using an amplifier for sound generation and a MATLAB app for signal processing.


Understanding DPOAE Testing

DPOAEs occur when two pure tones (frequencies f1f_1 and f2f_2) are presented to the ear. These tones interact in the cochlea, producing distortion products—new frequencies that are not part of the original tones. The most prominent distortion product is 2f1f22f_1 - f_2, which is generated by the cochlear nonlinearities. Detecting these emissions helps evaluate the integrity of outer hair cells in the cochlea.


Why Two Frequencies?

The cochlea responds differently to various frequencies due to its tonotopic organization, where specific regions resonate at specific frequencies:

  1. Primary Tones:

    • f1f_1 and f2f_2 are two closely spaced frequencies where f1f_1 (lower frequency) is slightly less than f2f_2.
    • These tones stimulate overlapping regions of the cochlea.
  2. Interaction Zone:

    • When the two frequencies are played simultaneously, they interact nonlinearly in the cochlea, creating distortion products.
    • The distortion product 2f1f22f_1 - f_2 is used because it is robust and easily measurable in healthy ears.

System Design

Hardware Components

  1. Amplifier:

    • Amplifies the generated audio signals to ensure the tones are strong enough to stimulate the cochlea.
    • Ensures minimal distortion in the generated signals.
  2. Ear Probe:

    • Plays the tones into the ear canal and captures the emitted DPOAE signals using a sensitive microphone.

MATLAB App

The MATLAB app handles the generation, playback, and analysis of the DPOAE signals.

  1. Tone Generation:

    • Generates two pure tones f1f_1 and f2f_2 with precise frequency and intensity.
  2. Signal Analysis:

    • Records the sound from the ear canal.
    • Performs FFT (Fast Fourier Transform) to analyze the frequency spectrum and detect the presence of 2f1f22f_1 - f_2.

MATLAB Implementation

Tone Generation and Playback

fs = 44100; % Sampling frequency
t = 0:1/fs:1; % Time vector

f1 = 1000; % First tone frequency in Hz
f2 = 1200; % Second tone frequency in Hz

% Generate tones
tone1 = 0.5 * sin(2 * pi * f1 * t);
tone2 = 0.5 * sin(2 * pi * f2 * t);

% Play tones simultaneously
sound(tone1 + tone2, fs);

Recording and FFT Analysis

% Record the signal from the microphone
recObj = audiorecorder(fs, 16, 1);
disp('Recording... Speak into the microphone.');
recordblocking(recObj, 2); % Record for 2 seconds
disp('Recording complete.');

% Get recorded data
recordedSignal = getaudiodata(recObj);

% Perform FFT
N = length(recordedSignal);
f = (0:N-1)*(fs/N); % Frequency vector
fftSignal = abs(fft(recordedSignal));

% Plot frequency spectrum
plot(f, fftSignal);
xlabel('Frequency (Hz)');
ylabel('Amplitude');
title('Frequency Spectrum');

% Highlight DPOAE at 2f1-f2
dpoae_freq = 2*f1 - f2;
disp(['Expected DPOAE Frequency: ', num2str(dpoae_freq), ' Hz']);

How It Works

  1. Tone Playback:
    The MATLAB app generates and plays two tones, f1f_1 and f2f_2, through an amplifier and into the ear canal.

  2. Cochlear Response:
    The cochlea vibrates in response to these tones, producing the distortion product 2f1f22f_1 - f_2.

  3. Signal Capture:
    The emitted DPOAE signal is captured by the ear probe and fed back into the MATLAB app for analysis.

  4. FFT Analysis:
    The app performs FFT on the recorded signal to analyze its frequency spectrum and detect the presence of the DPOAE at 2f1f22f_1 - f_2.


Applications

  • Hearing Screening: Identify cochlear health in newborns and individuals exposed to loud environments.
  • Clinical Diagnostics: Diagnose hearing loss caused by outer hair cell dysfunction.
  • Research: Study the mechanics of the cochlea and auditory system.

Videos

1. Working Video

DPOAE PASS (IN THIS VIDEO AM SHOWING IF I BLOCK THE MICRIOHONE SPEAKERS WILL PLAY THE SOUND AND FULL REFLECTION WILL BE THERE SO WE WILL GET THE ALL GREEN WHICH MEANS EARS  HAVE NO ISSUE ):






DPOAE REFER 
(IN THIS VIDEO AM SHOWING AM NOT  BLOCK THE MICRIOHONE SPEAKERS WILL PLAY THE SOUND AND BECAUSE OF ZERO REFLECTION WE WILL GET THE ALL RED WHICH MEANS EARS  HAVE ISSUE ):
:





2. 3D CIRCUIT DESIGN 



Conclusion

This DPOAE testing system combines MATLAB's powerful signal processing capabilities with a custom-built amplifier and ear probe to assess cochlear health effectively. By detecting 2f1f22f_1 - f_2 distortion products, we gain valuable insights into the auditory system's functionality, paving the way for advancements in hearing diagnostics and research.

Motion Detection Using RF Transmitter and Receiver with Arduino and Python

 


In the world of IoT and automation, motion detection is a fundamental concept used in security systems, smart homes, and more. In this project, we create a motion detection system using an RF transmitter and receiver. The transmitter detects motion using an IR sensor and sends the data wirelessly to the receiver. An Arduino connected to the receiver processes this data and communicates with a Python script via PySerial to control a computer screen or change tabs dynamically.


Project Overview

This system detects motion and triggers an action on a connected computer. The components work together as follows:

  1. Transmitter Side:

    • An IR sensor detects if someone crosses its path.
    • The RF transmitter sends a signal (1 or 0) to the receiver.
  2. Receiver Side:

    • An RF receiver captures the signal and sends it to an Arduino.
    • The Arduino communicates with a Python script via PySerial.
    • Python interprets the signal to shift tabs or change the screen.

Components Required

  1. Arduino Board
  2. RF Transmitter and Receiver Module (433 MHz)
  3. IR Sensor (e.g., IR Proximity Sensor or IR LED and Photodiode Pair)
  4. Computer with Python Installed
  5. Jumper Wires
  6. Breadboard

Circuit Diagram











Transmitter Side:

  • Connect the IR sensor’s VCC, GND, and output to the RF transmitter module.
  • The RF transmitter is powered by 5V from the Arduino or an external source.

Receiver Side:

  • The RF receiver’s data pin connects to a digital pin on the Arduino (e.g., Pin 2).
  • The Arduino communicates with the computer via a USB cable.

Arduino Code

The Arduino listens for signals from the RF receiver and sends the data to the Python script.

const int receiverPin = 2; // RF receiver data pin

void setup() {
  Serial.begin(9600);
  pinMode(receiverPin, INPUT);
}

void loop() {
  int motionDetected = digitalRead(receiverPin);
  if (motionDetected == HIGH) {
    Serial.println("1"); // Send 1 if motion is detected
  } else {
    Serial.println("0"); // Send 0 if no motion
  }
  delay(100); // Slight delay to prevent spamming
}

Python Script

The Python script uses PySerial to read data from the Arduino and control the screen or tabs accordingly.

import serial
import time
import pyautogui  # For controlling the screen

# Configure serial communication
arduino = serial.Serial('COM3', 9600)  # Replace 'COM3' with your Arduino's port
time.sleep(2)  # Wait for Arduino to initialize

def change_tab():
    pyautogui.hotkey('ctrl', 'tab')  # Simulates a tab switch in browsers

while True:
    if arduino.in_waiting > 0:
        data = arduino.readline().decode('utf-8').strip()
        print(f"Received: {data}")
        if data == "1":
            print("Motion detected! Changing tab...")
            change_tab()
        elif data == "0":
            print("No motion detected.")

How It Works

  1. Motion Detection:
    The IR sensor detects motion when someone crosses its path and sends a HIGH signal to the RF transmitter.

  2. Wireless Communication:
    The RF transmitter sends this signal wirelessly to the RF receiver.

  3. Arduino Processing:
    The Arduino reads the signal from the receiver and transmits the corresponding data (1 or 0) to the connected computer via USB.

  4. Python Automation:
    The Python script monitors the serial input. If it receives a 1, it triggers a screen action like switching tabs using the pyautogui library. If it receives a 0, no action is taken.


Applications

  1. Home Automation: Automatically shift screens based on motion detection in different rooms.
  2. Security Systems: Alert systems when unauthorized motion is detected.
  3. Interactive Displays: Use motion detection for dynamic content switching on screens.

Videos

1. Working Video



2. Prototype Testing Video




Conclusion

This project showcases a simple yet effective way to integrate hardware and software for real-time motion detection and response. By combining RF communication, Arduino, and Python, we’ve created a system that can be scaled for various applications, from smart homes to interactive displays. Dive into this project and explore the endless possibilities of automation!

Tesla coil

 

Unlocking the Potential of a Tesla Coil: Driving Wireless Power with a TV Transformer and ZVS Driver

The Tesla coil, invented by Nikola Tesla in 1891, is a marvel of engineering that demonstrates the fascinating principles of resonant inductive coupling and high-frequency power transmission. One of its exciting applications is wireless power transfer, which is as relevant today as ever, given our growing demand for innovative power delivery methods. In this blog, we’ll delve into how to build and power a Tesla coil using a TV transformer and a Zero Voltage Switching (ZVS) driver to create a simple yet effective wireless power supply.


Understanding the Tesla Coil

A Tesla coil comprises two main components:

  1. Primary Coil and Capacitor: These form a resonant LC circuit driven by an external power source.
  2. Secondary Coil and Topload: The secondary coil, coupled inductively to the primary, steps up voltage to incredibly high levels, with the topload serving as a capacitor for energy storage.

The system generates high-frequency alternating currents, creating a high-voltage field capable of wireless power transmission.


Why Use a TV Transformer and ZVS Driver?

The combination of a TV transformer and a ZVS driver is an excellent choice for beginners and hobbyists looking to drive a Tesla coil. Here’s why:

  • TV Transformer: A high-voltage flyback transformer from an old CRT TV can step up voltage efficiently and is readily available.
  • ZVS Driver: The ZVS driver ensures efficient energy transfer to the transformer with minimal heat loss by switching the voltage at zero crossing points. This results in reduced stress on components and higher reliability.

Building the Tesla Coil Setup

Materials Required

  1. Tesla coil (secondary and primary windings)
  2. TV flyback transformer
  3. ZVS driver circuit
  4. Power source (12V to 24V DC, depending on the ZVS driver rating)
  5. High-voltage diodes and capacitors (optional for additional filtering)
  6. Heat sink for the ZVS driver
  7. Wires and connectors
  8. Tools: Soldering kit, multimeter, and safety gloves

Step-by-Step Guide

  1. Prepare the Tesla Coil:

    • Wind the secondary coil using fine magnet wire on a PVC pipe.
    • Create the primary coil using thicker wire and mount it around the base of the secondary coil.
    • Attach a topload (e.g., a metallic toroid or aluminum sphere) to the secondary coil.
  2. Set Up the ZVS Driver:

    • Assemble the ZVS driver circuit or use a pre-built module.
    • Ensure the driver is rated for the voltage and current requirements of your TV transformer.
  3. Connect the TV Flyback Transformer:

    • Identify the primary winding of the flyback transformer and connect it to the ZVS driver’s output terminals.
    • Leave the secondary winding as-is; it will generate high voltage to power the Tesla coil.
  4. Integrate the Tesla Coil with the Transformer:

    • Connect the high-voltage output of the flyback transformer to the Tesla coil’s primary coil. Ensure proper insulation to handle the high voltage.
  5. Power the System:

    • Connect the ZVS driver to a DC power source.
    • Use a multimeter to verify connections and check for short circuits before powering on.
  6. Test the Tesla Coil:

    • Turn on the power and observe the Tesla coil in action. You should see high-voltage arcs from the secondary coil and topload.



Working video 






Safety Precautions

  • Always handle high-voltage components with care.
  • Use insulated tools and wear gloves when working with the setup.
  • Ensure the work area is dry and free of conductive materials.
  • Keep a safe distance from the Tesla coil when operating to avoid electrical shock.

Applications and Beyond

This Tesla coil setup is a demonstration of wireless power transfer, which can power small fluorescent lights or act as a base for experiments in electromagnetism. It’s a stepping stone toward understanding more advanced concepts like energy harvesting, wireless charging, and even radio transmission.

By integrating a TV flyback transformer and a ZVS driver, you’re not only building a cost-effective and efficient Tesla coil driver but also diving into the legacy of Tesla’s groundbreaking work.


Conclusion

The synergy of a Tesla coil, TV transformer, and ZVS driver exemplifies how simple components can create a fascinating demonstration of wireless power. This setup is a great educational tool and a fun project for electronics enthusiasts. Whether you’re exploring the principles of high-voltage engineering or simply enjoying the spectacle of dancing electrical arcs, this project offers a rewarding experience.

Dive into the world of wireless 

Electronic Dice With 7 – Segment Display

Aim The Aim of this project is to learn, study and create different ICs in digital logic and designing and create a unique project. This pro...