I need a code for my tilt sensor

Hi, im trying to make a circuit which shows like the angle of the tilt sensor in LCD. like if I tilt the breadboard the LCD would display the tilt but it just shows random numbers. I'm pretty sure that my circuit is correct but the problem is with the code

I agree, it's your code, or the sensor, or possibly the wiring. But only YOU can see them.

1 Like

Kindly share circuit and Code along with real world image

A schematic of your actual circuit would be a good first step!

can you give me the correct code for using the tilt sensor

but my circuit is like too dirty I mean there's like lot of things connected

How can I do that? I don't even knw what tilt sensor you have, or how it is wired up.

then i can make a schematic of how I connected mine wait like 10mins please

Sorry, the forum is for the help not for proper code kindly share your your code first

Systematic can't be dirty

#include <LiquidCrystal.h>
LiquidCrystal lcd(2,3,4,5,6,7);
int Tilt = A1;

void setup () {
  lcd.begin(16,2);
  pinMode(Tilt, OUTPUT);
}

void loop() {
  lcd.print("Tilt = ");
  lcd.print(analogRead(Tilt));
  lcd.print(" Tilt")
}

I would suggest if you are willing to learn the working of tilt sensor just remove the led and join sensor with analog read pins and read it to serial monitor

But like im not learning im just trying to make a sensor type? thing so I need to do it with lcd

Oops

what?

Take it as INPUT that's what I want to covey

I believe that you are very new in the field and pls learn the basics

ooh.... wait then can u tell me which ohm resistor should I also use? i think that's wrong

It's an analogue input, used with analogRead; it doesn't need a pinMode, it's implicit.

wait can u send me the fixed code so i can just copy and paste?