i have an error like this, please help me to solve
sketch_oct20a.ino (3.06 KB)
i have an error like this, please help me to solve
sketch_oct20a.ino (3.06 KB)
I could only find the INO sketch code (post in here in tags...
No error message attached that I could see.
Your code has a some strange character instead of spaces. If you copy the code below they should be replaced with real spaces and the problem should be solved.
//Sample using LiquidCrystal library
#include "LiquidCrystal.h"
// select the pins used on the LCD panel
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
// define some values used by the panel and buttons
int lcd_key = 0;
int adc_key_in = 0;
#define btnRIGHT 0
#define btnUP 1
#define btnDOWN 2
#define btnLEFT 3
#define btnSELECT 4
#define btnNONE 5
// read the buttons
int read_LCD_buttons()
{
adc_key_in = analogRead(0); // read the value from thesensor
// my buttons when read are centered at these valies: 0, 144, 329, 504, 741
// we add approx 50 to those values and check to see if we are close
if (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result
// For V1.1 us this threshold
if (adc_key_in < 50) return btnRIGHT;
if (adc_key_in < 250) return btnUP;
if (adc_key_in < 450) return btnDOWN;
if (adc_key_in < 650) return btnLEFT;
if (adc_key_in < 850) return btnSELECT;
return btnNONE; // when all others fail, return this...
}
void setup()
{
lcd.begin(16, 2); // start the library
lcd.setCursor(0,0);
lcd.print("Push the buttons");
Serial.begin(9600);
while (!Serial); // Leonardo: wait for serial monitor
Serial.println("\nNILAI ADC");
// print a simple message
}
void loop()
{
lcd.setCursor(14,1); // move cursor to second line "1" and 9 spaces over
lcd.print(millis()/1000);// display seconds elapsed since powerup
lcd.setCursor(0,1); // move to the begining of the second line
lcd_key = read_LCD_buttons(); // read the buttons
switch (lcd_key) // depending on which button was pushed, we perform an action
{
case btnRIGHT:
{
lcd.print("ADC : ");
lcd.print(adc_key_in);
lcd.print(" ");
Serial.println("\nRIGHT :");
Serial.println(adc_key_in,DEC);
break;
}
case btnLEFT:
{
lcd.print("ADC : ");
lcd.print(adc_key_in);
lcd.print(" ");
Serial.println("\nLEFT :");
Serial.println(adc_key_in,DEC);
break;
}
case btnUP:
{
lcd.print("ADC : ");
lcd.print(adc_key_in);
lcd.print(" ");
Serial.println("\nUP :");
Serial.println(adc_key_in,DEC);
break;
}
case btnDOWN:
{
lcd.print("ADC : ");
lcd.print(adc_key_in);
lcd.print(" ");
Serial.println("\nDOWN :");
Serial.println(adc_key_in,DEC);
break;
}
case btnSELECT:
{
lcd.print("ADC : ");
lcd.print(adc_key_in);
lcd.print(" ");
Serial.println("\nSELECT :");
Serial.println(adc_key_in,DEC);
break;
}
case btnNONE:
{
lcd.print("NILAI ADC");
lcd.print(" ");
break;
}
}
}
Code needs to be developed with a real programmers' text editor, not some fancy WYSIWYG tool,
since the character coding must be based on ASCII (ASCII spaces, quotes, double quotes, etc, not
fancy variants).