Smart door. help me please

Hello. I have problem my code. (I´m sorry my English is very bad). I need Help. Please

#include <NeoSWSerial.h>
#include <Servo.h>

NeoSWSerial BT(2,3);
String readvoice;
char c;
Servo myservo;
int servopin=7;

void setup() {
BT.begin(9600);
Serial.begin(9600);
myservo.attach(servopin);
}

void loop() {
while (BT.available())
{delay(10);
c=BT.read();
readvoice+=c;
}
if (readvoice.length()>0)
{
Serial.println(readvoice);
if (readvoice=="open")
{
Serial.print("Door opened");
myservo.write(90);
delay(1000);
}
else if (readvoice=="close")
{
Serial.print("Door closed");
myservo.write(180);
delay(1000);
}
else if (c==´D´)
{
Serial.print("Door opened");
myservo.write(90);
delay(1000);
}
else if(c==´d´) // HERE THE ERROR. I DDON´T NOW. HELPME
{
Serial.print("Door closed");
myservo.write(180);
delay(1000);
}
readvoice="";
}
}

Hello
Take some time and study how while() works.

Please format your code correctly (there is a button for it in the text box) and give a description of your project/the error and what you expected to have happen. You may benefit from reading How to get the best out of this forum.

You have miss counted the number of { and }, they do not match up.

Who wrote this code?

There should have been a warning that you needed to format your code. Did you ignore that warning?

what exactly is the error?
have you tried using a different letter, such as 'o' for open?

Hi,
What is your code supposed to do?
What does your code do?

Tom... :smiley: :+1: :coffee: :australia:

look into the categories of the arduino-user-forum if your native language is in the list
Chinese
espanol
francais
india
italiano
nederlands
portuges
Russia
scandianvia

or use google-translate,

use your native language to write a description of

  • what your project is about
  • what error you might see
    etc.
    and let do google translate the translation
    the grammar of the translation will not be brilliant but the information you can trasnfer this way will be 100 times more than the poor

best regards Stefan

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.