Create a complete, highly interactive p5.js simulation demonstrating: pendulum

CRITICAL REQUIREMENTS:
1. ACCURACY: The simulation must be scientifically/mathematically accurate for pendulum
2. FUNCTIONAL INTERACTIVITY: All sliders and buttons MUST actually control and modify the simulation behavior in real-time
3. EDUCATIONAL: Users should learn about pendulum through experimentation and parameter manipulation

MANDATORY INTERACTIVE ELEMENTS THAT MUST WORK:
- At least 4-6 sliders controlling key parameters with realistic ranges - these MUST change simulation behavior
- At least 3-4 buttons for actions (reset, pause/play, presets, etc.) - these MUST perform actual functions
- Real-time parameter display showing current values that update as sliders move
- Visual feedback that responds immediately and visibly to control changes
- Mouse interactions where physically meaningful

CRITICAL: CONTROLS MUST BE FUNCTIONAL, NOT DECORATIVE
- Every slider must control a variable that actively affects the simulation
- Every button must perform a meaningful action that changes the simulation state
- Parameter changes must be immediately visible in the simulation output
- Use the actual slider values in mathematical calculations and physics equations

CONTROL IMPLEMENTATION REQUIREMENTS:
- Sliders: Use createSlider(min, max, default, step) with appropriate ranges
- Buttons: Use createButton('Label') with meaningful functions that actually execute
- Position controls below canvas using .position(x, y)
- Show parameter values with text() in the main canvas that update in real-time
- Use function declarations for event handlers: function resetSim() {} 
- ALWAYS use slider.value() in your calculations - never ignore slider inputs

CODE FORMAT REQUIREMENTS:
- Use GLOBAL MODE p5.js (NOT instance mode)
- Define setup() and draw() as regular functions
- All variables should be global (use let/var at top level)
- Use standard p5.js function names: createCanvas, background, fill, etc.
- NO sketch wrapper function - write direct p5.js code

SIMULATION ACCURACY FOR PENDULUM:
- Use correct physics equations, mathematical relationships, or algorithmic principles
- Realistic parameter ranges and default values that make physical sense
- Smooth, continuous animations at 60fps
- Proper scaling and units where applicable
- Include scientific constants or realistic coefficients
- ENSURE every parameter controlled by sliders affects the simulation visibly

VISUAL REQUIREMENTS:
- Clear, educational visualization of the concept
- Multiple visual elements (trails, vectors, measurements, etc.)
- Color coding to distinguish different aspects
- Grid lines, axes, or reference markers where helpful
- Immediate and obvious visual response to parameter changes

EXAMPLE OF FUNCTIONAL CONTROLS:
```javascript
// Global variables that ACTUALLY affect simulation
let gravitySlider, dampingSlider;
let gravity = 0.5;  // This gets updated by slider
let damping = 0.99; // This gets updated by slider
let resetBtn, pauseBtn;
let isPaused = false;

function setup() {
  createCanvas(400, 400);
  
  // Create sliders that CONTROL the simulation
  gravitySlider = createSlider(0.1, 2.0, 0.5, 0.1);
  gravitySlider.position(10, height + 10);
  
  dampingSlider = createSlider(0.9, 1.0, 0.99, 0.01);
  dampingSlider.position(10, height + 40);
  
  // Create buttons that DO something
  resetBtn = createButton('Reset');
  resetBtn.position(200, height + 10);
  resetBtn.mousePressed(resetSimulation);
  
  pauseBtn = createButton('Pause/Play');
  pauseBtn.position(200, height + 40);
  pauseBtn.mousePressed(togglePause);
}

function draw() {
  background(220);
  
  // ACTUALLY USE the slider values - this is critical!
  gravity = gravitySlider.value();
  damping = dampingSlider.value();
  
  if (!isPaused) {
    // Use gravity and damping in actual physics calculations
    velocity += gravity;
    velocity *= damping;
    position += velocity;
  }
  
  // Show parameter values that update in real-time
  fill(0);
  text('Gravity: ' + gravity.toFixed(2), 10, 20);
  text('Damping: ' + damping.toFixed(2), 10, 40);
  
  // Draw simulation that responds to parameters
  ellipse(position, height/2, 20, 20);
}

// Functions that actually work
function resetSimulation() {
  position = 0;
  velocity = 0;
}

function togglePause() {
  isPaused = !isPaused;
}
```

IMPORTANT: 
- Focus on the specific physics, mathematics, or principles of pendulum
- Make controls that ACTUALLY matter for understanding the concept
- Every slider must control a variable used in the simulation
- Every button must perform a visible action
- Ensure the simulation behaves realistically and responds to all controls
- Only output JavaScript code, no explanations
- Use global mode p5.js format (no sketch wrapper)
- Position controls below the 400x400 canvas

Generate an accurate, interactive simulation of: pendulum with WORKING controls