-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c0fd2d1
Showing
3 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
int andar; | ||
int your = 0; | ||
|
||
void setup(){ | ||
//sensores para ir para algum canto | ||
for (int i = 4; i<=7; i++){ pinMode(i, INPUT_PULLUP); } | ||
|
||
//sensores qual q ta | ||
for (int i = 8; i<=11; i++){ pinMode(i, INPUT_PULLUP); } | ||
|
||
|
||
//LEDS | ||
for (int i = 22; i <= 28; i++){ pinMode(i, OUTPUT); } | ||
|
||
//motor | ||
pinMode(3, OUTPUT); | ||
pinMode(2, OUTPUT); | ||
|
||
Serial.begin(9600); | ||
} | ||
|
||
void getAndar(){ | ||
// pega qual ta | ||
if(digitalRead(4) == LOW){ andar = 4; } | ||
else if (digitalRead(5) == LOW){ andar = 3; } | ||
else if (digitalRead(6) == LOW){ andar = 2; } | ||
else { andar = 1; } | ||
} | ||
|
||
void getYourAndar(){ | ||
// pega qual ta | ||
if(digitalRead(8) == LOW){ | ||
your = 1; | ||
digitalWrite(22, LOW); | ||
digitalWrite(28, LOW); | ||
digitalWrite(25, LOW); | ||
digitalWrite(26, LOW); | ||
digitalWrite(27, LOW); | ||
digitalWrite(23, HIGH); | ||
digitalWrite(24, HIGH); | ||
} | ||
|
||
else if (digitalRead(9) == LOW){ | ||
your = 2; | ||
digitalWrite(22, HIGH); | ||
digitalWrite(23, HIGH); | ||
digitalWrite(28, HIGH); | ||
digitalWrite(26, HIGH); | ||
digitalWrite(25, HIGH); | ||
digitalWrite(24, LOW); | ||
digitalWrite(27, LOW); | ||
} | ||
|
||
else if (digitalRead(10) == LOW){ | ||
your = 3; | ||
digitalWrite(22, HIGH); | ||
digitalWrite(23, HIGH); | ||
digitalWrite(28, HIGH); | ||
digitalWrite(24, HIGH); | ||
digitalWrite(25, HIGH); | ||
digitalWrite(26, LOW); | ||
digitalWrite(27, LOW); | ||
} | ||
|
||
else if (digitalRead(11) == LOW) { | ||
your = 4; | ||
digitalWrite(23, HIGH); | ||
digitalWrite(24, HIGH); | ||
digitalWrite(28, HIGH); | ||
digitalWrite(27, HIGH); | ||
digitalWrite(22, LOW); | ||
digitalWrite(25, LOW); | ||
digitalWrite(26, LOW); | ||
} | ||
|
||
else { | ||
your = 0; | ||
digitalWrite(22, LOW); | ||
digitalWrite(28, LOW); | ||
digitalWrite(25, LOW); | ||
digitalWrite(26, LOW); | ||
digitalWrite(27, LOW); | ||
digitalWrite(23, LOW); | ||
digitalWrite(24, LOW); | ||
} | ||
} | ||
|
||
void move(){ | ||
if(your < andar){ | ||
digitalWrite(3, HIGH); | ||
}else{ | ||
digitalWrite(2, HIGH); | ||
} | ||
} | ||
|
||
void goNext(){ | ||
while(andar != your){ | ||
move(); | ||
getAndar(); | ||
} | ||
} | ||
|
||
void loop() | ||
{ | ||
getAndar(); | ||
getYourAndar(); | ||
Serial.print("qual ta --> "); | ||
Serial.println(andar); | ||
if(your != 0){ goNext(); } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Elevator with arduino | ||
|
||
This is a project I helped by coding for some friends of mine from my former school. | ||
We created that to a thecnology week to demonstrate what we were doing on the eletronics course. | ||
|
||
|
||
![Elevator photo](./assets/elevator.jpg) | ||
|
||
My friends were in charge of doing eletric/eletronic part of the project, and I created the code that you can see on the `.ino` file. | ||
|
||
The operation is simple, you only need to click on a button to select a floor and, when the elevator reach the selected floor, you'll be able to select another one, as a common elevator. | ||
|
||
## Demonstration | ||
|
||
|
||
|
||
https://user-images.githubusercontent.com/75098594/193454695-da2093b5-357b-4aa3-b0b5-98036e6be475.mp4 | ||
|