Go Down

Topic: bargraph ultrasonic ranging (Read 824 times) previous topic - next topic


Hi,  I'm newbie to arduino, does anyone  know how to add smooth range bargraph meter on the second  line  with 2x16 LCD  to that code?

LiquidCrystal lcd(8, 9, 4, 5, 6, 7); int pingPin = 13; int inPin = 12;
void setup() { lcd.begin(16, 2); lcd.print("testing..."); }
void loop() {
long duration, inches, cm; pinMode(pingPin, OUTPUT); digitalWrite(pingPin, LOW); delayMicroseconds(2); digitalWrite(pingPin, HIGH); delayMicroseconds(10); digitalWrite(pingPin, LOW);
pinMode(inPin, INPUT); duration = pulseIn(inPin, HIGH);
inches = microsecondsToInches(duration); cm = microsecondsToCentimeters(duration); lcd.clear(); lcd.setCursor(0, 0); lcd.print(inches); lcd.print("in, "); lcd.print(cm); lcd.print("cm");
delay(100); }
long microsecondsToInches(long microseconds) {
return microseconds / 74 / 2; }
long microsecondsToCentimeters(long microseconds) { return microseconds / 29 / 2; }

Many thanks for any suggestions.


I have a double-line bar graph in this project code. Maybe you can modify the code to do single line bar graph.


People don't write code the way you posted on your thread. Please don't write more than one statement in one line and use the "#" button to post code.
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter

Go Up