Elevator project for technology class
FunduinoPublished on
Ein Aufzugmodell aus Aluminiumprofilen aufbauen und programmieren
The elevator project in class
Inspect and sort all components
Prepare the upper crossbar profile
1 / 3
Build the base
1 / 7
Install the motor and photoelectric sensors
1 / 5
Attach the motor to the top of the frame
1 / 4
Insert the gondola and cable
1 / 4
Base plate and stepper motor driver
1 / 3
Exercises with standard materials
Tasks with supplementary materials
Example program: four floors with OLED display
Four floors with buttons, light barriers, and an OLED display
#include <Stepper.h> // Add the program library.
int SPU = 2048; // Steps per revolution.
Stepper Motor(SPU, 11,9,10,8); // The stepper motor is named "Motor", and the pins it is connected to are specified.
int T1=22, T2=2, T3=3, T4=4, S1=17, S2=16, S3=15, S4=14;// Assign pins for buttons and sensors
int sT1=0, sT2=0, sT3=0, sT4=0, sS1=0, sS2=0, sS3=0, sS4=0;// Assign status variables for buttons and sensors
int EtageSoll=0, EtageIst=0;// Input storage for buttons and sensors
int F=0; // Variable for operating mode or pause mode
int EtageAlt=0;
int EtageSollAlt=0;
// Initialize OLED
#include <Wire.h>
#include "SSD1306Ascii.h"
#include "SSD1306AsciiWire.h"
#define I2C_ADDRESS 0x3C
SSD1306AsciiWire oled;
void setup() // Setup begins here.
{
Serial.begin(9600);
Motor.setSpeed(6); // Set the speed in revolutions per minute.
pinMode (T1, INPUT);
pinMode (T2, INPUT);
pinMode (T3, INPUT);
pinMode (T4, INPUT);
pinMode (S1, INPUT);
pinMode (S2, INPUT);
pinMode (S3, INPUT);
pinMode (S4, INPUT);
// OLED setup
Wire.begin();
Wire.setClock(400000L);
oled.begin(&Adafruit128x64, I2C_ADDRESS);
oled.setFont(Verdana12); // Select the font
oled.clear(); // Clear the current display
oled.println("TESTFAHRT"); // Text on the first line. "Println" adds a line break.
oled.println("Aufzug faehrt"); // Text on the second line. "Println" adds a line break.
oled.print("zum Startpunkt"); // Text on the third line.
delay (2000);
// Move the elevator to the starting position
for (int i = 0; i <= 1; i++)
{
Motor.step(-1);
sS1 = digitalRead(S1);
if (sS1!=1) i=0;
Serial.println(sS1);
}
EtageIst=0;
EtageSoll=0;
delay(1000);
Serial.println("Setup beendet");
oled.clear();
oled.println("Betriebsbereit");
oled.print("Etage: ");
oled.println(EtageIst);
oled.print("Ziel: ");
oled.print(EtageSoll);
}
void loop()
{
// Input
Serial.print("Waiting for floor selection ");
sT1 = digitalRead(T1); if (sT1==1) EtageSoll=0;
sT2 = digitalRead(T2); if (sT2==1) EtageSoll=1;
sT3 = digitalRead(T3); if (sT3==1) EtageSoll=2;
sT4 = digitalRead(T4); if (sT4==1) EtageSoll=3;
// Save the previous position before reading the new one so changes can be detected
// Read the current elevator position
sS1 = digitalRead(S1); if (sS1==1) EtageIst=0;
sS2 = digitalRead(S2); if (sS2==1) EtageIst=1;
sS3 = digitalRead(S3); if (sS3==1) EtageIst=2;
sS4 = digitalRead(S4); if (sS4==1) EtageIst=3;
Serial.print(sT1);
Serial.print(EtageSoll);
Serial.println(EtageIst);
// Operating mode
if (EtageSoll-EtageIst >0) Motor.step(8); // If the value is greater than 0 (the target floor is higher than the elevator's position), move up.
if (EtageSoll-EtageIst <0) Motor.step(-8); // If the value is less than 0 (the target floor is lower than the elevator's position), move down.
// Display control
if (EtageAlt!=EtageIst || EtageSoll!=EtageSollAlt) // Update the display with the new values if the elevator reaches another floor while moving, OR if the floor selection changes
{
oled.clear();
oled.println("Betriebsbereit");
oled.print("Etage: ");
oled.println(EtageIst);
oled.print("Ziel: ");
oled.print(EtageSoll);
}
EtageAlt=EtageIst;
EtageSollAlt=EtageSoll;
}The older version V1.0
1 / 2
Rate the instructions