Help with password code
hey guys, little new arduino , wondering if on 1 of projects working on right now.
so happens have string called "key" has password stored on beforehand such "banana" when type serial monitor send typed lcd , if typed , password same there message on lcd saying "correct password". if not correct password there try again message. having trouble getting serial.read() compared "key" variable in if statements. grateful if out, code below.
in if statements keeps saying have "non-static member function".
so happens have string called "key" has password stored on beforehand such "banana" when type serial monitor send typed lcd , if typed , password same there message on lcd saying "correct password". if not correct password there try again message. having trouble getting serial.read() compared "key" variable in if statements. grateful if out, code below.
code: [select]
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
#include <liquidcrystal.h>
liquidcrystal lcd(rs, en, d4, d5, d6, d7);
string key = "radical dude";
void setup() {
// set lcd's number of columns , rows:
lcd.begin(16, 2);
// initialize serial communications:
serial.begin(9600);
}
void loop() {
// when characters arrive on serial port...
if (serial.available()) {
// wait bit entire message arrive
delay(100);
// clear screen
lcd.clear();
// read available characters
while (serial.available() > 0) {
// display each character lcd
lcd.write(serial.read());
}
}
if (serial.read == key){
lcd.clear();
lcd.print("password accepted");
}
if (serial.read != key){
lcd.clear();
lcd.print("incorrect");
}
}
in if statements keeps saying have "non-static member function".
second guessing happens in asynchronous line synchronous code calling trouble...
read serial input basics , familiar c functions in stdlib.h , string.h , drop usage of string class
code: [select]
if (serial.available()) {
// wait bit entire message arrive
delay(100);
read serial input basics , familiar c functions in stdlib.h , string.h , drop usage of string class
Arduino Forum > Using Arduino > Programming Questions > Help with password code
arduino
Comments
Post a Comment