18
votes
Accepted
What's the difference between analogWrite and digitalWrite?
digitalWrite will set the specified pin to one of two states - HIGH/LOW, which equate to 5v (3.3v on some boards) and ground respectively.
analogWrite can vary by the type of output used.
If applied ...
9
votes
What's the difference between analogWrite and digitalWrite?
analogWrite(): The analogWrite() method sets the value of a PWM output pin. The analogWrite() is on a scale of 0 - 255, such that analogWrite(255) requests a 100% duty cycle (always on), and ...
8
votes
Accepted
Is it wise to use analog input pins to read digital buttons?
The Analog pins are essentially identical in functionality to digital pins when used as digital I/O.
If desired you could "be clever" and use an analog input in analog mode to read multiple keys ...
7
votes
Is there a way to play sounds from an Arduino without using a sound shield?
I helped someone with a similar question. The results are in my github repo at https://github.com/linhartr22/count. This example uses the PWM library and includes a reference to the article I used to ...
7
votes
What's the difference between analogWrite and digitalWrite?
digitalWrite sets the output pin to either LOW or HIGH (where those voltages depend on the Vcc of the processor. For a Uno or Mega that would be 0V or 5V (or close to it).
Here's a screenshot of ...
7
votes
Digital Pins Question
The digital pins of the Arduino are rated to reliably deliver up to
20 mA. Their absolute maximum rating is 40 mA. Anything
above that risks destroying the microcontroller.
If your device is supposed ...
6
votes
Accepted
Why are pin 18 and 19 always HIGH?
The analog pins function as digital pins number 14 - 19, with 14 being A0 and 19 being A5. I had hooked it up backwards.
This time we're gonna get funky
Everybody check your pins
Check check check ...
6
votes
Accepted
digitalRead keeps giving 1
You have set Pin 2 to HIGH, which is 5V. You have set Pin 4 to INPUT_PULLUP, which means if no signal is driving it, it will be HIGH.
You have connected a button between Pins 2 and 4. So, if you don'...
5
votes
Accepted
What does “LSB per degree per second” mean?
Let us say we have a number, "4025". The "most significant digit" of the number is the 4 in the thousands position, since it tells us the most about the magnitude of the number ("in the four thousands"...
5
votes
UNO's digital pin continue to read 1 for a while
Digital inputs should either be low or high. In this image acceptable input voltages on the left represent common TTL voltages based on a 0 to 5 volt range:
It is bad practice to leave a digital ...
5
votes
Accepted
Digital I/O threshold voltages for ATmega32u4
LVTTL is Low Voltage Transistor-Transistor Logic. In general, the
term "TTL" is used for a digital signal.
The "Low Voltage" part is special,
the ATmega32U4 switches from low to high (and vice versa) ...
5
votes
Accepted
Unable to use analog pins as digital inputs
A6 and A7 are special on the nano. They are the only pins that can't be used for digital. They are only analog inputs.
5
votes
Digital Pins Question
The most common solution is to use the digital output to turn on a MOSFET that supplies separate power to a high-current device that needs more current than the 20 mA that an ATmega328 microcontroller ...
4
votes
What does “LSB per degree per second” mean?
With further elaboration on Ignacia's answer:
A gyroscope itself is generally an analog device in the sense that in reality, it will have a continous output. This output is digitized using some form ...
4
votes
Is there a way to play sounds from an Arduino without using a sound shield?
The PCMAudio example shows how to play audio data via PWM. Note that you will need to access the MCU at a low level in order to do this; the Arduino libraries don't provide enough control over the ...
4
votes
Why does the PIN 13 LED of Uno R3 blink every time I upload some code?
See What happens when code is uploaded using the bootloader? - the flashing is by design.
Probably the reason is to confirm that the bootloader has started.
4
votes
Accepted
How to update multiple outputs simultaneously
Yes, the ports of an Uno are addressed in C/C++ as PORTB, PORTC, and PORTD respectively, each 8 bits wide. You can read them or assign to them. Other processors' ports have similar names. Of course ...
4
votes
Accepted
Interfacing Digital clock with Uno
It is likely that the alarm clock does not provide any voltage level (I mean GND) to the buzzer when it does not have to ring, the circuit is just left "open" then; it will provide a voltage level (...
4
votes
manual square wave period is off
From Arduino reference on delayMicroseonds:
Currently, the largest value that will produce an accurate delay is 16383. This could change in future Arduino releases. For delays longer than a few ...
4
votes
Fool Proofing My Arduino IC Checker
I would connect each of the IC's IO pins to both a digital output and
a digital (or analog) input of the Arduino, like this:
simulate this circuit – Schematic created using CircuitLab
Drive ...
4
votes
Accepted
Digital selection for gain control not working instead showing 0
pinMode( K1, INPUT );
with
if(K1 == LOW && K2 == LOW)
makes no sense. K1 is a pin number. LOW is a macro for 0 (HIGH for 1). You are comparing a static pin number against a static ...
4
votes
Accepted
`LOW` being defined as `0` and `HIGH` being defined as `1` - is this a part of external specification?
The underlying reason for this question is to figure out whether code like
digitalWrite(some_pin, true);
digitalWrite(some_other_pin, !digitalRead(some_other_pin));
is a good programming ...
4
votes
Accepted
Plug in analog sensor into digital pin
According to SAMD21 the digital input pin detects HIGH if the voltage on pin is higher than 0.55 of supply voltage. So at 3.3 V it is 1.8 V.
The input pin detects LOW if the voltage is lower than 0.3 ...
4
votes
Plug in analog sensor into digital pin
Yes. If you read the datasheet you will find a set of voltage specifications. The ones you are interested in are VIH and VIL.
Most MCUs use a "Schmitt Trigger" for the inputs. This means ...
3
votes
Accepted
For the digital output pins, how is LOW different than no connection?
(Edit for clarification: I've assumed in this answer that you're asking about the difference between connecting the relay to ground/LOW vs. connecting the relay to nothing at all. I've also assumed by ...
3
votes
4 channel relay module reversed? Or is it my code?
All the relay boards I've come across are 'active low' i.e. as you've discovered bringing the control pin down to earth activates the relay. As an aside just be careful that the arduino has enough ...
3
votes
Accepted
Digital pins on Arduino function as both positive and negative terminals?
The answer to your question is basically yes, you can use ATmega I/O pins as +/- power supply terminals for other circuits. But there's a limit to what you can power that way (20mA per pin and 100mA ...
3
votes
Accepted
How to blink a series of LED alternately only one at a time
You could always copy and paste:
void setup() {
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(11, HIGH);
delay(1000);
digitalWrite(11, ...
3
votes
Arduino Pin won't go LOW
you forgot to add a delay after digitalWrite(devicePin, LOW);
#define devicePin 10
void setup() {
pinMode(devicePin, OUTPUT);
}
void loop() {
digitalWrite(devicePin, HIGH);
delay(2000);
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
digital × 123arduino-uno × 38
pins × 14
arduino-mega × 12
programming × 11
analogread × 11
led × 10
serial × 7
sensors × 7
arduino-nano × 7
input × 7
pwm × 6
arduino-due × 6
button × 5
relay × 5
voltage-level × 5
c++ × 4
power × 4
voltage × 4
potentiometer × 4
motor × 3
interrupt × 3
spi × 3
timers × 3
communication × 3