This programming gets an analog voltage output;
double a;
double b;
double v;
void setup() {
pinMode(11, OUTPUT);
Serial.begin(9600);
}
void loop() {
v=2.433;
a= ((v-.2955)/.107375);
b=(40-a);
digitalWrite(11, HIGH);
delayMicroseconds(a);
digitalWrite(11, LOW);
delayMicroseconds(b);
}
This shows that delay will accept a variable which one of your contributors was doubtful of as was I. However when I add more programming in the loop to determine the value of 'v', I just get a few millivolts output. Can anybody suggest how I can fix this? Could it be that the program spends too much time on the extra programming to do the pwm to analog conversion?
If I can't fix it I will use a digital to analog ic meaning more hardware.
I can include the complete sketch if desired. There must be something there stopping it working. Let me know.
double a;
double b;
double v;
void setup() {
pinMode(11, OUTPUT);
Serial.begin(9600);
}
void loop() {
v=2.433;
a= ((v-.2955)/.107375);
b=(40-a);
digitalWrite(11, HIGH);
delayMicroseconds(a);
digitalWrite(11, LOW);
delayMicroseconds(b);
}
This shows that delay will accept a variable which one of your contributors was doubtful of as was I. However when I add more programming in the loop to determine the value of 'v', I just get a few millivolts output. Can anybody suggest how I can fix this? Could it be that the program spends too much time on the extra programming to do the pwm to analog conversion?
If I can't fix it I will use a digital to analog ic meaning more hardware.
I can include the complete sketch if desired. There must be something there stopping it working. Let me know.
Last edited: