FAQ hub / Coding
Coding frequently asked questions
Sketch structure, blink patterns, binary counters and PWM in real Arduino examples.
- 9real questions
- 3source guides
- 5related pages
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.
Why does my LED flicker on camera?
The camera shutter samples individual pulses. Slow the switching or use a longer exposure to reduce banding.
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.
How to use these answers
Three short steps.
- Find your symptom
Open the question that matches what you see on your board or in your sketch. - Read the short answer
Each answer gives the most likely cause first, then the check that confirms it. - 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.
-
Guide
Button Counter with LED Display
Count button presses on Arduino and display 0-3 in binary on two LEDs. Learn state-change detection and binary output wiring. With tips.
-
Guide
Sequential Blinking LEDs
Create a chasing-light effect with four LEDs driven forwards and backwards from Arduino. Learn arrays, delays and common cathodes. With tips.
-
Guide
PWM dimming: fade an LED with Arduino
Understand PWM dimming on Arduino: duty cycle, the analogWrite 0-255 range, which pins support PWM, a fade sketch and the wiring needed to drive an LE
-
Guide
Code won't compile? Read the first error
A wall of compiler errors is usually one small mistake repeated. Read the first message, fix it, then compile again.
-
Guide
Serial monitor empty? Match the baud rate and port
No text in the serial monitor? Check baud rate, port selection and whether Serial.begin actually ran before you print.
Keep your progress in one place
Create a free account to save what you are working on and see your results.