Advertisement
microrobotics

ADS1110 A/D Converter Module

May 6th, 2023
894
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Wire.h>
  2. #define ADS1110_ADDR 0x48
  3.  
  4. void setup() {
  5.   Serial.begin(9600);
  6.   Wire.begin();
  7. }
  8.  
  9. void loop() {
  10.   // Start a single conversion on AIN0 with a gain of 1
  11.   Wire.beginTransmission(ADS1110_ADDR);
  12.   Wire.write(0x85);
  13.   Wire.write(0x83);
  14.   Wire.endTransmission();
  15.  
  16.   delay(10);    // Wait for the conversion to complete
  17.  
  18.   // Read the conversion result
  19.   Wire.requestFrom(ADS1110_ADDR, 2);
  20.   int16_t result = Wire.read() << 8 | Wire.read();
  21.   float voltage = result * 0.000125; // Convert to voltage
  22.   Serial.println(voltage);
  23.  
  24.   delay(1000);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement