Class ADC0834ConverterHelper

java.lang.Object
com.opensourcewithslu.inputdevices.ADC0834ConverterHelper

public class ADC0834ConverterHelper extends Object
The ADC0834ConverterHelper class interfaces with the ADC0834 analog-to-digital converter using SPI. It provides methods to read digital values and voltages from the specified channel.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ADC0834ConverterHelper(com.pi4j.io.spi.SpiConfig spiConfig, com.pi4j.context.Context pi4jContext)
    Constructor for ADC0834ConverterHelper.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    readValue(int channel)
    Reads the digital value from the specified channel (0-3) of the ADC0834.
    double
    readVoltage(int channel, double referenceVoltage)
    Reads the voltage from the specified channel using the provided reference voltage.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ADC0834ConverterHelper

      public ADC0834ConverterHelper(com.pi4j.io.spi.SpiConfig spiConfig, com.pi4j.context.Context pi4jContext)
      Constructor for ADC0834ConverterHelper.
      Parameters:
      spiConfig - A Pi4J SPIConfig object which holds the SPI configuration.
      pi4jContext - The Pi4J context object.
  • Method Details

    • readValue

      public int readValue(int channel)
      Reads the digital value from the specified channel (0-3) of the ADC0834.
      Parameters:
      channel - The ADC channel to read (0-3).
      Returns:
      The 8-bit digital value (0-255).
      Throws:
      IllegalArgumentException - if channel is invalid.
    • readVoltage

      public double readVoltage(int channel, double referenceVoltage)
      Reads the voltage from the specified channel using the provided reference voltage.
      Parameters:
      channel - The ADC channel to read (0-3).
      referenceVoltage - The reference voltage (e.g., 3.3V or 5.0V).
      Returns:
      The measured voltage.
      Throws:
      IllegalArgumentException - if channel or referenceVoltage is invalid.