Ciao a tutti, in questi giorni mi sono imbatutto in un progettino in rete per monitorare la pressione del turbo (http://cstark27.blogspot.co.uk/) , ho provveduto ad adattare il codice per il mio display dotato di interfaccia I2c 1602, ed ho scaricato dal seguente link la libreria LCD BAR GRAPH (Arduino Playground - HomePage). Adesso ho due problemi, primo problema non mi appare nella seconda riga del display la barra grafica e poi per caricare lo sketch su arduino devo togliere dal listato la riga lbg.drawValue( analogRead(sensorPin), 1024); altrimenti gia' in compilazione mi da il seguente errore: sketch_nov09a.ino: In function 'void loop()':
sketch_nov09a:43: error: 'lbg' was not declared in this scope
sketch_nov09a:43: error: 'sensorPin' was not declared in this scope
Premetto che sono pochi giorni che maneggio arduino e sono novello di programmazione, per cui confido tanto in un vostro aiuto ![]()
Tengo a precisare che eliminando la riga che mi da errore riesco a caricare il listato e la prima riga mi funziona correttamente indicando i valori letti dal sensore di pressione (che al momento simulo con un potenziometro).
Grazie
#include <LiquidCrystal.h>
#include <LcdBarGraph.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>int mapsen = 0; // Set MAP sensor input on Analog port 0
float boost = 0; // Set boost value to 0
float mapval = 0; // Set raw map value to 0
volatile float peakboost = -30.0; // Set peak memory to low number so max displays correctly
float warnpsi = 20.5; // Set PSI for warning
float atmpsi = 13.9637; //Local atmospheric pressure
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
void setup()
{
lcd.init(); // initialize the lcd// Print a message to the LCD.
lcd.backlight();
lcd.clear();
lcd.setCursor(4,0);
lcd.print("Welcome");
lcd.setCursor(4,1);
lcd.print("Cameron");
delay (1500);
lcd.clear();
lcd.setCursor(10,0);
lcd.print("|");}
void loop()
{
// -- draw bar graph from the analog value readedlbg.drawValue( analogRead(sensorPin), 1024);
// -- do some delay: frequent draw may cause broken visualization
//delay(100);
mapval= analogRead(mapsen); //Reads the MAP sensor raw value on analog port 0
boost = ((((float)mapval/(float)1023+0.04)/.004)*.145)-atmpsi;
if (boost <0) //If PSI is negative, convert to inHG and display VAC instead of PSI
{
//boost = boost*2.036021;
lcd.setCursor(0,0);
lcd.print("VAC");
}
else{
lcd.setCursor(0,0);
lcd.print("PSI");
}
if (boost > peakboost) //Works the MAX
{
peakboost = boost;
if (peakboost<-10) //Adjusts numbers over
{
lcd.setCursor(12,0);
lcd.print(peakboost,1);
}
if (peakboost>-10)
{
lcd.setCursor(11,0);
lcd.write(254);
lcd.setCursor(12,0);
lcd.print(peakboost,1);
}
if (peakboost >0)
{
lcd.setCursor(12,0);lcd.write(254);
lcd.setCursor(13,0);
lcd.print(peakboost,1);
}
if (peakboost >=10)
{
lcd.setCursor(12,0);
lcd.print(peakboost,1);
}
}
if (boost<-10){
lcd.setCursor(4,0);
lcd.print(boost,1);
}
if (boost>-10)
{
lcd.setCursor(8,0);
lcd.write(254);
lcd.setCursor(4,0);
lcd.print(boost,1);
}
if (boost >0)
{
lcd.setCursor(7,0);
lcd.write(254);
lcd.setCursor(4,0);
lcd.print(boost,1);
}
}
EDIT by mod: cambiato titolo - rimosso "help"