I have set up a single pulse (width of ~400 ms) using the burst feature on the Tektronix AFG3102 function generator and I want to transfer this signal to the digital pin of Arduino UNO. Essentially I want to continuously (in a loop) perform reading on pin 7 using the built-in digitalread() function. So I'm expecting to see 0 when I did not trigger the signal and 1 when I trigger the signal for a duration of 400 ms and then back to 0. However, this is not the case here as I'm just reading 0s even though I trigger my signal. Interestingly when I change the width of the pulse to 1ms I can see the signal coming through, but It does seem to work with 400 ms.
I have placed my code here for your review. I would highly appreciate some help on this.
void setup() {
Serial.begin(9600); // start serial for output
pinMode(7,INPUT);
}
void loop() {
Serial.println(digitalRead(7));
Serial.print('\n');
}
Thank you,
Nikan
loop()
, like 50ms, and/or increasing the baudrate to something like 115200?Serial.print('\n');
, asSerial.println()
already adds"\r\n"
. @chrisl: Filling the serial buffer should be no issue: it justs adds a small latency (< 7 ms) to the transmitted data.