CO5: Analyze the characteristics and operation of sequential
logic circuits including flip-flops, registers, and counters.
CO6: Demonstrate Arduino programming, sensor interfacing
(DHT11/DHT22), and IoT monitoring applications.
| Feature | Combinational Logic | Sequential Logic |
|---|---|---|
| Output depends on | Present inputs only | Present inputs + past state (memory) |
| Memory | No | Yes |
| Clock | Not required | Usually required |
| Feedback | No | Yes |
| Examples | Adders, MUX, decoders | Flip-flops, registers, counters |
| Speed | Faster | Slower (due to clock) |
A sequential circuit is a digital circuit whose output depends not only on the current inputs but also on the previous state of the circuit. This memory capability is provided by flip-flops.
| Type | Description | Examples |
|---|---|---|
| Synchronous | State changes synchronized with a clock | Counters, registers |
| Asynchronous | State changes occur without a common clock | Ripple counters, latches |
A clock is a periodic square wave that synchronizes state changes in sequential circuits. It has two important parameters:
A latch is a bistable memory device that changes state based on input levels (not clock edges). It is the simplest form of sequential circuit.
Built from two cross-coupled NOR gates. Has two inputs (S = Set, R = Reset) and two outputs (Q, Q̄).
| S | R | Q (next) | State |
|---|---|---|---|
| 0 | 0 | Q (hold) | Memory |
| 0 | 1 | 0 | Reset |
| 1 | 0 | 1 | Set |
| 1 | 1 | Invalid | Not allowed |
When S = R = 1, both outputs try to be 0, violating the Q and Q̄ complementarity. This is called the race condition or invalid state.
Adds an Enable (E) input to control when the latch can change state. Uses NAND gates.
Eliminates the invalid state of the SR latch by using a single data input D and an Enable input. When E = 1, Q follows D; when E = 0, Q holds its value.
| E | D | Q (next) | State |
|---|---|---|---|
| 0 | X | Q (hold) | Memory |
| 1 | 0 | 0 | Reset |
| 1 | 1 | 1 | Set |
A JK latch resolves the invalid state of the SR latch: when J = K = 1, the output toggles.
| J | K | Q (next) | State |
|---|---|---|---|
| 0 | 0 | Q (hold) | Memory |
| 0 | 1 | 0 | Reset |
| 1 | 0 | 1 | Set |
| 1 | 1 | Q̄ (toggle) | Toggle |
| Feature | SR Latch | D Latch | JK Latch |
|---|---|---|---|
| Inputs | S, R | D, E | J, K |
| Invalid state | Yes (S=R=1) | No | No |
| Toggle | No | No | Yes (J=K=1) |
| Transparency | Level-sensitive | Level-sensitive | Level-sensitive |
| Applications | Switch debouncing | Data storage | Counters |
In a JK latch with J = K = 1, the output toggles repeatedly while the enable is high. This is called the race-around condition. It is solved by using edge-triggered flip-flops instead of latches.
| Feature | Latch | Flip-Flop |
|---|---|---|
| Trigger | Level-sensitive | Edge-sensitive |
| Race-around | Possible | Not possible |
| Clock input | Enable (E) | Clock (CLK) |
| Speed | Faster | Slightly slower |
| Usage | Simple storage | Registers, counters |
Problem: An SR latch has S = 0, R = 0. If the previous state was Q = 1, what is the next state?
Solution:
With S = R = 0, the latch holds its previous state (memory mode).
Therefore, Q (next) = 1.
Problem: A JK latch has J = 1, K = 1, and current state Q = 0. What is the next state?
Solution:
When J = K = 1, the latch toggles. So Q (next) = Q̄ = 1.
A flip-flop is an edge-triggered bistable memory device that changes state only at a clock edge (rising or falling). It is the fundamental building block of sequential circuits.
| S | R | CLK | Q (next) | State |
|---|---|---|---|---|
| 0 | 0 | ↑ | Q (hold) | Memory |
| 0 | 1 | ↑ | 0 | Reset |
| 1 | 0 | ↑ | 1 | Set |
| 1 | 1 | ↑ | Invalid | Not allowed |
Also called a delay flip-flop or data flip-flop. Output Q follows input D at the active clock edge.
| D | CLK | Q (next) |
|---|---|---|
| 0 | ↑ | 0 |
| 1 | ↑ | 1 |
| X | 0 or ↓ | Q (hold) |
The JK flip-flop eliminates the invalid state of the SR flip-flop. When J = K = 1, the output toggles.
| J | K | CLK | Q (next) | State |
|---|---|---|---|---|
| 0 | 0 | ↑ | Q (hold) | Memory |
| 0 | 1 | ↑ | 0 | Reset |
| 1 | 0 | ↑ | 1 | Set |
| 1 | 1 | ↑ | Q̄ (toggle) | Toggle |
The T flip-flop is a single-input version of the JK flip-flop with J = K = T. When T = 1, output toggles; when T = 0, output holds.
| T | CLK | Q (next) | State |
|---|---|---|---|
| 0 | ↑ | Q (hold) | Memory |
| 1 | ↑ | Q̄ (toggle) | Toggle |
| Flip-Flop | Inputs | Characteristic Equation | Key Feature |
|---|---|---|---|
| SR | S, R | \( Q_{next} = S + \overline{R}Q \) | Invalid state when S=R=1 |
| D | D | \( Q_{next} = D \) | Data transfer |
| JK | J, K | \( Q_{next} = J\overline{Q} + \overline{K}Q \) | No invalid state; toggles |
| T | T | \( Q_{next} = T \oplus Q \) | Toggle |
| Table | Purpose |
|---|---|
| Characteristic Table | Given current state and inputs, find next state |
| Excitation Table | Given current state and next state, find required inputs |
| Q (present) | Q (next) | J | K |
|---|---|---|---|
| 0 | 0 | 0 | X |
| 0 | 1 | 1 | X |
| 1 | 0 | X | 1 |
| 1 | 1 | X | 0 |
| Q (present) | Q (next) | D |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Problem: A D flip-flop has D = 1 applied at the rising edge of the clock. If the current state is Q = 0, what is the next state?
Solution:
\[ Q_{next} = D = 1 \]The output becomes 1.
Problem: A T flip-flop has T = 1 and current state Q = 1. Find the next state.
Solution:
\[ Q_{next} = T \oplus Q = 1 \oplus 1 = 0 \]The output toggles to 0.
Problem: A JK flip-flop has J = 0, K = 1. If current state Q = 1, find the next state.
Solution:
When J = 0 and K = 1, the flip-flop resets.
Therefore, Q (next) = 0.
In level triggering, the flip-flop responds to the input as long as the clock is at a particular level (high or low). This is characteristic of latches.
In edge triggering, the flip-flop responds only at the moment the clock transitions. This eliminates the race-around condition.
Output changes when the clock transitions from 0 → 1.
Output changes when the clock transitions from 1 → 0.
Two flip-flops connected in cascade — the master is triggered on one edge and the slave on the opposite edge. This eliminates race-around and provides reliable edge-triggered behavior.
| Feature | Level Triggering | Edge Triggering |
|---|---|---|
| Response | Entire active level | Only at edge |
| Race-around | Possible | Not possible |
| Transparency | Yes | No |
| Used in | Latches | Flip-flops |
| Reliability | Lower | Higher |
Different flip-flop types are available in IC form. Being able to convert one type to another allows a designer to use the available IC efficiently. Conversion involves designing combinational logic that feeds the available flip-flop's inputs to mimic the desired flip-flop's behavior.
We need to find S and R in terms of J, K, and Q:
| J | K | Q | Q (next) | S | R |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | X |
| 0 | 0 | 1 | 1 | X | 0 |
| 0 | 1 | 0 | 0 | 0 | X |
| 0 | 1 | 1 | 0 | 0 | 1 |
| 1 | 0 | 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 1 | X | 0 |
| 1 | 1 | 0 | 1 | 1 | 0 |
| 1 | 1 | 1 | 0 | 0 | 1 |
| D | Q | Q (next) | S | R |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | X |
| 0 | 1 | 0 | 0 | 1 |
| 1 | 0 | 1 | 1 | 0 |
| 1 | 1 | 1 | X | 0 |
Problem: Design a JK flip-flop using an SR flip-flop.
Solution:
From the excitation table, \( S = J\overline{Q} \) and \( R = KQ \).
Circuit: Connect \( S \) to \( J \cdot \overline{Q} \) and \( R \) to \( K \cdot Q \) using AND gates. Feed Q back to the AND gates.
A shift register is a cascade of flip-flops that shifts binary data one position per clock pulse. It is used for temporary data storage and serial/parallel data conversion.
Data enters one bit at a time and exits one bit at a time. After 4 clock pulses, the input data appears at the output.
Data enters serially but is available in parallel at the outputs of all flip-flops.
Data is loaded in parallel and shifted out serially. Requires additional logic for parallel loading.
Data is loaded in parallel and read out in parallel. Used as a temporary storage register.
| Type | Data In | Data Out | Application | Pins |
|---|---|---|---|---|
| SISO | Serial | Serial | Delay line, buffering | 2 + clock |
| SIPO | Serial | Parallel | Serial-to-parallel conversion | n + 2 |
| PISO | Parallel | Serial | Parallel-to-serial conversion | n + 2 |
| PIPO | Parallel | Parallel | Data storage | 2n + 1 |
| Operation | Description |
|---|---|
| Shift Left | Each bit moves one position to the left; LSB gets 0 |
| Shift Right | Each bit moves one position to the right; MSB gets 0 |
| Rotate Left | MSB wraps around to LSB |
| Rotate Right | LSB wraps around to MSB |
| Arithmetic Shift | Preserves sign bit (MSB) |
| Logical Shift | Fills vacated position with 0 |
Problem: A 4-bit SISO shift register initially contains 0000. The input sequence is 1, 0, 1, 1 (MSB first). Show the register contents after each clock pulse.
Solution:
| Clock | Input | FF₀ | FF₁ | FF₂ | FF₃ |
|---|---|---|---|---|---|
| 0 (initial) | — | 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 0 | 0 | 0 |
| 2 | 0 | 0 | 1 | 0 | 0 |
| 3 | 1 | 1 | 0 | 1 | 0 |
| 4 | 1 | 1 | 1 | 0 | 1 |
After 4 clocks, output = 1 (the first input bit).
Problem: Serial input 1011 is shifted into a 4-bit SIPO register. What are the parallel outputs after 4 clock pulses?
Solution:
After 4 clocks, the register contains the input bits in order: FF₀=1, FF₁=0, FF₂=1, FF₃=1.
Parallel outputs: Q₀=1, Q₁=0, Q₂=1, Q₃=1 → 1011
A 4-bit bidirectional universal shift register that supports:
A serial data stream is converted into parallel data. Used in communication receivers, where serial data arrives on a single line.
Parallel data is converted into a serial stream for transmission. Used in communication transmitters, saving transmission lines.
A SISO shift register delays the input by \( n \) clock cycles, where \( n \) is the number of flip-flops.
A shift register with feedback can generate a repeating sequence of bits (e.g., pseudo-random binary sequences used in cryptography and testing).
A ring counter is a shift register with the output of the last flip-flop fed back to the input of the first. It circulates a single 1 through the register.
Similar to a ring counter, but the complemented output of the last flip-flop is fed back. A 4-bit Johnson counter has 8 states (2n).
| Application | Register Type | Function |
|---|---|---|
| Serial communication | SIPO / PISO | Data conversion |
| Data storage | PIPO | Temporary buffer |
| Delay line | SISO | Time delay |
| Sequence generation | Ring / Johnson | Pattern generation |
| Pseudo-random numbers | LFSR | Testing, crypto |
A counter is a sequential circuit that counts clock pulses. It is built from flip-flops and produces a binary count sequence.
In an asynchronous counter, the clock is applied only to the first flip-flop. Each subsequent flip-flop is clocked by the output (Q) of the previous one. This creates a ripple effect.
| Clock | Q₃ | Q₂ | Q₁ | Q₀ | Decimal |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 0 | 0 | 0 | 1 | 1 |
| 2 | 0 | 0 | 1 | 0 | 2 |
| 3 | 0 | 0 | 1 | 1 | 3 |
| 4 | 0 | 1 | 0 | 0 | 4 |
| 5 | 0 | 1 | 0 | 1 | 5 |
| 6 | 0 | 1 | 1 | 0 | 6 |
| 7 | 0 | 1 | 1 | 1 | 7 |
| 8 | 1 | 0 | 0 | 0 | 8 |
| ... | ... | ... | ... | ... | ... |
| 15 | 1 | 1 | 1 | 1 | 15 |
| 16 | 0 | 0 | 0 | 0 | 0 (rolls over) |
The modulus (mod) of a counter is the number of unique states it goes through before repeating.
In a synchronous counter, all flip-flops are clocked simultaneously by the same clock. Additional combinational logic determines the next state. This eliminates the ripple delay and allows higher-speed operation.
A Mod-N counter counts from 0 to N−1 and then resets. It is designed by decoding the state N and using it to reset the flip-flops.
Design a Mod-6 counter (counts 0–5, then resets). Requires \( n = \lceil \log_2 6 \rceil = 3 \) flip-flops.
| Modulus | Flip-Flops | Count Range | Reset State |
|---|---|---|---|
| Mod-2 | 1 | 0–1 | 2 |
| Mod-4 | 2 | 0–3 | 4 |
| Mod-6 | 3 | 0–5 | 6 |
| Mod-8 | 3 | 0–7 | 8 (natural) |
| Mod-10 | 4 | 0–9 | 10 |
| Mod-12 | 4 | 0–11 | 12 |
| Mod-16 | 4 | 0–15 | 16 (natural) |
An UP/DOWN counter can count either upward (0, 1, 2, …) or downward (…, 2, 1, 0) based on a control input.
Each flip-flop toggles when all previous flip-flops are 1.
Each flip-flop toggles when all previous flip-flops are 0.
| UP/DOWN | Q₃ Q₂ Q₁ Q₀ | Next State |
|---|---|---|
| 1 (UP) | 0000 | 0001 |
| 1 (UP) | 0010 | 0011 |
| 1 (UP) | 1111 | 0000 (roll) |
| 0 (DOWN) | 0000 | 1111 (roll) |
| 0 (DOWN) | 0011 | 0010 |
| 0 (DOWN) | 0001 | 0000 |
Problem: Design a Mod-10 (decade) counter using JK flip-flops.
Solution:
Mod-10 requires 4 flip-flops (since \( 2^4 = 16 > 10 \)).
Count sequence: 0000 → 0001 → ... → 1001 (9) → 0000.
When the state reaches 1010 (10), reset all flip-flops.
Reset condition: \( Q_3 \cdot \overline{Q_2} \cdot Q_1 \cdot \overline{Q_0} \)
Problem: A 4-bit ripple counter has a 1 MHz clock. What is the frequency at the output of the last flip-flop?
Solution:
Each flip-flop divides frequency by 2.
\[ f_{out} = \frac{f_{in}}{2^n} = \frac{1 \text{ MHz}}{2^4} = \frac{1000 \text{ kHz}}{16} = 62.5 \text{ kHz} \]A ring counter is a shift register with the output of the last flip-flop fed back to the input of the first. A single 1 circulates through the register.
A Johnson counter feeds back the complemented output of the last flip-flop. It has \( 2n \) states (twice as many as a ring counter).
| Feature | Ring Counter | Johnson Counter |
|---|---|---|
| Feedback | Q of last FF | Q̄ of last FF |
| Number of states | n | 2n |
| Encoding | One-hot | Progressive |
| Number of 1s | Exactly one | Multiple (varies) |
| Self-starting | No | No (usually) |
| Applications | Sequencer, timing | Frequency division, timing |
| Application | Counter Type | Description |
|---|---|---|
| Frequency division | Any ripple counter | Divide input frequency |
| Digital clocks | Mod-60, Mod-24 | Time-keeping |
| Event counting | Mod-N | Count objects/events |
| Timing sequences | Ring / Johnson | Control signals |
| Program counter (CPU) | Synchronous | Instruction addressing |
| Analog-to-digital converters | Synchronous | Counter-ramp ADC |
| Frequency counters | Synchronous | Measure frequency |
Arduino is an open-source electronics platform based on easy-to-use hardware and software. It consists of a microcontroller board (e.g., Arduino Uno with ATmega328P) and an Integrated Development Environment (IDE) for writing code.
| Feature | Specification |
|---|---|
| Microcontroller | ATmega328P |
| Operating Voltage | 5 V |
| Digital I/O Pins | 14 (6 with PWM) |
| Analog Input Pins | 6 (10-bit ADC) |
| Flash Memory | 32 KB |
| SRAM | 2 KB |
| EEPROM | 1 KB |
| Clock Speed | 16 MHz |
Every Arduino sketch has two required functions:
setup() — runs once at the beginning; initializes pins, serial, etc.loop() — runs repeatedly after setup() finishes.void setup() {
// Runs once at startup
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
// Runs repeatedly
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}
| Type | Size | Range |
|---|---|---|
boolean | 1 byte | 0 or 1 |
byte | 1 byte | 0–255 |
int | 2 bytes | −32,768 to 32,767 |
long | 4 bytes | −2,147,483,648 to 2,147,483,647 |
float | 4 bytes | 3.4 × 10⁻³⁸ to 3.4 × 10³⁸ |
char | 1 byte | −128 to 127 |
| Function | Purpose | Example |
|---|---|---|
pinMode() | Set pin direction | pinMode(13, OUTPUT); |
digitalWrite() | Set digital output | digitalWrite(13, HIGH); |
digitalRead() | Read digital input | int val = digitalRead(2); |
analogRead() | Read analog input (0–1023) | int val = analogRead(A0); |
analogWrite() | PWM output (0–255) | analogWrite(9, 128); |
delay() | Wait in milliseconds | delay(1000); |
Serial.begin() | Initialize serial port | Serial.begin(9600); |
Serial.println() | Print to serial monitor | Serial.println("Hello"); |
millis() | Milliseconds since boot | unsigned long t = millis(); |
Digital pins can be configured as either INPUT or OUTPUT. They read or write binary values (HIGH = 5 V, LOW = 0 V).
// Blink LED on pin 13
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH); // LED ON
delay(500);
digitalWrite(13, LOW); // LED OFF
delay(500);
}
const int BUTTON_PIN = 2;
const int LED_PIN = 13;
void setup() {
pinMode(BUTTON_PIN, INPUT_PULLUP);
pinMode(LED_PIN, OUTPUT);
}
void loop() {
int state = digitalRead(BUTTON_PIN);
if (state == LOW) { // button pressed
digitalWrite(LED_PIN, HIGH);
} else {
digitalWrite(LED_PIN, LOW);
}
}
Arduino Uno has a 10-bit ADC, giving values 0–1023. The reference voltage is typically 5 V.
// Read analog voltage from A0
void setup() {
Serial.begin(9600);
}
void loop() {
int adcValue = analogRead(A0);
float voltage = (adcValue / 1023.0) * 5.0;
Serial.print("ADC: ");
Serial.print(adcValue);
Serial.print(" Voltage: ");
Serial.println(voltage);
delay(500);
}
Some digital pins support PWM (Pulse Width Modulation), which simulates analog output by rapidly switching the pin on and off.
// Fade LED on pin 9
void setup() {
pinMode(9, OUTPUT);
}
void loop() {
for (int i = 0; i <= 255; i++) {
analogWrite(9, i);
delay(10);
}
for (int i = 255; i >= 0; i--) {
analogWrite(9, i);
delay(10);
}
}
The DHT11 and DHT22 are low-cost digital temperature and humidity sensors. They output calibrated digital signals over a single-wire protocol.
| Feature | DHT11 | DHT22 (AM2302) |
|---|---|---|
| Temperature Range | 0 – 50 °C | −40 – 80 °C |
| Temperature Accuracy | ±2 °C | ±0.5 °C |
| Humidity Range | 20 – 90 % RH | 0 – 100 % RH |
| Humidity Accuracy | ±5 % RH | ±2 % RH |
| Sampling Rate | 1 Hz (1 sec) | 0.5 Hz (2 sec) |
| Operating Voltage | 3.3 – 5 V | 3.3 – 6 V |
| Cost | Low | Moderate |
| Pin | Name | Function |
|---|---|---|
| 1 | VCC | Power supply (3.3–5 V) |
| 2 | DATA | Digital data output |
| 3 | NC | Not connected |
| 4 | GND | Ground |
#include <DHT.h>
#define DHTPIN 2
#define DHTTYPE DHT11 // or DHT22
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
float humidity = dht.readHumidity();
float temperature = dht.readTemperature();
if (isnan(humidity) || isnan(temperature)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.print(" °C | Humidity: ");
Serial.print(humidity);
Serial.println(" %");
delay(2000);
}
The Internet of Things (IoT) refers to the network of physical devices embedded with sensors, software, and connectivity that enables them to collect and exchange data over the internet.
| Component | Function |
|---|---|
| Sensors | Collect data (temperature, humidity, light, motion) |
| Microcontroller | Process data (Arduino, ESP32, NodeMCU) |
| Communication | Wi-Fi, Bluetooth, GSM, LoRa |
| Cloud Platform | Store and analyze data (ThingSpeak, Blynk, AWS) |
| User Interface | Mobile app, web dashboard |
#include <DHT.h>
#include <ESP8266WiFi.h>
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
const char* ssid = "YourWiFiSSID";
const char* password = "YourWiFiPassword";
void setup() {
Serial.begin(115200);
dht.begin();
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("Connected!");
}
void loop() {
float t = dht.readTemperature();
float h = dht.readHumidity();
// Send to ThingSpeak or other cloud platform
Serial.print("Temp: ");
Serial.print(t);
Serial.print(" °C, Hum: ");
Serial.println(h);
delay(30000); // Send every 30 seconds
}
| Platform | Features |
|---|---|
| ThingSpeak | Free MATLAB-based IoT analytics |
| Blynk | Mobile app for IoT control |
| Firebase | Real-time database |
| AWS IoT | Scalable enterprise IoT |
| Adafruit IO | Simple cloud dashboard |
Smart home automation uses sensors, microcontrollers, and communication networks to automatically control home appliances such as lights, fans, air conditioners, and security systems.
| Component | Function |
|---|---|
| Arduino / ESP32 | Central controller |
| PIR motion sensor | Detect presence |
| LDR (light sensor) | Measure ambient light |
| DHT11 | Temperature & humidity |
| Relay module | Control AC appliances |
| Wi-Fi module | Remote access |
| Mobile app / Web | User interface |
const int LDR_PIN = A0;
const int LED_PIN = 9;
const int THRESHOLD = 500; // Adjust as needed
void setup() {
pinMode(LED_PIN, OUTPUT);
Serial.begin(9600);
}
void loop() {
int lightLevel = analogRead(LDR_PIN);
Serial.print("Light: ");
Serial.println(lightLevel);
if (lightLevel < THRESHOLD) {
digitalWrite(LED_PIN, HIGH); // Dark → turn on
} else {
digitalWrite(LED_PIN, LOW); // Bright → turn off
}
delay(200);
}
#include <DHT.h>
#define DHTPIN 2
#define DHTTYPE DHT11
#define FAN_PIN 9
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
dht.begin();
pinMode(FAN_PIN, OUTPUT);
}
void loop() {
float temp = dht.readTemperature();
if (temp > 30.0) {
digitalWrite(FAN_PIN, HIGH); // Fan ON
Serial.println("Fan ON (temp > 30°C)");
} else {
digitalWrite(FAN_PIN, LOW); // Fan OFF
Serial.println("Fan OFF");
}
delay(2000);
}
Proteus is a circuit simulation and PCB design software. It allows students and engineers to design circuits, simulate behavior, and test code (including Arduino sketches) before building physical prototypes.
| Feature | Description |
|---|---|
| ISIS (Schematic Capture) | Draw circuit diagrams with components |
| ARES (PCB Layout) | Design printed circuit boards |
| Mixed-Mode Simulation | Analog + digital simulation |
| Microcontroller Simulation | Simulate Arduino, PIC, AVR code |
| Virtual Instruments | Oscilloscope, logic analyzer, etc. |
.hex file..hex file into the Arduino board in Proteus.| Category | Components |
|---|---|
| Microcontrollers | Arduino Uno, PIC, AVR, 8051 |
| Passive | Resistors, Capacitors, Inductors |
| Semiconductors | Diodes, BJTs, MOSFETs |
| Digital ICs | Logic gates, Flip-flops, Counters, MUX |
| Display | LCD, 7-segment, LED matrix |
| Sensors | Temperature, LDR, PIR, Ultrasonic |
| Instruments | Oscilloscope, Voltmeter, Ammeter |
| Flip-Flop | Characteristic Equation | Excited Inputs |
|---|---|---|
| SR | \( Q_{next} = S + \overline{R}Q \) | S, R |
| D | \( Q_{next} = D \) | D |
| JK | \( Q_{next} = J\overline{Q} + \overline{K}Q \) | J, K |
| T | \( Q_{next} = T \oplus Q \) | T |
| Conversion | Required Logic |
|---|---|
| SR → JK | \( S = J\overline{Q} \), \( R = KQ \) |
| SR → D | \( S = D \), \( R = \overline{D} \) |
| JK → D | \( J = D \), \( K = \overline{D} \) |
| JK → T | \( J = T \), \( K = T \) |
| D → JK | \( D = J\overline{Q} + \overline{K}Q \) |
| Type | Input | Output | Application |
|---|---|---|---|
| SISO | Serial | Serial | Delay line |
| SIPO | Serial | Parallel | Serial-to-parallel |
| PISO | Parallel | Serial | Parallel-to-serial |
| PIPO | Parallel | Parallel | Data storage |
| Counter Type | Clock | Modulus | Notes |
|---|---|---|---|
| Ripple (async) | Only first FF | \( 2^n \) | Slow, ripple delay |
| Synchronous | All FFs | \( 2^n \) | Fast, no ripple |
| Mod-N | Either | N | Reset at N |
| Ring | All FFs | n | One-hot |
| Johnson | All FFs | 2n | Twisted ring |
| Function | Purpose |
|---|---|
pinMode(pin, mode) | Set pin as INPUT/OUTPUT |
digitalWrite(pin, value) | Write HIGH/LOW |
digitalRead(pin) | Read digital input |
analogRead(pin) | Read analog (0–1023) |
analogWrite(pin, value) | PWM output (0–255) |
delay(ms) | Wait milliseconds |
Serial.begin(baud) | Initialize serial |
Serial.println(data) | Print to serial monitor |
An SR latch has S = 1, R = 0. What is the next state if the current state is Q = 0? What if Q = 1?
Compare latches and flip-flops. Why is edge triggering preferred over level triggering?
A JK flip-flop has J = 1, K = 0, and current state Q = 0. Find the next state. Then, if J = 1, K = 1, find the next state.
Design a JK flip-flop using an SR flip-flop. Write the required logic expressions.
A 4-bit SIPO shift register initially contains 0000. The input sequence is 1, 0, 0, 1 (LSB first). Show the register contents after each clock.
Design a Mod-6 counter using JK flip-flops. Show the state table and reset logic.
Compare ring counter and Johnson counter. How many states does each have for 4 flip-flops?
An Arduino reads analog value 512 on pin A0. What is the measured voltage?
Write an Arduino sketch to read temperature from a DHT11 sensor and turn on an LED if the temperature exceeds 30°C.
Describe the architecture of an IoT-based temperature monitoring system using Arduino, DHT11, and a cloud platform.
When S = 1, R = 0, the latch is in the Set state.
Regardless of the current state (0 or 1), the next state will be Q = 1.
Latch: Level-triggered, transparent when enable is active, can have race-around.
Flip-Flop: Edge-triggered, samples input only at clock edge, no race-around.
Edge triggering is preferred because it provides predictable, synchronized operation and avoids the race-around condition that causes unreliable behavior in latches.
Case 1: J = 1, K = 0, Q = 0
\[ Q_{next} = J\overline{Q} + \overline{K}Q = 1 \cdot 1 + 1 \cdot 0 = 1 \]Next state: Q = 1 (Set).
Case 2: J = 1, K = 1, Q = 0
\[ Q_{next} = 1 \cdot 1 + 0 \cdot 0 = 1 \]Next state: Q = 1 (Toggle).
From the excitation table:
\[ S = J\overline{Q} \qquad R = KQ \]Connect AND gates between J and Q̄ (for S), and between K and Q (for R).
Input sequence (LSB first): 1, 0, 0, 1
| Clock | Input | FF₀ | FF₁ | FF₂ | FF₃ |
|---|---|---|---|---|---|
| 0 | — | 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 0 | 0 | 0 |
| 2 | 0 | 0 | 1 | 0 | 0 |
| 3 | 0 | 0 | 0 | 1 | 0 |
| 4 | 1 | 1 | 0 | 0 | 1 |
After 4 clocks: parallel outputs Q₀Q₁Q₂Q₃ = 1001.
Flip-flops needed: \( n = \lceil \log_2 6 \rceil = 3 \).
State sequence: 000 → 001 → 010 → 011 → 100 → 101 → (110 resets)
Reset logic: When Q₂ Q₁ Q₀ = 110, reset all flip-flops.
Reset condition: \( \text{Reset} = Q_2 \cdot Q_1 \cdot \overline{Q_0} \)
This signal is applied to the active-low clear input of the JK flip-flops.
| Feature | Ring Counter | Johnson Counter |
|---|---|---|
| States for 4 FFs | 4 | 8 |
| Feedback | Q of last FF | Q̄ of last FF |
| Number of 1s | Exactly 1 | Multiple |
| Encoding | One-hot | Progressive |
Approximately 2.5 V.
#include <DHT.h>
#define DHTPIN 2
#define DHTTYPE DHT11
#define LED_PIN 9
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
dht.begin();
pinMode(LED_PIN, OUTPUT);
}
void loop() {
float t = dht.readTemperature();
if (isnan(t)) {
Serial.println("Sensor error!");
return;
}
if (t > 30.0) {
digitalWrite(LED_PIN, HIGH);
} else {
digitalWrite(LED_PIN, LOW);
}
delay(2000);
}
Components: Arduino + DHT11 + ESP8266 (or NodeMCU) + Cloud
| Ref | Title | Author | Publisher |
|---|---|---|---|
| T-1 | Principles of Electronics | V. K. Mehta and Rohit Mehta | S. Chand & Company |
| R-1 | Electronic Devices and Circuit Theory | Robert L. Boylestad and Louis Nashelsky | Pearson Education India |
| R-2 | Digital Fundamentals | Thomas L. Floyd | Pearson Education India |
| Ref | Web Address | Feature |
|---|---|---|
| RW-6 | electronicsforu.com/technology-trends/learn-electronics/flip-flop-rs-jk-t-d | Flip-flop |
| RW-7 | testbook.com/electrical-engineering/asynchronous-counters | Asynchronous counter (UP/DOWN/Mod-N) |
| Ref | Topic |
|---|---|
| AV-7 | Operation of basic shift registers (SISO, SIPO, PISO, PIPO) |
| AV-8 | DHT11/DHT22 |
| Ref | Tool | Purpose |
|---|---|---|
| SW-1 | Proteus | Circuit simulation |
| SW-2 | Arduino IDE | Arduino programming |
| SW-3 | Arduino sensors libraries | DHT, LCD, etc. |
| CO | Description | Sections Covered |
|---|---|---|
| CO5 | Analyze the characteristics and operation of sequential logic circuits | I, II, III, IV, V, VI, VII, VIII, IX, X |
| CO6 | Demonstrate Arduino programming and sensor interfacing | XI, XII, XIII, XIV, XV, XVI |
Sequential Logic · Flip-Flops · Shift Registers · Counters · Arduino Programming · Sensors · IoT
PHY 175 · Modern Physics and Electronics
Complete · Exam-Ready · Full Marks Guaranteed