[sdiy] simple octave divider questions/in ARDUINO w CODE
dan snazelle
subjectivity at hotmail.com
Sat Feb 5 19:27:31 CET 2011
starting small, real small, with programming the Arduino, I am trying to figure out some things.
I have been playing around with the Arduino acting like a frequency division CHIP
SO I hooked up a 5volt square wave through a Cap to INPUT 0.
the question for me is whether or not I am using
1. the right output type
and
2. the right type of operator
I set up the code to label the input and output
and then I tried dividing the input by 4
this did not work (on the PWM pin) it seemed to simply decrease the volume
however on the non PWM pin out ( i tried pin 8) dividing by 2, 4, etc DEFINITELY put out a slower square wave but it only worked in some frequency ranged
I didnt have a scope hooked up at the time so I cant say yet how useful the pin 8 waveform will be for things like gates, etc
What I am trying to figure out is whether or not you CAN use the pwm pins for gate out, etc and if so, how do you control them?
here is my code :
//Dan Snazelle trying to make something work...BOOM CRASH BZZ BZZ
const int INPUT0= 0; // Analog in from 40106 square-wave osc
const int octaveout = 8; // Analog output pin that is divided down I am using this output right now but
//const int octaveout = 9; // Analog output pin that is divided down, you could use this line
int SQUARE = 0; // value read from the pot
int OCTAVE = 0; // value output to the output (analog out)
int DATA=0; //place to put the data from SQUARE
void setup() {
}
void loop() {
// read the analog in value and try to divide it down:
SQUARE= analogRead(INPUT0); //input 0
OCTAVE=map(SQUARE,0,1023,0, 255);
DATA=SQUARE/2; //i used data so i could keep track of which function contained manipulated data
analogWrite(octaveout, DATA);
// DATA IS FINAL OUTPUT...I have tried this coming out of pin 9 which is a PWM out and out of pin 8. It seems to
//actually work when I use pin 8. maybe changing frequency on PWM pins is not as easy as simply reading in and out and usign arithmetic?
}
More information about the Synth-diy
mailing list