Devices & Components
Arduino Nano
Infrared Emitter, 30 °
Resistor 220 ohm
Photodiode, 35 °
Hardware & Tools
Soldering iron (generic)
Solder Wire, Lead Free
3D Printer (generic)
Software & Tools
Arduino IDE
Project description
Code
Infrared Detect and Select Floors
arduino
This is the main code of our system. It determines which button is bushed and which floor is detected. Right now it is now linked to a specific elevator so the code is not workable. Figure out how your elevator communication works and then change the part that needs to be changed.
1/* 2 InfraredDetectAndSelectFloor 3 4 This program is used to read values from all ports you assigned. Change the value of "NumberOfButton" to fit your target elevator. Be sure to assign the ports manually. 5 6 Now we have only assigned 1 port so only A0 is used. if you want to used both A0 and A1 for inputs, change NumberOfButton to 2 and set IR_REC[NumberOfButton] to {A0,A1}. 7 8 Author: Sky Song 9*/ 10 11int const NumberOfButton = 1; //Number of buttons of the target elevator. Remeber if there are more than 8 buttons, you need to use another Arduino Nano 12int IR_REC[NumberOfButton] = {A0}; //Assign photodiodes analog port numbers, A0 is used for testing 1 block 13int tolerance = 20; //variable that defines tolerance, 20 is generally a good value in our testing 14 15int UpperBound[NumberOfButton], LowerBound[NumberOfButton]; 16 17 18 19 20 21void setup() 22{ 23 Serial.begin(9600); 24 for(int i = 0; i< NumberOfButton; i++) 25 { 26 pinMode(IR_REC[i], INPUT); 27 } 28 29 //Get the initial value of all ports when starting 30 for(int i = 0; i< NumberOfButton; i++) 31 { 32 int InitValue[NumberOfButton]; 33 34 //Assign inital values to all ports 35 for(int i = 0; i< NumberOfButton; i++) 36 { 37 InitValue[i] = analogRead(IR_REC[i]); 38 for(int j = 0; j < 200; j++) //Sample 200 times and get a more accurate mean number of the inital value of the ith port 39 { 40 InitValue[i] = InitValue[i] + analogRead(IR_REC[i]); 41 InitValue[i] = InitValue[i] / 2; 42 } 43 } 44 45 //establish the tolerance range 46 UpperBound[i] = InitValue[i] + tolerance; 47 LowerBound[i] = InitValue[i] - tolerance; 48 } 49 50 51 Serial.println("Ready!"); 52} 53 54 55 56 57 58void loop() 59{ 60 for(int i = 0; i < NumberOfButton; i++) 61 { 62 int average = analogRead(IR_REC[i]); 63 for(int j = 0; j < 20; j++)//To get an average value to avoid fluctuations 64 { 65 average = average + analogRead(IR_REC[i]); 66 average = average / 2; 67 } 68 69 //if the port just scanned is within the tolerance range (been pressed), then do some action 70 if(average <= UpperBound and average >= LowerBound){} 71 else 72 { 73 Serial.println("pressed");//Here comes the actual action need to be done. We can change it to adapt the elevator control unit to select floors. Right now it's printing "pressed" onto the monitor 74 } 75 if(i < NumberOfButton) i = 0;//Reset when finish scaning all ports 76 } 77} 78
Infrared Detect and Select Floors
arduino
This is the main code of our system. It determines which button is bushed and which floor is detected. Right now it is now linked to a specific elevator so the code is not workable. Figure out how your elevator communication works and then change the part that needs to be changed.
1/* 2 InfraredDetectAndSelectFloor 3 4 This program is used to read values from all ports you assigned. Change the value of "NumberOfButton" to fit your target elevator. Be sure to assign the ports manually. 5 6 Now we have only assigned 1 port so only A0 is used. if you want to used both A0 and A1 for inputs, change NumberOfButton to 2 and set IR_REC[NumberOfButton] to {A0,A1}. 7 8 Author: Sky Song 9*/ 10 11int const NumberOfButton = 1; //Number of buttons of the target elevator. Remeber if there are more than 8 buttons, you need to use another Arduino Nano 12int IR_REC[NumberOfButton] = {A0}; //Assign photodiodes analog port numbers, A0 is used for testing 1 block 13int tolerance = 20; //variable that defines tolerance, 20 is generally a good value in our testing 14 15int UpperBound[NumberOfButton], LowerBound[NumberOfButton]; 16 17 18 19 20 21void setup() 22{ 23 Serial.begin(9600); 24 for(int i = 0; i< NumberOfButton; i++) 25 { 26 pinMode(IR_REC[i], INPUT); 27 } 28 29 //Get the initial value of all ports when starting 30 for(int i = 0; i< NumberOfButton; i++) 31 { 32 int InitValue[NumberOfButton]; 33 34 //Assign inital values to all ports 35 for(int i = 0; i< NumberOfButton; i++) 36 { 37 InitValue[i] = analogRead(IR_REC[i]); 38 for(int j = 0; j < 200; j++) //Sample 200 times and get a more accurate mean number of the inital value of the ith port 39 { 40 InitValue[i] = InitValue[i] + analogRead(IR_REC[i]); 41 InitValue[i] = InitValue[i] / 2; 42 } 43 } 44 45 //establish the tolerance range 46 UpperBound[i] = InitValue[i] + tolerance; 47 LowerBound[i] = InitValue[i] - tolerance; 48 } 49 50 51 Serial.println("Ready!"); 52} 53 54 55 56 57 58void loop() 59{ 60 for(int i = 0; i < NumberOfButton; i++) 61 { 62 int average = analogRead(IR_REC[i]); 63 for(int j = 0; j < 20; j++)//To get an average value to avoid fluctuations 64 { 65 average = average + analogRead(IR_REC[i]); 66 average = average / 2; 67 } 68 69 //if the port just scanned is within the tolerance range (been pressed), then do some action 70 if(average <= UpperBound and average >= LowerBound){} 71 else 72 { 73 Serial.println("pressed");//Here comes the actual action need to be done. We can change it to adapt the elevator control unit to select floors. Right now it's printing "pressed" onto the monitor 74 } 75 if(i < NumberOfButton) i = 0;//Reset when finish scaning all ports 76 } 77} 78
Downloadable files
Schematic for 1 block
This is the diagram for 1 block to show its connection to Arduino Nano
Schematic for 1 block

Schematics for 2 blocks
This is the diagram for 1 block to show its connection to Arduino Nano. This shows how multiple blocks are connected electrically.
Schematics for 2 blocks

Schematic for 1 block
This is the diagram for 1 block to show its connection to Arduino Nano
Schematic for 1 block

Schematics for 2 blocks
This is the diagram for 1 block to show its connection to Arduino Nano. This shows how multiple blocks are connected electrically.
Schematics for 2 blocks

Documentation
Reference
The reference for the final effect. NOT an actual component. The big buttons on the back panel are the original buttons of a elevator and the cylinders on the blocks are infrared emitter and photodiodes. Arduino Nano will be placed into the big box on the bottom.
Reference
Reference
The reference for the final effect. NOT an actual component. The big buttons on the back panel are the original buttons of a elevator and the cylinders on the blocks are infrared emitter and photodiodes. Arduino Nano will be placed into the big box on the bottom.
Reference
Block
"Blocks" build up the whole system and are the main frames.
Block
Comments
Only logged in users can leave comments