This is what I have now, the function of the potmeter has to be replaced by a piece of code to regulate the delay.
int brightness = 0; // how bright the LED is
int fadeAmount = 10; // how many points to fade the LED by
int sensorValue = 0;
int outputValue =0;
//const int analogInPin = A0; // make frequency controlled by potmetervoid setup() {
// declare pin 9 to be an output:pinMode(9, OUTPUT);
Serial.begin(9600);
}void loop() {
//sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
//outputValue = map(sensorValue, 0, 1023, 200, 1600);Serial.println("1");
while(brightness >= 0) {
// set the brightness of pin 9:
analogWrite(9, brightness);//Serial.println("kjklo");
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;// reverse the direction of the fading at the ends of the fade:
if (brightness == 230) {
fadeAmount = -fadeAmount ;
}
// wait for 30 milliseconds to see the dimming effectdelay(1);
}//delay(100);
brightness = 0;
fadeAmount = 10;while(brightness >= 0) {
// set the brightness of pin 9:
analogWrite(9, brightness);//Serial.println("dd");
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;// reverse the direction of the fading at the ends of the fade:
if (brightness == 150) {
fadeAmount = -fadeAmount ;
}
// wait for 30 milliseconds to see the dimming effect
delay(5);
}fadeAmount = 10;
brightness = 0;
delay(outputValue); //variable output from potmeter
Serial.println(outputValue);
}