Controlling On/Off Speed, PWM, and Weight.


i'm trying make pseudo granular on/off tremolo effect audio signal.

at moment i'm using npn transistor switch, , led indicate status.

i should mention i'm new arduino-ing, using example code , trying mess things.

i managed pot control rate of on/off , managed scale values useful range, i'm stuck on how implement other features want.

i'd able control pwm(duty cycle?) of led. if analogread 1023 led on. , @ 0, flash tiny tiny blip @ rate set the.... rate.

not sure if pwm right term in application.

what kind of changes have make code below implement that? define new variable, make on/off times dependent on it?

eventually want implement random control, doesn't turn on/off regularly, rather, based on value read pot, either:
max clockwise : led on
middle : on/off 50% of time
counterclock : led off.

but based on random on/off. 'weight' type value. higher 'weight' more led on (though still random), , lower weight, less led on.

i know these lot of questions, , specific/particular ones. don't want give me code work, enjoy figuring things out. i'm stuck how such things done @ in code.


code: [select]
int sensorpin = 2;
int ledpin = 0;
int sensorvalue = 0;

void setup() {
 pinmode(ledpin, output);
}
void loop() {
  sensorvalue = analogread(sensorpin);
  sensorvalue = map(sensorvalue, 0, 1023, 20, 500);
  digitalwrite(ledpin, high);
  delay(sensorvalue);
  digitalwrite(ledpin, low);
  delay(sensorvalue);
}

i intend change frequency of output, going off, pulsing @ 10% on duty cycle, ramp frequency , bring 10% on pulses closer together, need increase on time approach 100% on.  this complex transfer function few different states it.

it's possible, works better interrupts when trying read in, , output time domain based.  especially if audio, because it's easy audibly hear glitches , errors in code timing.

if can define input output transfer function can try to you.

like this:

analog input = 0-1%, digital output = 100% off (deadband)
analog input = 0-20%, digital output = 100% off 10% on @ 1khz
analog input = 20-80%, digital output = 10% on 1 10khz
analog input = 80-99%, digital output = 10% on 100% on @ 10khz
analog input = 99-100%, digital output = 100% on (deadband)


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > Controlling On/Off Speed, PWM, and Weight.


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums