Questions tagged [digital]

Digital refers to signals which are either on or off (high or low, one or zero). This contrasts with analog signals which have a range of values.

Digital Inputs

Digital inputs are read as being HIGH or LOW in the Arduino code. There are no intermediate values.

The datasheet specifies voltage levels:

  • A certain level below which a signal is considered LOW
  • Another level, above which a signal is considered HIGH
  • There is normally an in-between level where the signal is undefined (it might be HIGH or LOW randomly).

As an example, on the Atmega328P, operating at 5 volts supply, the levels for most pins are:

  • -0.5 V to 1.5 V - considered LOW
  • Above 1.5 and below 3 V - undefined
  • 3 V to 5.5 V - considered HIGH

Digital Outputs

Digital outputs are written as HIGH or LOW in the Arduino code. There are no intermediate values.

The driver transistors in the processor attempt to bring the corresponding output pin to 0 V for LOW and VCC for HIGH (where VCC is the supply voltage for the chip, typically 3.3 V or 5 V).

As an example, the datasheet for the Atmega328P specifies that (at an ambient temperature of 85°C, driving 20 mA, and running at 5 V) the output pin should be:

  • A maximum of 0.9 V when driven LOW
  • A minimum of 4.2 V when driven HIGH

Analog inputs

Contrast the above to the analog inputs on the Arduino which use an ADC (Analog to Digital Converter) to read a range of values on an input pin, and return a number corresponding to where that voltage lies in the range 0 to the analog reference voltage.

See also:

130 questions
14
votes
6 answers

Is there a way to play sounds from an Arduino without using a sound shield?

I would like to play a wav file (spoken words) from my Arduino. I do not want to add a sound shield. Is there a way to play a sound through an output pin? The quality does not have to be great.
Hoytman
  • 747
  • 5
  • 13
  • 27
10
votes
8 answers

What's the difference between analogWrite and digitalWrite?

As the title states. What's the difference between the two? analogWrite(pin,0-255) vs digitalWrite(pin,LOW-HIGH)
pijemcolu
  • 127
  • 1
  • 1
  • 8
6
votes
1 answer

Arduino Digital Input Causing Output Problems

I am working on a simple project using an Arduino Mega 2560 that involves reading a 12-bit binary encoder signal and which is used to cycle a digital pin high and low (depending on the angular location of the encoder). My problem is that when the…
6
votes
5 answers

Arduino-based mains frequency monitor

I'm looking to put together a simple mains frequency monitor based on the Arduino platform. The mains here are 250 V @ 50 Hz, but obviously these fluctuate slightly, which is the whole point of the exercise. (I am not interested in capturing voltage…
Ozzah
  • 193
  • 5
5
votes
2 answers

Is it wise to use analog input pins to read digital buttons?

I am thinking about building a circuit that is literally going to take 11 of the 14 digital pins of an UNO to communicate with an SD card and an external EEPROM chip (EEPROM programmer). Using 4 shift registers and the SD card, I will have 1 digital…
cbmeeks
  • 247
  • 2
  • 10
5
votes
3 answers

Fool Proofing My Arduino IC Checker

I am creating an IC checker for some high school juniors since a faulty IC can be a nuisance of a bug to find when bread-boarding. These ICs are all simple TTL gating from the 74LS series; the set I am using are all 14-pin and have VCC and GND at…
5
votes
2 answers

Why digital pin not reading ON from push button switches connected to 5V and pull-down 10K resistor?

Here's my circuit: And the code: //pins const int control1 = 2; const int control2 = 3; const int enable = 9; const int pinDirection = 4; const int pinOnOff = 5; const int pot = A0; //states int stateOnOff = 0; int stateOnOffPrev = 0; int…
Roman
  • 211
  • 1
  • 2
  • 8
4
votes
0 answers

What’s the most stable digital communication protocol for sewable electronics?

I’ve spent the past few days trying researching communication protocols and I have a few issues. With sewable electronics, you need to work with cables with a fairly high resistance that are constantly moving. That means unreliable and noisy…
3
votes
2 answers

For the digital output pins, how is LOW different than no connection?

I am working with relays and I noticed that connecting the trigger pin to ground (or a digital pin set to LOW) is not the same as having the trigger connected to anything. For the digital output pins, how is LOW different than no connection? Is…
Hoytman
  • 747
  • 5
  • 13
  • 27
3
votes
2 answers

How to count positive electrical pulses?

I have a device that has one blinking LED. I want to count the number of blinks. I planned to do it using Arduino. I will connect two terminals of LED input to Arduino digital input pins, and I will count the number of positive voltage pulses I just…
SSR
  • 31
  • 1
3
votes
1 answer

Red LED not turning off on Adafruit Circuit Playground Classic

When using the traditional Blink example program, the light blinks as expected. Even when writing from scratch digitalWriteing pin 13 to high and low repeatedly works fine. The problem is when I try to use CircuitPlayground.redLED(false). That has…
Daffy
  • 141
  • 4
3
votes
1 answer

Digital I/O threshold voltages for ATmega32u4

What are the voltages on a ATmega32u4 (eg Arduino Leonardo) such that a HIGH or LOW is read? I want to ensure that I'm reading the chip reference manual correctly, where Table 29-1 says: VIL: Input Low Voltage, Except XTAL1 and Reset pin Min:…
Tom Hale
  • 431
  • 6
  • 19
3
votes
6 answers

Digital pins on Arduino function as both positive and negative terminals?

I'm learning the arduino platform and working on a circuit that connects the two pins of a piezo buzzer -- one to ground and the other to a digital pin of the arduino board. In this configuration, is the arduino's digital pin acting as the positive…
Jog
  • 141
  • 1
  • 1
  • 4
3
votes
1 answer

Cheapest way to change digital output source

Powering at 5 volts, atmega328 output ~4.7 volts. I need to output between 12 and 24 volts @ 2 amp. I'm currently using relay but they are costly. Is there a way to do it with transistors or any thing cheaper? Thanks
3
votes
2 answers

UNO's digital pin continue to read 1 for a while

I'm doing some tests and I notice a bad things with digitals pins. I have a wire that sends 1 signals. If i connect it to a reading pin, I read 1 - and it's ok. But if i disconnect it, for 5-6 seconds Arduino continues to read 1 instead of 0! How…
Andrean
  • 141
  • 2
1
2 3
8 9