Hello,
I normally can use analogwrite() to give a voltage output 0-5V, but I need to record on a campbell scientific 3000 datalogger, which samples much faster than what I am used to. Instead of an average PWM voltage, the datalogger records the voltage of each and every high and low in the pulse, so essentially it just reads 0 or 5V and nothing in between. What the datalogger CAN do is read the distance between those pulses if at 50% duty cycle. So, I am wondering if there is a way to use Tone() to output a 50% duty cycle PWM? Below is a sample of my code.
int zerov = 35; //Minimum freq of Uno Hz + 13100
int onev = 13135;
int twov = 26235;
int threev = 39335;
int fourv = 52435;
int fivev = 65535; // Max Freq of Uno Hz
int melody[] = {
zerov, onev, twov, threev, fourv, fivev
};
int noteDurations[] = {
5,5,5,5,5
};
void setup() {
}
void loop() {
// iterate over the notes of the melody:
for (int thisNote = 1; thisNote < 6; thisNote++) {
int noteDuration = 1000 / noteDurations[thisNote];
tone(9, melody[thisNote], noteDuration);
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
// stop the tone playing:
noTone(8);
}
}
Right now, I am getting nothing out of the Uno, but when I do analogWrite from 0-255, I can get 0-5V fine, but only on my multimeter, not the datalogger.
Any ideas on using tone to output voltage at 50% duty cycle?
Thank you.