Toggle navigation
Toggle navigation
This project
Loading...
Sign in
성준영
/
2018-1-lolock
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Junyoung, Sung
2018-06-19 22:02:31 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
be42a814b669342ed1404e5e14e556e4e8d88112
be42a814
1 parent
dc843c0d
Added arduino source
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
0 deletions
lolock_arduino/lolock.ino
lolock_arduino/lolock.ino
0 → 100644
View file @
be42a81
#include <Servo.h>
#include <LoRaShield.h>
#include <SoftwareSerial.h>
#define LoRaBaud 38400
#define LoRaRx 10
#define LoRaTx 11
#define DigitalPush 2
#define ServoPin 9
#define OPEN 0
#define CLOSE 180
LoRaShield
LoRa
(
LoRaRx
,
LoRaTx
);
int
MotorStatus
[
2
];
Servo
servo
;
void
setup
()
{
LoRa
.
begin
(
LoRaBaud
);
Serial
.
begin
(
115200
);
pinMode
(
LoRaTx
,
OUTPUT
);
pinMode
(
DigitalPush
,
INPUT_PULLUP
);
servo
.
attach
(
ServoPin
);
servo
.
write
(
CLOSE
);
attachInterrupt
(
digitalPinToInterrupt
(
DigitalPush
),
digitalPushInterrupt
,
CHANGE
);
Serial
.
println
(
"SETUP COMPLETE"
);
Serial
.
println
(
digitalRead
(
2
));
}
void
loop
(){
LoRa
.
listen
();
String
LoRa_Text
,
LoRa_Message
;
while
(
LoRa
.
available
())
{
LoRa_Text
=
LoRa
.
ReadLine
();
LoRa_Message
=
LoRa
.
GetMessage
();
if
(
LoRa_Message
==
"26"
)
{
Serial
.
println
(
"Door Open"
);
doorOpen
();
}
}
if
(
MotorStatus
[
0
]
==
1
&&
MotorStatus
[
1
]
==
1
)
{
doorOpen
();
MotorStatus
[
0
]
=
0
;
MotorStatus
[
1
]
=
0
;
}
}
void
doorOpen
()
{
int
i
;
for
(
i
=
0
;
i
<
180
;
i
++
)
{
servo
.
write
(
i
);
delay
(
2
);
}
delay
(
400
);
for
(
i
=
180
;
i
>
0
;
i
--
)
{
servo
.
write
(
i
);
delay
(
2
);
}
}
void
digitalPushInterrupt
()
{
MotorStatus
[
digitalRead
(
2
)]
=
1
;
Serial
.
print
(
"MOTOR1 "
);
Serial
.
println
(
MotorStatus
[
0
]);
Serial
.
print
(
"MOTOR2 "
);
Serial
.
println
(
MotorStatus
[
1
]);
}
Please
register
or
login
to post a comment