1

Using for example 433MHz RF Receiver modules, they are connected to a digital input pin with interrupt. Looking at the most basic meaning of digital readings (e.g. 1/0, on/off, HIGH/LOW), how does the Arduino convert the signal readings to a number/string?

From my limited understanding, I'm assuming it has something to do with the (external) libraries, or it might just be that my understanding about digital readings are too limited.

1
  • I don't know about RF Receivers, but most sensors I know uses some form of digital protocol to comunicate with Arduino, so you need a library for that specific protocol (like I2C or SPI). I think there is, however, a pH sensor that is just output a voltage that you read with an analog pin. – user31481 Jul 4 '17 at 14:46
1

From the official Arduino site, See DigitalWrite :

If the pin has been configured as an OUTPUT with pinMode(), its voltage will be set to the corresponding value: 5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW.

The exact definitions can be found here for reading a signal: Constants

When reading or writing to a digital pin there are only two possible values a pin can take/be-set-to: HIGH and LOW.

HIGH

The meaning of HIGH (in reference to a pin) is somewhat different depending on whether a pin is set to an INPUT or OUTPUT. When a pin is configured as an INPUT with pinMode(), and read with digitalRead(), the Arduino (Atmega) will report HIGH if:

-a voltage greater than 3.0V is present at the pin (5V boards); -a voltage greater than 2.0V is present at the pin (3.3V boards);

A pin may also be configured as an INPUT with pinMode(), and subsequently made HIGH with digitalWrite(). This will enable the internal 20K pullup resistors, which will pull up the input pin to a HIGH reading unless it is pulled LOW by external circuitry. This is how INPUT_PULLUP works and is described below in more detail.

When a pin is configured to OUTPUT with pinMode(), and set to HIGH with digitalWrite(), the pin is at: -5 volts (5V boards); -3.3 volts (3.3V boards);

In this state it can source current, e.g. light an LED that is connected through a series resistor to ground.

LOW

The meaning of LOW also has a different meaning depending on whether a pin is set to INPUT or OUTPUT. When a pin is configured as an INPUT with pinMode(), and read with digitalRead(), the Arduino (Atmega) will report LOW if:

-a voltage less than 1.5V is present at the pin (5V boards);

-a voltage less than 1.0V (Approx) is present at the pin (3.3V boards);

When a pin is configured to OUTPUT with pinMode(), and set to LOW with digitalWrite(), the pin is at 0 volts (both 5V and 3.3V boards). In this state it can sink current, e.g. light an LED that is connected through a series resistor to +5 volts (or +3.3 volts).

Probably, HIGH is 1, LOW is 0, and ON is 1, OFF is 0. Than 1 is mapped to 5V or 3.3V depending on the Arduino and 0 is mapped to 0V. These mappings and the definitions of HIGH/LOW/ON/OFF are in the Arduino libraries.

0

A digital pin can only tell you if a signal is HIGH or LOW at any instant in time. That itself isn't enough to transfer data (as in a stream of 1 and 0) since it's just the state at that moment.

To transfer data you need to introduce the extra parameter of time. That is, the amount of time a pin is HIGH or LOW and when exactly it changes.

UART data works this way. Both ends of the connection agree on a certain time for each "bit" of data (symbol) and read or set the pin at the agreed rate. That is the baud rate of the connection. Without that pre-arranged agreement on the time there is no way one end can know what the other is saying.

Other methods involve looking not at the current state of the pin but instead looking at how and when it changes from HIGH to LOW or LOW to HIGH. One example of this is Manchester Coding which encodes the different bits 0 and 1 as different sequences of transitions between HIGH and LOW or LOW and HIGH.

A third method, which is what SPI and I2C use, is to employ another pin to indicate to the receiver when it should look at the pin - this is sending the clock to the receiver.

Fourth, you get the way IR remote controls work. These use different length pulses of HIGH/LOW to indicate a 1 or a 0. A long HIGH and short LOW could be a 1, and a short HIGH and long LOW could be a 0.

1
  • In other words, the receiver sends the data in binary (1s and 0s) to the Arduino? (and the library converts it to string code) – Renier Delport Jul 5 '17 at 6:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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