Help creating horizontal bar graph

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Help creating horizontal bar graph

Postby the_prawn » Tue Nov 20, 2012 6:01 am

Hi all, I'm extremely new to programming and am fumbling my way through so far.
I purchased a Uno, breadboard and 16x2 RGB negative backlight LCD, as well as a MPX4250AP pressure sensor.
My goal is to build a boost sensor/gauge for the turbo on my car.
So far, I'm doing OK. I've got a pot hooked up in place of the actual sensor for testing but everything seems to be going as it should - keep in mind I'm cutting and pasting and modifying bits of code and trying to get them to work together.
On my top line I have a reading of boost pressure in PSI, calibrated to my location/altitude, starting from the left. I have a dividing line "|" at position 10 and after that I have the peak/max boost value stored (resets when engine/power off).
I also have the display set so that it changes colour when a critical boost (eg overboost) pressure is reached.
I'm pretty happy with all that so far!

Now, my problem is I would like a horizontal bar graph on the second line coming from the left side, just as a visual representation and just because I have an empty second line.
I'm able to write characters to the second line but not much else. So far I just have it displaying "bar graph here".

I've downloaded and installed the LCDBarGraph library from arduino.cc but am now at a loss as to how I code it to display my graph. I need to get it to read the pressure values from "analogue 0" where the sensor will be installed, then I assume I can use a pot to adjust and calibrate my graph to the pressure range I want? I've been searching for a week or so but am struggling to find appropriate code that I can modify to suit my needs and my skill is not up to making it from scratch yet.

Any help would be appreciated.
the_prawn
 
Posts: 3
Joined: Sat Sep 15, 2012 5:40 am

Re: Help creating horizontal bar graph

Postby the_prawn » Tue Nov 20, 2012 6:20 am

OK, I've inserted the following code into the void loop

lcd.setCursor(0,1);
lbg.drawValue( analogRead(sensorPin), 1024);

and now I get my bar graph but its on line one. Sad face.
the_prawn
 
Posts: 3
Joined: Sat Sep 15, 2012 5:40 am

Re: Help creating horizontal bar graph

Postby Arctic_Eddie » Tue Nov 20, 2012 8:42 am

The LCD row and column numbers start at 0. The columns will then have a range of 0-15 and the rows will be 0-1. To use the top row, set the cursor to 0,0. If the bar graph range is the same as columns then you will need to map the ADC range 0-1023 to the LCD range 0-15. It will be easier to just divide the ADC reading by 64 to keep the bar on the screen.

PS - It appears that the bargraph command already has the correct scaling built in to the library. See link in the following post.
Last edited by Arctic_Eddie on Tue Nov 20, 2012 9:06 am, edited 1 time in total.
Arctic_Eddie
 
Posts: 208
Joined: Tue Feb 28, 2012 5:01 pm
Location: St. Petersburg, FL

Re: Help creating horizontal bar graph

Postby Arctic_Eddie » Tue Nov 20, 2012 9:04 am

Arctic_Eddie
 
Posts: 208
Joined: Tue Feb 28, 2012 5:01 pm
Location: St. Petersburg, FL

Re: Help creating horizontal bar graph

Postby the_prawn » Tue Nov 20, 2012 7:17 pm

Cheers Eddie, I had seen that blog before but missed the part where he edited the library to set the graph on line 2.

Problem solved, thanks for your help.
the_prawn
 
Posts: 3
Joined: Sat Sep 15, 2012 5:40 am


Return to Other Arduino products from Adafruit

Who is online

Users browsing this forum: No registered users and 3 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [103]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[109]
 
Wireless[14]
Cables[61]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[70]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]