Community project

CPU Scheduling Control Panel

Photo of CPU Scheduling Control Panel
Generated with AI

Sam

Published December 2, 2026

This CPU scheduling control panel simulates six different process scheduling algorithms on an ESP32 microcontroller. The project demonstrates FCFS, SJF, SRTF, priority-based, and round-robin scheduling with real-time visualization of process execution states.

The guide provides a complete wiring diagram, parts list, and step-by-step assembly instructions for connecting the OLED display, potentiometer for mode selection, push buttons for control, and five indicator LEDs representing active processes. Builders will also receive the complete firmware to load onto the ESP32, enabling interactive exploration of how different scheduling algorithms handle process queues and execution timing.

Wiring diagram

Wiring diagram for CPU Scheduling Control Panel
Loading diagram…

Gather all the parts

QtyComponent
1

SSD1306 OLED

0.96-inch 128 x 64 white monochrome OLED display module driven by an SSD1306 controller over I2C (address 0x3C). It runs from 3 V to 5 V and connects through a 4-pin 2.54 mm header (GND, VCC, SCL, SDA); the self-emitting pixels need no backlight.

1

Resistor

330 Ω

Through-hole resistor (current-limiting in series with an LED)

1

LED

Green 5 mm

Standard 3mm/5mm through-hole LED. A current-limiting series resistor is added automatically.

1

Resistor

330 Ω

Through-hole resistor (current-limiting in series with an LED)

1

LED

Green 5 mm

Standard 3mm/5mm through-hole LED. A current-limiting series resistor is added automatically.

1

Resistor

330 Ω

Through-hole resistor (current-limiting in series with an LED)

1

LED

Green 5 mm

Standard 3mm/5mm through-hole LED. A current-limiting series resistor is added automatically.

1

Resistor

330 Ω

Through-hole resistor (current-limiting in series with an LED)

1

LED

Green 5 mm

Standard 3mm/5mm through-hole LED. A current-limiting series resistor is added automatically.

1

Resistor

330 Ω

Through-hole resistor (current-limiting in series with an LED)

1

LED

Green 5 mm

Standard 3mm/5mm through-hole LED. A current-limiting series resistor is added automatically.

1

10kΩ Potentiometer

10 kΩ linear (B10K) rotary potentiometer in the common 16 mm panel style: metal can, M7 threaded bushing for mounting through a panel, a 6 mm knurled split shaft for push-on knobs, and three PCB pins in a row 5 mm apart. Connect the outer pins across 3.3 V or 5 V and ground; the middle wiper pin then gives an adjustable voltage for an ADC input over about 300° of rotation.

1

Push Button

Momentary push button switch

1

Push Button

Momentary push button switch

1

Push Button

Momentary push button switch

1

Push Button

Momentary push button switch

Assemble it in 4 steps

1. Lay out the four panel sections

With USB unplugged, put the OLED at top left and the algorithm knob at top right. Leave a separate horizontal row for P1–P5 and a bottom row for START, PAUSE, STEP and RESET. Print those labels on the faceplate. Leave clearance behind the controls and keep the ESP32 USB port accessible.

2. Wire the display and knob

Connect both VCC pins to 3V3 and both GND pins to GND. Connect OLED SDA to GPIO21 (data), SCL to GPIO22 (clock), and knob WIPER to GPIO32 (position). Mark the six positions in order: FCFS, SJF, SRTF, Priority Non-preemptive, Priority Preemptive, Round Robin. Confirm the marks against the OLED before fixing them in place.

3. Wire the process lights

Route GPIO18, 19, 23, 25 and 26 through R1–R5 respectively to the long legs of P1–P5. Join the short legs to GND. Keep one 330-ohm resistor per light.

4. Wire the control buttons

Connect one contact from each button to GND. Connect the other contact of START, PAUSE, STEP and RESET to GPIO13, 14, 27 and 33 respectively. Run the ground wires along the edge and keep signal runs separated and labelled.

Review all connections

1. Connections between "STATUS" and "ESP32"

FunctionSTATUSESP32
powerVCC3V3
groundGNDGND
i2cSDAGPIO 21
i2cSCLGPIO 22

2. Connections between "R1" and "ESP32"

FunctionR1ESP32
digitalP1GPIO 18
digitalP2 → LED ANODEEXT

3. Connections between "P1" and "ESP32"

FunctionP1ESP32
groundGNDGND

4. Connections between "R2" and "ESP32"

FunctionR2ESP32
digitalP1GPIO 19
digitalP2 → LED ANODEEXT

5. Connections between "P2" and "ESP32"

FunctionP2ESP32
groundGNDGND

6. Connections between "R3" and "ESP32"

FunctionR3ESP32
digitalP1GPIO 23
digitalP2 → LED ANODEEXT

7. Connections between "P3" and "ESP32"

FunctionP3ESP32
groundGNDGND

8. Connections between "R4" and "ESP32"

FunctionR4ESP32
digitalP1GPIO 25
digitalP2 → LED ANODEEXT

9. Connections between "P4" and "ESP32"

FunctionP4ESP32
groundGNDGND

10. Connections between "R5" and "ESP32"

FunctionR5ESP32
digitalP1GPIO 26
digitalP2 → LED ANODEEXT

11. Connections between "P5" and "ESP32"

FunctionP5ESP32
groundGNDGND

12. Connections between "ALGORITHM" and "ESP32"

FunctionALGORITHMESP32
powerVCC3V3
groundGNDGND
adcWIPERGPIO 32

13. Connections between "START" and "ESP32"

FunctionSTARTESP32
digitalSIGNALGPIO 13
groundGNDGND

14. Connections between "PAUSE" and "ESP32"

