Asansör sistemi gelişmiş bir ev ve iş yeri otomasyonudur.Genellikle yüksek katlı binalarda insan taşımacılığı yapmak için kullanılır.İnsan taşıyan asansörler yük taşıma asansörlerine göre daha küçük ve düşük maliyetlidir.Asansörlerde kat arttıkça kablo boyu uzadığından kişi sayısı düşer.Emniyet katsayıları çok yüksek şekilde tasarlanırlar, örnek vermek gerekirse 4 kişilik yazan bir asansör aslında 40 kişi taşıyabilecek şekilde tasarlanır.Bu genel kültür bilgisini verdikten sonra projemize geçelim.Projemiz basit bir asansör sistemi ve otomasyonudur.
#define switchFloor1 0
#define switchFloor2 2
#define switchFloor3 3
#define photocellFloor2 0
#define photocellFloor3 1
#define steps 520
#define stepperPin1 10
#define stepperPin2 11
#define stepperPin3 12
#define stepperPin4 13
#define delaytime 10
#define A 4 // (A = 11) Corresponding arduino pins for the segments on the 7 segment LED display
#define B 5 // (B = 7)
#define C 6 // (C = 4)
#define D 7 // (D = 2)
#define E 8 // (E = 1)
#define f 10 // Not used in the circuit
#define G 9 //(G = 5)
#define DP 11 // Not used in the circuit
#define CC4 1 // (CC4 = 13) Pin driving common cathodes
boolean firstRun = true;
int currentFloor = 1; // Used to save the current floor. This value is changed with the switches and with the readings done by the photocells
long debounceTime = 200; // The switch's debounce time
int secondFloorReading = 0; // The analog reading from the sensor divider (for floor 2 and 3)
int thirdFloorReading = 0;
byte numbers[3][8] = {{0,1,1,0,0,0,0,0},{1,1,0,1,1,0,1,0},{1,1,1,1,0,0,1,0}};
const int segments[8] = { A, B, C, D, E, f, G, DP }; // This defines an array that contains the arduino pins for each segment
void setup(){
Serial.begin(9600); // Initialize serial port
pinMode(A, OUTPUT); // Set anodes low to make sure all segments are off
digitalWrite(A,LOW);
pinMode(B, OUTPUT);
digitalWrite(B,LOW);
pinMode(C, OUTPUT);
digitalWrite(C,LOW);
pinMode(D, OUTPUT);
digitalWrite(D,LOW);
pinMode(E, OUTPUT);
digitalWrite(E,LOW);
pinMode(f, OUTPUT); // This pin will not be connected to the board
digitalWrite(f,LOW);
pinMode(G, OUTPUT);
digitalWrite(G,LOW);
pinMode(DP, OUTPUT); // This pin will not be connected to the board
digitalWrite(DP,LOW);
pinMode(CC4, OUTPUT); // Set catodes high to turn off digit
digitalWrite(CC4,HIGH);
pinMode(switchFloor1, INPUT); // Define the arduino pins for the swi tches as inputs
pinMode(switchFloor2, INPUT);
pinMode(switchFloor3, INPUT);
pinMode(stepperPin1, OUTPUT); // Define the the arduino pins for the stepper's coils as outputs
pinMode(stepperPin2, OUTPUT);
pinMode(stepperPin3, OUTPUT);
pinMode(stepperPin4, OUTPUT);
}
void loop(){
secondFloorReading = analogRead(photocellFloor2); // Get a reading from the photocells to verify the current floor
thirdFloorReading = analogRead(photocellFloor3);
Serial.print("Analog reading (Second floor) = ");
Serial.println(secondFloorReading); // the raw analog reading
Serial.print("Analog reading (Third floor) = ");
Serial.println(thirdFloorReading); // the raw analog reading
delay(1000);
if(secondFloorReading > 790 && thirdFloorReading > 790) // Check if the elevator is in the first floor
{
setSegments(0, CC4); // Turn on the segments that display the number 1
currentFloor = 1; // Set the current floor to 1
// The elevator is meant to start at the first floor
}
else if(secondFloorReading < 750) // Check if the elevator is in the second floor
{
setSegments(1, CC4); // Turn on the segments that display the number 2
currentFloor = 2;
}
else if(thirdFloorReading < 750) // Check if the elevator is in the third floor { setSegments(2, CC4); // Turn on the segments that display the number 3 currentFloor = 3; } // The following if statement will only allow the switch's input if the current floor is not already 1 // The coils in the stepper motor will go backwards if the elevator // is on either floor 2 or floor 3 // If it is on floor 3, it will go backwards twice the number of steps if(readSwitch(switchFloor1, debounceTime) == true && currentFloor != 1){ if(currentFloor == 2){ Serial.println("going down"); int numberOfSteps = steps+90; step_OFF(); // Turning all coils off while(numberOfSteps>0){
backward(); // Going backward
numberOfSteps -- ; // Counting down the number of steps
}
}
else if(currentFloor == 3){
Serial.println("going down");
int numberOfSteps = (steps*2)+80;
step_OFF(); // Turning all coils off
while(numberOfSteps>0){
backward(); // Going backward
numberOfSteps -- ; // Counting down the number of steps
}
}
currentFloor = 1; // Sets the currentFloor to 1 since the elevator is now at the first floor
delay(1000);
}
// The following if statement will only allow the switch's input if the current floor is not already 2
// The coils in the stepper motor will go forward or backwards if the elevator
// is on either floor 1 or floor 3, respectively
if(readSwitch(switchFloor2, debounceTime) == true && currentFloor != 2){
if(currentFloor == 1){
Serial.println("going up");
int numberOfSteps = steps+90;
step_OFF(); // Turning all coils off
while(numberOfSteps>0){
forward(); // Going forward
numberOfSteps -- ; // Counting down the number of steps
}
}
else if(currentFloor == 3){
Serial.println("going down");
int numberOfSteps = steps+5;
step_OFF(); // Turning all coils off
while(numberOfSteps>0){
backward(); // Going forward
numberOfSteps -- ; // Counting down the number of steps
}
}
currentFloor = 2; // Sets the currentFloor to 2 since the elevator is now at the second floor
delay(2000);
}
if(readSwitch(switchFloor3, debounceTime) == true && currentFloor != 3){ //
if(currentFloor == 1){
Serial.println("going up");
int numberOfSteps = (steps*2)+80; // Twice the number of steps to reach floor 3
step_OFF(); // Turning all coils off
while(numberOfSteps>0){
forward(); // Going forward
numberOfSteps -- ; // Counting down the number of steps
}
}
else if(currentFloor == 2){
Serial.println("going up");
int numberOfSteps = steps+5;
step_OFF(); // Turning all coils off
while(numberOfSteps>0){
forward(); // Going forward
numberOfSteps -- ; // Counting down the number of steps
}
}
currentFloor = 3; // Sets the currentFloor to 2 since the elevator is now at the second floor
delay(2000);
}
Serial.println(currentFloor);
}
İncelemeler
Henüz inceleme yapılmadı.