I get the following error in my sketch (its my first).
error: 'currentValue' was not declared in this scope In function 'void loop()':
At global scope:
Here is the sketch in its entirety (reads accelerometer data and puts it on a serial display (16x2)
Its not done yet and needs other polishing...plus there is no rush as arduino's are backordered at sparkfun:
long highValue=0.0;
long currentValue=0.0;
void setup()
{
Serial.begin(9600);
backlightOn();
displayWelcome();
}
//in order to do a 1.11 style output two ints are required
// 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 (pin)
// \ \ \ \ \ \ \ | / / / / / / / (semi analog)
// 0 . 1 2 C u r | 0 . 1 3 H i
void loop()
{
currentValue=0.0;
int firstPart=0;
int secondPart=0;
currentValue = getAccelValue();
//split for prettyfied output
firstPart = (int)(currentValue);
secondPart = (int)(currentValue * 100); //nothing expected to beat 1g
selectLineOne();
delay(100);
barchart(currentValue);
selectLineTwo();
delay(100);
Serial.print(firstPart);
delay(100);
Serial.print(".");
delay(100);
Serial.print(secondPart);
delay(100);
Serial.print("CUR/HI");
delay(100);
value=(getMaxValue(currentValue));
firstPart = (int)(currentValue);
secondPart = (int)(currentValue * 100); //nothing expected to beat 1g
Serial.print(firstPart);
Serial.print(".");
Serial.print(secondPart);
delay(300);
clearLCD();
}
void displayWelcome(){
selectLineOne();
Serial.print("Danger to the");
delay(100);
selectLineTwo();
delay(100);
Serial.print("manifold!!!");
}
float getAccelValue(){
return (random(1));
}
float getMaxValue(currentValue){
if (currentValue > highValue){
highValue=currentValue;
}
return (highValue);
}
void barchart(currentValue) {//makes a simple bar chart on the top line
}
void selectLineOne(){ //puts the cursor at line 0 char 0.
Serial.print(0xFE, BYTE); //command flag
Serial.print(128, BYTE); //position
}
void selectLineTwo(){ //puts the cursor at line 0 char 0.
Serial.print(0xFE, BYTE); //command flag
Serial.print(192, BYTE); //position
}
void clearLCD(){
Serial.print(0xFE, BYTE); //command flag
Serial.print(0x01, BYTE); //clear command.
}
void backlightOn(){ //turns on the backlight
Serial.print(0x7C, BYTE); //command flag for backlight stuff
Serial.print(157, BYTE); //light level.
}
void backlightOff(){ //turns off the backlight
Serial.print(0x7C, BYTE); //command flag for backlight stuff
Serial.print(128, BYTE); //light level for off.
}
void serCommand(){ //a general function to call the command flag for issuing all other commands
Serial.print(0xFE, BYTE);
}