readRAM16()

[RAM]
unsigned short readRAM16 (unsigned short address);

Description

Reads a short value (16 bits) from the RAM memory at the specified address.

Parameters

address: the address where the data will be read.

Returns

The data read from the RAM memory at the specified address. The data is a 16-bit value (0-65535).

Example Code

The code initializes the RAM with a size of 1024 bytes and a width of 2 bytes and reads the value from the RAM memory at the address 0x00 to place it in the pins 1, 2, 3, and 4.

void setup() {
    beginRAM(1024, 2);       // initializes the RAM memory with a size of 1024 * 1 bytes
    writeRAM16(0x00, 0x55FF);  // writes the value 0x55 to the RAM memory at the address 0x00
}

void loop() {
    unsigned short value = readRAM16(0x00);  // reads the value from the RAM memory at the address 0x00
    digitalWriteNibble(1, 2, 3, 4, value); // takes the 4 least significant bits
                                           // and writes them to the specified pins
}

Notes and Warnings

  • The readRAM16() function can only be used after the beginRAM() function.
  • The returned value is a 16-bit value (0-65535) or an unsigned short.
  • If the programmer initializes the RAM with a width lower than 2 bytes, the function will return only 8 bits of the data.