Skip to content

FAQ hub / Coding

Coding frequently asked questions

Sketch structure, blink patterns, binary counters and PWM in real Arduino examples.

Frequently asked questions

9 answers, each linked to the guide it comes from.

What does this circuit do?

Increment a counter on every button press and show the number's binary equivalent on two LEDs.

Source: Button Counter with LED Display

How does the circuit work?

The input pin is held connected to the supply voltage through the internal pull-up resistor; when the button is pressed, the pin is pulled to ground and reads LOW. The software increments the counter at the moment the pin goes from HIGH to LOW; holding the button down does not make the value keep increasing. The counter value is displayed on two LEDs in binary form: the low bit is connected to the first LED and the high bit to the second. The values 0, 1, 2 and 3 correspond to four different on-off combinations of the LEDs. The 220-ohm resistors limit the current through each LED. This circuit teaches basic counter logic by combining state-change detection with binary number display.

Source: Button Counter with LED Display

What is the expected result?

The counter increments on every button press and the two LEDs show the binary equivalent.

Source: Button Counter with LED Display

What does this circuit do?

Create a chasing-light effect by lighting four LEDs in turn forwards and backwards.

Source: Sequential Blinking LEDs

How does the circuit work?

The code holds the output pins in an array and moves forward through the array, setting each pin HIGH briefly. The delay at the end of each step lets the human eye perceive the light separately. Reversing the array repeats the same sequence backwards, producing the chasing-light effect. In hardware, each LED is driven by its own 220-ohm resistor, which keeps the current safe even when several LEDs are on at once. The common-cathode connection gives all LEDs the same reference point and lets the circuit be expanded without complication.

Source: Sequential Blinking LEDs

What is the expected result?

The LEDs light up and go out in forward and reverse order, creating a chasing-light effect.

Source: Sequential Blinking LEDs

Is PWM the same as an analogue output?

No. It is a digital signal switched fast enough that the average looks analogue to a slow load such as an LED.

Source: PWM dimming: fade an LED with Arduino

Why does my LED flicker on camera?

The camera shutter samples individual pulses. Slow the switching or use a longer exposure to reduce banding.

Source: PWM dimming: fade an LED with Arduino

Can I dim a servo or a motor this way?

A servo expects a specific 50 Hz pulse width, not a generic duty cycle. A DC motor can be speed-controlled with PWM through a suitable driver.

Source: PWM dimming: fade an LED with Arduino

How to use these answers

Three short steps.

  1. Find your symptom
    Open the question that matches what you see on your board or in your sketch.
  2. Read the short answer
    Each answer gives the most likely cause first, then the check that confirms it.
  3. Open the full guide
    Follow the source link under the answer for the complete circuit and code.

Related guides

Five real pages to continue from here.

Keep your progress in one place

Create a free account to save what you are working on and see your results.