Go Down

Topic: Expanding on Project 6 - Light Theremin: Where to start? (Read 5996 times) previous topic - next topic

preshock

Hi there. On the page for Project 6's step by step guide, the text has a few sentences for users to think about and it mentions adding a potentiometer into the circuit.

1. How would I go about that? a. Do I have to change or add anything into the code?
2. I played around it a bit and added the potentiometer in series with the circuit (did not add anything to the code in the book) but not sure if I'm doing it right... The phototransistor is connected to A0 and I connected A0 to the potentiometer's ground pin via jump wire.

I'm thinking the potentiometer could control volume while the phototransistor changes the noises the piezo is making, making the whole project more similar to an actual theremin.

Total newb here, though I have a basic grasp of coding and electronics. Really interested in the idea of a theremin, so wanted to expand on that a bit. Any thoughts or comments appreciated.

Here's the code from the book, if it helps:

Code: [Select]
int sensorValue;
int sensorLow = 1023;
int sensorHigh = 0;
const int ledPin = 13;

void setup() {
  // put your setup code here, to run once:
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, HIGH);
  while (millis() < 5000) {
  sensorValue = analogRead(A0);
  if (sensorValue > sensorHigh) {
    sensorHigh = sensorValue;
    }
  if (sensorValue < sensorLow) {
      sensorLow = sensorValue;
    }
  }

  digitalWrite(ledPin, LOW);
}

void loop() {
  // put your main code here, to run repeatedly:
  sensorValue = analogRead(A0);
  int pitch = map(sensorValue, sensorLow, sensorHigh, 50, 4000);

  tone(8,pitch,20);

  delay(10);
}

Go Up