edge lab LIVE! starts Tuesday in Munich. Grab a workshop seat and take home the board you build on. Code FRIEND-HACKSTER saves 20%. () Learn more!
Bradley Freedman
Published © CC BY-NC

Tracker Movie Prop

It’s a little device that beeps and lights up faster when you turn the potentiometer

BeginnerShowcase (no instructions)2 hours19
Tracker Movie Prop

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Buzzer, Piezo
Buzzer, Piezo
×1
LED (generic)
LED (generic)
×1
Resistor 330 ohm
Resistor 330 ohm
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

schematics

Code

Code

Python
For project
// Potentiometer-controlled LED + Piezo
// Pot wiper → A0
// LED (+ 220Ω resistor) → Pin 9
// Piezo (+) → Pin 8


const int POT_PIN   = A2;
const int LED_PIN   = 8;
const int PIEZO_PIN = 6;


// Blink/beep interval range (ms)
const int MIN_INTERVAL = 50;   // fastest (pot at max)
const int MAX_INTERVAL = 1000; // slowest (pot at min)


void setup() {
  pinMode(LED_PIN, OUTPUT);
  pinMode(PIEZO_PIN, OUTPUT);
}


void loop() {
  int potVal  = analogRead(POT_PIN);           // 0–1023
  int interval = map(potVal, 0, 1023, MAX_INTERVAL, MIN_INTERVAL);


  // Flash LED
  digitalWrite(LED_PIN, HIGH);


  // Beep piezo (frequency also rises with pot)
  int freq = map(potVal, 0, 1023, 200, 2000);
  tone(PIEZO_PIN, freq, interval / 2);         // beep for half the interval


  delay(interval / 2);


  // Off phase
  digitalWrite(LED_PIN, LOW);
  noTone(PIEZO_PIN);


  delay(interval / 2);
}

Credits

Bradley Freedman
1 project • 0 followers

Comments