Saikat Chakraborty
Published © MIT

Liquid Level Inclinometer

A sensor system to determine the inclination of a platform by measuring the level of a conductive liquid.

IntermediateFull instructions provided15 hours100
Liquid Level Inclinometer

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
7 Segment LED Display, InfoVue
7 Segment LED Display, InfoVue
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Breadboard (generic)
Breadboard (generic)
×2
Jumper wires (generic)
Jumper wires (generic)
×20
Table Tennis Ball
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Custom parts and enclosures

4 directional CAD Model

Dimensions

Schematics

Analogous Schematic in TinkerCAD

Code

Inclinometer.ino

Arduino
// Saikat Chakraborty
// Roll : 1803005
// Dept. of EEE, KUET
#include <Servo.h>
const int numReadings = 10;
byte pin[] = {4, 5, 6, 7, 8, 9, 10, 11};//arduino pin array
Servo myservo;
 
int number[10][8] = {//number array
  {1, 1, 1, 0, 1, 1, 1, 0},//0
  {0, 0, 1, 0, 1, 0, 0, 0},//1
  {1, 1, 0, 0, 1, 1, 0, 1},//2
  {0, 1, 1, 0, 1, 1, 0, 1},//3
  {0, 0, 1, 0, 1, 0, 1, 1},//4
  {0, 1, 1, 0, 0, 1, 1, 1},//5
  {1, 1, 1, 0, 0, 1, 1, 1},//6
  {0, 0, 1, 0, 1, 1, 1, 0},//7
  {1, 1, 1, 0, 1, 1, 1, 1},//8
  {0, 1, 1, 0, 1, 1, 1, 1},//9
};
//11-12, 24-25, 35-36, 47-48, 55-56, 65-66, 74-75, 81-82, 89-90
//5-6, 12-13, 19-20,25-26, 32-33, 38-39, 44-45, 50-51, 55-56
//14, 27, 38, 49, 58, 67, 76, 84, 91, 98
int levels[11] = {12, 27, 37, 50, 61, 75, 85, 98, 109, 130};
int index = -1;

void setup() {
  for (byte a = 0; a < 8; a++) {
    pinMode(pin[a], OUTPUT);//define output pins
  }
  myservo.attach(3, 600, 2300);
  myservo.write(90);
  Serial.begin(9600);
}

void loop() {
  int A0 = analogRead(A4); // Read analog outputs
  int A1 = analogRead(A5);
  int value = (A0 >= A1)?A0:A1; // Compare to get the largest value
  int dir = (A0 >= A1)?1:-1; // Calculate the direction of servo
  Serial.println(value);
  int temp = 0;
  for (int i = 0; i < 10; i++)
  {
    if (value >= levels[i] && value < levels[i + 1])
    {
      temp = i + 1;
      break;
    }
  }
  if (temp != index)
  {
    index = temp;
    for (int b = 0; b < 8; b++) {
    digitalWrite(pin[b], number[temp][b]);//display numbers
    }
    myservo.write(90 + temp * dir * 10);
  }
  delay(100);  // delay in between reads for stability
}

Credits

Saikat Chakraborty
4 projects • 0 followers
Electrical Engineer specializing in signal processing with a keen interest in Computer Aided Design, Software Development and Cybersecurity.

Comments