FunctionPAUSEESP32
digitalSIGNALGPIO 14
groundGNDGND

15. Connections between "STEP" and "ESP32"

FunctionSTEPESP32
digitalSIGNALGPIO 27
groundGNDGND

16. Connections between "RESET" and "ESP32"

FunctionRESETESP32
digitalSIGNALGPIO 33
groundGNDGND

Deploy the firmware

#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_SSD1306.h>

constexpr int N=5, Q=2;
constexpr int arrival[N]={1,2,3,7,10}, burst[N]={7,4,1,5,2}, priority[N]={4,2,1,3,2};
constexpr int led[N]={18,19,23,25,26};
const char* names[]={"FCFS","SJF","SRTF","PRIORITY NON-PREEMPT","PRIORITY PREEMPTIVE","ROUND ROBIN (Q=2)"};
Adafruit_SSD1306 screen(128,64,&Wire,-1);
struct Button {
  int pin;
  bool raw=false, stable=false;
  uint32_t changed=0;
  bool pressed(uint32_t now){
    bool sample=digitalRead(pin)==LOW;
    if(sample!=raw){raw=sample;changed=now;}
    if(stable!=raw && now-changed>=25){stable=raw;return stable;}
    return false;
  }
};
Button keys[]={{13},{14},{27},{33}};
enum State {Ready,Running,Paused,Done};
State state=Ready;
int mode=0, candidate=0, t=0, left[N], active=-1, shown=-1;
int fifo[N], head=0, count=0, slice=0;
uint32_t selectionSince=0, lastTick=0;
bool dirty=true, displayOK=false;

void resetRun(){
  for(int i=0;i<N;i++)left[i]=burst[i];
  t=0; active=shown=-1; head=count=slice=0; state=Ready; dirty=true;
}
void enqueue(int i){fifo[(head+count)%N]=i; ++count;}
int rankOf(int i){
  if(mode==1)return burst[i];
  if(mode==2)return left[i];
  if(mode==3 || mode==4)return priority[i];
  return arrival[i];
}
void tick(){
  if(mode==5){
    // Arrivals at this boundary enter before a process whose quantum expired.
    for(int i=0;i<N;i++)if(arrival[i]==t)enqueue(i);
    if(active>=0 && slice==Q){enqueue(active);active=-1;}
    if(active<0 && count){active=fifo[head];head=(head+1)%N;--count;slice=0;}
  } else if(active<0 || mode==2 || mode==4){
    // A preemptive policy keeps the current process on equal rank.
    for(int i=0;i<N;i++)if(left[i] && arrival[i]<=t){
      if(active<0 || rankOf(i)<rankOf(active))active=i;
    }
  }
  shown=active;
  if(active>=0){
    ++slice;
    if(--left[active]==0)active=-1;
  }
  ++t;
  bool done=true;
  for(int n:left)if(n)done=false;
  if(done){state=Done;shown=-1;}
  dirty=true;
}
void render(){
  dirty=false;
  for(int i=0;i<N;i++)digitalWrite(led[i],i==shown && (state==Paused || state==Running));
  if(!displayOK)return;
  const char* states[]={"READY","RUNNING","PAUSED","COMPLETE"};
  screen.clearDisplay();screen.setTextColor(SSD1306_WHITE);screen.setTextWrap(false);
  screen.setTextSize(1);screen.setCursor(0,0);screen.print(names[mode]);
  screen.drawFastHLine(0,10,128,SSD1306_WHITE);
  screen.setCursor(0,16);screen.setTextSize(2);
  screen.print("T=");screen.print(t);screen.print("  ");
  if(shown<0)screen.print("--");else {screen.print('P');screen.print(shown+1);}
  screen.setTextSize(1);screen.setCursor(0,38);
  screen.print("CPU: ");screen.print(state==Paused ? "HELD" : shown<0 ? "IDLE" : "BUSY");
  screen.setCursor(0,53);screen.print("STATE: ");screen.print(states[state]);screen.display();
}
int selector(int previous){
  int sum=0;for(int i=0;i<8;i++)sum+=analogRead(32);
  int raw=sum/8;
  if(previous>=0 && raw>=previous*4096/6-50 && raw<(previous+1)*4096/6+50)return previous;
  return raw*6/4096;
}
void setup(){
  for(int p:led){pinMode(p,OUTPUT);digitalWrite(p,LOW);}
  for(auto &key:keys)pinMode(key.pin,INPUT_PULLUP);
  analogReadResolution(12);
  Wire.begin(21,22);
  displayOK=screen.begin(SSD1306_SWITCHCAPVCC,0x3C,false,false);
  mode=candidate=selector(-1);resetRun();
}
void loop(){
  uint32_t now=millis();
  int next=selector(candidate);
  if(next!=candidate){candidate=next;selectionSince=now;}
  if(candidate!=mode && now-selectionSince>=120){mode=candidate;resetRun();}
  bool start=keys[0].pressed(now), pause=keys[1].pressed(now);
  bool step=keys[2].pressed(now), reset=keys[3].pressed(now);
  if(reset)resetRun();
  else if(pause && state==Running){state=Paused;dirty=true;}
  else if(step && (state==Ready || state==Paused)){state=Paused;tick();}
  else if(start && state!=Running){if(state==Done)resetRun();state=Running;lastTick=now;dirty=true;}
  if(state==Running && now-lastTick>=700){lastTick=now;tick();}
  if(dirty)render();
  delay(3);
}

Remix this project

Make it yours in one click

Open a full copy of this project in your own Schematik workspace, diagram, code, parts, and assembly steps included. Swap the sensor, add features, or redesign the whole thing with AI. The author's original stays untouched.

Open in Schematik