Hello,
I am making a door lock, it is almost finished but i have one problem. When i turn the Arduino Nano on, the servo automatically goes to an position. How can i change that? I want that the servo doesn’t move when it starts up. There is a 5 second delay because i want to open the lock also with a key.
This is the code:
#include <Servo.h>
Servo servo;
int servo_val;
int tx=1;
int rx=0;
char inSerial[15];
void setup(){
Serial.begin(9600);
pinMode(tx, OUTPUT);
pinMode(rx, INPUT);
delay(5000);
servo.attach(13);
}
void loop(){
int i=0;
int m=0;
delay(500);
if (Serial.available() > 0) {
while (Serial.available() > 0) {
inSerial*=Serial.read();*
- i++; *
- }*
_ inSerial*=’\0’;_
Check_Protocol(inSerial);
_ }_
_}*_
void Check_Protocol(char inStr[]){
_ int i=0;_
* int m=0;*
* Serial.println(inStr);*
* if(!strcmp(inStr,“092422421”)){ *
* servo.write(125);*
* Serial.println(“Slot gesloten”);*
* for(m=0;m<11;m++){*
* inStr[m]=0;}*
* i=0;}*
* if(!strcmp(inStr,“452175547”)){ *
* servo.write(0);*
* Serial.println(“Slot geopend”);*
* for(m=0;m<11;m++){*
* inStr[m]=0;}*
* i=0;}*
* else{*
* for(m=0;m<11;m++){*
* inStr[m]=0;*
* }*
* i=0;*
}}