Skip to content

notes to self

a document of a plodding mind

Menu
Menu

Arduino: the oBITerator

Posted on October 20, 2011March 6, 2012 by abram

this was a short experiment where i wanted to see how analog AC signals from a guitar were received and converted to digital signals by the ATMEGA328. to “hear” the results along with seeing the numbers as i plucked the strings, i combined digitalWrite() and the tone() functions to output on the same pin giving it a broken-video-game effect just for fun. overall, pretty useless, but the idea of extrapolating the tonal frequency from the input voltage (or at least getting close by using an array of predefined tonal constants) seems feasible enough.

here’s a bit of the code i was using.

const int inputPin = 2;
const int outputPin = 10;

void setup() {
  Serial.begin(9600);
  pinMode(outputPin, OUTPUT);
  pinMode(inputPin, INPUT);
}

void loop() {
  Serial.println(analogRead(inputPin));
  int frequency = map(analogRead(inputPin), 0, 1023, 82.4, 5000);
  int duration = map(analogRead(inputPin), 0, 1023, 0, 1000);
  if(duration != 0) {
    digitalWrite(outputPin, analogRead(inputPin));
    tone(outputPin, frequency, duration);
  }
  delay(duration);
}

Leave a Reply Cancel reply

You must be logged in to post a comment.

about

Abram Morphew is an electrical engineer, bedroom musician, composer, naturalist, and amateur scientist. I play music in the the binary marketing show. This blog is a catalog of stuff that I make or bits of information that I think could prove useful later on when memory fails me.

 

I currently hold an Extra Class Amateur Radio Operator license and transmit on the air as K2NXF.

Tags

40m amp amplifier Arduino atmega328 atmel audio bash bjt breadboard circuit code cw delay digital effect effects electrical electronics homebrew lfo linux LM386 mellotronium music no. 5 opamp oscillator pcb pedal photos php pt2399 pwm radio rf schematic stereo stompbox synth tape TDA2040 tl072 TL082 tube

Social

  • Instagram
  • LinkedIn

Space Weather


© 2026 notes to self | Powered by Minimalist Blog WordPress Theme