I have written a simple Arduino sketch, that shall produce a clock signal.

Here is the code:

void setup() {
  // put your setup code here, to run once:


void loop() {
  // put your main code here, to run repeatedly:

Namely the pin 8 of Arduino Uno is periodicaly set to HIGH and LOW.

The output that I receive, for three different frequencies, is:

enter image description here

enter image description here

enter image description here

My question is: Why is falling edge not as sharp as rising edge? As can be noted, for high frequencies the signal wouldn't go to LOW after all.

  • Is this your demonstration of what you're calling, "high frequency"? Because this does look like it's going LOW but as you pointed out, it's not as sudden as it going HIGH. Have you also reviewed what the datasheet says about your particular Arduino Uno?
    – user23244
    Commented Sep 24, 2018 at 15:05
  • 2
    I don't know the details of Arduino hardware, but don't you need to explicitly configure pin 8 to be an output in your setup() function? It looks like you're just enabling/disabling a pullup by default.
    – Dave Tweed
    Commented Sep 24, 2018 at 15:05
  • @DaveTweed No, it appears that the problem is the OP hasn't declared pin 8 as output.
    – Long Pham
    Commented Sep 24, 2018 at 15:11
  • @DaveTweed Indeed, declaring a pin as output, produced a nice square wave. Can you please elaborate on reasons behind this (e.g. what you mean by enabling/disabling a pullup by default) and that would be answer to this question.
    – balboa
    Commented Sep 24, 2018 at 15:12

1 Answer 1


The pin is not configured as OUTPUT.

By default, all of the GPIO pins on pretty much any microcontroller are configured as inputs following reset. This prevents the chip from "fighting" an external device that might be driving any of those pins before the firmware has had a chance to configure the GPIO correctly.

On the MCU used on the Arduino, the output latch controls the state of an internal pullup resistor when the pin is configured as an input. Your code was simply enabling and disabling this resistor. When you set the pin low, it makes the pin open-circuit, and you see a slow decay of voltage through your oscilloscope probe.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.