Pages: [1]   Go Down
Author Topic: bargraph ultrasonic ranging  (Read 422 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
VM

Logged

Central MN, USA
Online Online
Tesla Member
***
Karma: 65
Posts: 6936
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

http://liudr.wordpress.com/2011/02/16/my-project-became-featured-project-on-instructables-com/

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.
Logged


Pages: [1]   Go Up
Jump to: