Elevator Programming Code
Elevator Programming Code
h>
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Stepper test!");
motor_freight.setSpeed(80); // 60 rpm
motor_passenger.setSpeed(100);
void loop() {
motor_freight.step(1, FORWARD, SINGLE);
motor_passenger.step(1, FORWARD, SINGLE);
// motor_freight.step(100, BACKWARD, SINGLE);
// delay(500);
// motor_passenger.step(200, FORWARD, SINGLE);
// delay(500);
}
#include <AFMotor.h>
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Stepper test!");
motor_freight.setSpeed(60); // 60 rpm
motor_passenger.setSpeed(80);
void loop() {
motor_freight.step(300, FORWARD, SINGLE);
delay(500);
motor_freight.step(100, BACKWARD, SINGLE);
delay(500);
motor_passenger.step(200, FORWARD, SINGLE);
delay(500);
motor_passenger.step(200, BACKWARD, SINGLE);
delay(500);
}
file:///Users/mg/Documents/M2%20Thesis%202008/Tech/03%20Arduino%20Code%20/AFMotornoservo.txt
#include <avr/io.h>
#include "WProgram.h"
#include "AFMotor.h"
AFMotorController::AFMotorController(void) {
}
void AFMotorController::enable(void) {
// setup the latch
LATCH_DDR |= _BV(LATCH);
ENABLE_DDR |= _BV(ENABLE);
CLK_DDR |= _BV(CLK);
SER_DDR |= _BV(SER);
latch_state = 0;
latch_tx(); // "reset"
void AFMotorController::latch_tx(void) {
uint8_t i;
/******************************************
MOTORS
******************************************/
MC.enable();
switch (num) {
case 1:
latch_state &= ~_BV(MOTOR1_A) & ~_BV(MOTOR1_B); // set both motor pins to 0
MC.latch_tx();
switch (cmd) {
case FORWARD:
latch_state |= _BV(a);
latch_state &= ~_BV(b);
MC.latch_tx();
break;
case BACKWARD:
latch_state &= ~_BV(a);
latch_state |= _BV(b);
MC.latch_tx();
break;
case RELEASE:
latch_state &= ~_BV(a);
latch_state &= ~_BV(b);
MC.latch_tx();
break;
}
}
/******************************************
STEPPERS
******************************************/
revsteps = steps;
steppernum = num;
if (steppernum == 1) {
latch_state &= ~_BV(MOTOR1_A) & ~_BV(MOTOR1_B) &
~_BV(MOTOR2_A) & ~_BV(MOTOR2_B); // all motor pins to 0
MC.latch_tx();
MC.latch_tx();
void AF_Stepper::release(void) {
if (steppernum == 1) {
latch_state &= ~_BV(MOTOR1_A) & ~_BV(MOTOR1_B) &
~_BV(MOTOR2_A) & ~_BV(MOTOR2_B); // all motor pins to 0
MC.latch_tx();
} else if (steppernum == 2) {
latch_state &= ~_BV(MOTOR3_A) & ~_BV(MOTOR3_B) &
~_BV(MOTOR4_A) & ~_BV(MOTOR4_B); // all motor pins to 0
MC.latch_tx();
}
}
while (steps--) {
onestep(dir, style);
delay(uspers/1000); // in ms
steppingcounter += (uspers % 1000);
if (steppingcounter >= 1000) {
delay(1);
steppingcounter -= 1000;
}
}
}
if (steppernum == 1) {
a = _BV(MOTOR1_A);
b = _BV(MOTOR2_A);
c = _BV(MOTOR1_B);
d = _BV(MOTOR2_B);
} else if (steppernum == 2) {
a = _BV(MOTOR3_A);
b = _BV(MOTOR4_A);
c = _BV(MOTOR3_B);
d = _BV(MOTOR4_B);
} else {
return;
}
if (dir == FORWARD)
step = (step + 1) % 8;
else
step = (step + 7) % 8;
} else { // go to the next even step
if (dir == FORWARD)
step = (step + 2) % 8;
else
step = (step + 6) % 8;
}
} else if (style == DOUBLE) {
if (! (step % 2)) { // we're at an even step, weird
if (dir == FORWARD)
step = (step + 1) % 8;
else
step = (step + 7) % 8;
} else { // go to the next odd step
if (dir == FORWARD)
step = (step + 2) % 8;
else
step = (step + 6) % 8;
}
} else if (style == INTERLEAVE) {
if (dir == FORWARD)
step = (step + 1) % 8;
else
step = (step + 7) % 8;
}
// release all
latch_state &= ~a & ~b & ~c & ~d; // all motor pins to 0
switch (step) {
case 0:
latch_state |= a; // energize coil 1 only
break;
case 1:
latch_state |= a | b; // energize coil 1+2
break;
case 2:
latch_state |= b; // energize coil 2 only
break;
case 3:
latch_state |= b | c; // energize coil 2+3
break;
case 4:
latch_state |= c; // energize coil 3 only
break;
case 5:
latch_state |= c | d; // energize coil 3+4
break;
case 6:
latch_state |= d; // energize coil 4 only
break;
case 7:
latch_state |= d | a; // energize coil 1+4
break;
}
MC.latch_tx();
}
int motorPin1 = 8;
int motorPin2 = 9;
int motorPin3 = 10;
int motorPin4 = 11;
int ledPin = 13;
int delayTime = 1000;
void setup() {
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(motorPin3, OUTPUT);
pinMode(motorPin4, OUTPUT);
pinMode(ledPin, OUTPUT);
void loop() {
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
delay(delayTime);
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
delay(delayTime);
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1000); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(1000); // waits for a second
}
// H bridge Trouble Shooting B
int motorPin1 = 8;
int motorPin2 = 9;
int motorPin3 = 10;
int motorPin4 = 11;
int ledPin = 13;
int delayTime = 10;
void setup() {
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(motorPin3, OUTPUT);
pinMode(motorPin4, OUTPUT);
pinMode(ledPin, OUTPUT);
void loop() {
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
delay(delayTime);
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
delay(delayTime);
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(1); // waits for a second
}
// Igoe Code modified
#include <Stepper.h>
/*
Stepper Motor Controller
language: Wiring/Arduino
The motor moves 100 steps in one direction, then 100 in the other.
*/
// define the pins that the motor is attached to. You can use
// any digital I/O pins.
#include <Stepper.h>
void setup() {
// set the motor speed at 60 RPMS:
myStepper.setSpeed(120);
void loop() {
// Step forward 100 steps:
Serial.println("Forward");
myStepper.step(100);
delay(500);
// Step backward 100 steps:
Serial.println("Backward");
myStepper.step(-100);
delay(500);
void setup() {
//start serial
Serial.begin(9600);
void loop() {
//white space
Serial.println("Marnie");
//delay so all these print satements can keep up.
delay(500);
pinMode(myClockPin, OUTPUT);
pinMode(myDataPin, INPUT);
//we will be holding the clock pin high 8 times (0,..,7) at the
//end of each time through the for loop
//at the begining of each loop when we set the clock low, it will
//be doing the necessary low to high drop to cause the shift
//register's DataPin to change state based on the value
//of the next bit in its serial information flow.
//The register transmits the information about the pins from pin 7 to pin 0
//so that is why our function counts down
for (i=7; i>=0; i--)
{
digitalWrite(myClockPin, 0);
delayMicroseconds(0.2);
temp = digitalRead(myDataPin);
if (temp) {
pinState = 1;
//set the bit to 0 no matter what
myDataIn = myDataIn | (1 << i);
}
else {
//turn it off -- only necessary for debuging
//print statement since myDataIn starts as 0
pinState = 0;
}
digitalWrite(myClockPin, 1);
}
//debuging print statements whitespace
//Serial.println();
//Serial.println(myDataIn, BIN);
return myDataIn;
}
//15 March Shift Register 1
void setup() {
//start serial
Serial.begin(9600);
void loop() {
//white space
Serial.println("Marnie");
//delay so all these print satements can keep up.
delay(500);
pinMode(myClockPin, OUTPUT);
pinMode(myDataPin, INPUT);
//we will be holding the clock pin high 8 times (0,..,7) at the
//end of each time through the for loop
//at the begining of each loop when we set the clock low, it will
//be doing the necessary low to high drop to cause the shift
//register's DataPin to change state based on the value
//of the next bit in its serial information flow.
//The register transmits the information about the pins from pin 7 to pin 0
//so that is why our function counts down
for (i=7; i>=0; i--)
{
digitalWrite(myClockPin, 0);
delayMicroseconds(0.2);
temp = digitalRead(myDataPin);
if (temp) {
pinState = 1;
//set the bit to 0 no matter what
myDataIn = myDataIn | (1 << i);
}
else {
//turn it off -- only necessary for debuging
//print statement since myDataIn starts as 0
pinState = 0;
}
digitalWrite(myClockPin, 1);
}
//debuging print statements whitespace
//Serial.println();
//Serial.println(myDataIn, BIN);
return myDataIn;
}
// 1 April Shift Register Trials A
void setup() {
//start serial
Serial.begin(9600);
void loop() {
if (switchVar1 == 1)
{floorcount = 1;}
else if (switchVar1 == 2)
{floorcount = 2;
//else if (switchVar1 == 4)
// {floorcount = 3;
// else if (switchVar1 = 8)
// {floorcount = 4;}
// else if (switchVar1 = 16)
// {floorcount = 5;}
// else if (switchVar1 = 32)
// {floorcount = 6;}
// else if (switchVar1 = 64)
// {floorcount = 7;}
// else if (switchVar1 = 128)
// {floorcount = 8;}
digitalWrite(ledPin,1);
delay(1000);
digitalWrite (ledPin,0);
}
pinMode(myClockPin, OUTPUT);
pinMode(myDataPin, INPUT);
//we will be holding the clock pin high 8 times (0,..,7) at the
//end of each time through the for loop
//at the begining of each loop when we set the clock low, it will
//be doing the necessary low to high drop to cause the shift
//register's DataPin to change state based on the value
//of the next bit in its serial information flow.
//The register transmits the information about the pins from pin 7 to pin 0
//so that is why our function counts down
for (i=7; i>=0; i--)
{
digitalWrite(myClockPin, 0);
delayMicroseconds(0.2);
temp = digitalRead(myDataPin);
if (temp) {
pinState = 1;
//set the bit to 0 no matter what
myDataIn = myDataIn | (1 << i);
}
else {
//turn it off -- only necessary for debuging
//print statement since myDataIn starts as 0
pinState = 0;
}
//Debuging print statements
// Serial.print(pinState);
//Serial.print("Marnie");
//Serial.println (dataIn, BIN);
digitalWrite(myClockPin, 1);
}
//debuging print statements whitespace
//Serial.println();
//Serial.println(myDataIn, BIN);
return myDataIn;
}
// 1 April Shift Register Trials A1
void setup() {
//start serial
Serial.begin(9600);
void loop() {
if (switchVar1 == 1)
{floorcount = 1;
// else if (switchVar1 == 2)
// {floorcount = 2;}
// else if (switchVar1 == 4)
// {floorcount = 3;}
// else if (switchVar1 == 8)
// {floorcount = 4;}
// else if (switchVar1 == 16)
// {floorcount = 5;}
// else if (switchVar1 == 32)
// {floorcount = 6;}
// else if (switchVar1 == 64)
// {floorcount = 7;}
// else if (switchVar1 == 128)
// {floorcount = 8;}
// else if (switchVar2 == 1)
// {//floorcount = freight move up until released;
// }
// else if (switchVar2 == 2)
// {//floorcount = freight move down until released;
// }
// else if (switchVar2 == 4)
// {//elevator_loveletter;
//}
// else if (switchVar2 == 8)
// {//big_brother;
//}
// else if (switchVar2 == 16)
// {//bureaucratic_prostitution;
//}
// else if (switchVar2 == 32)
// {//coordinates_of_social_space;
//}
// else if (switchVar2 == 64)
// {//entrapment;
//}
//else if (switchVar2 == 128)
// {//the_fear;
//}
digitalWrite(ledPin,1);
delay(1000);
digitalWrite (ledPin,0);
}
}
pinMode(myClockPin, OUTPUT);
pinMode(myDataPin, INPUT);
//we will be holding the clock pin high 8 times (0,..,7) at the
//end of each time through the for loop
//at the begining of each loop when we set the clock low, it will
//be doing the necessary low to high drop to cause the shift
//register's DataPin to change state based on the value
//of the next bit in its serial information flow.
//The register transmits the information about the pins from pin 7 to pin 0
//so that is why our function counts down
for (i=7; i>=0; i--)
{
digitalWrite(myClockPin, 0);
delayMicroseconds(0.2);
temp = digitalRead(myDataPin);
if (temp) {
pinState = 1;
//set the bit to 0 no matter what
myDataIn = myDataIn | (1 << i);
}
else {
//turn it off -- only necessary for debuging
//print statement since myDataIn starts as 0
pinState = 0;
}
digitalWrite(myClockPin, 1);
}
//debuging print statements whitespace
//Serial.println();
//Serial.println(myDataIn, BIN);
return myDataIn;
}
// 1 April Shift Register Trial B
void setup() {
//start serial
Serial.begin(9600);
void loop() {
if (switchVar1 == 1)
{floorcount = 1;}
//else if (switchVar1 == 2)
//{floorcount = 2;}
//else if (switchVar1 == 4)
// {floorcount = 3;}
// else if (switchVar1 = 8)
// {floorcount = 4;}
// else if (switchVar1 = 16)
// {floorcount = 5;}
// else if (switchVar1 = 32)
// {floorcount = 6;}
// else if (switchVar1 = 64)
// {floorcount = 7;}
// else if (switchVar1 = 128)
// {floorcount = 8;}
// else if (switchVar1 = 256)
// {floorcount = freight move up until released;}
// else if (switchVar1 = 512)
// {floorcount = freight move down until released;}
// else if (switchVar1 = 1024)
// {elevator_loveletter;}
// else if (switchVar1 = 2048)
// {big_brother;}
// else if (switchVar1 = 4096)
// do {bureaucratic_prostitution;}
// else if (switchVar1 = 8192)
// do {coordinates_of_social_space;}
//else if (switchvar1 = 16384)
// {entrapment;}
// else if (switchvar1 = 32768)
//{the_fear;}
digitalWrite(ledPin,1);
delay(1000);
digitalWrite (ledPin,0);
}
pinMode(myClockPin, OUTPUT);
pinMode(myDataPin, INPUT);
//we will be holding the clock pin high 8 times (0,..,7) at the
//end of each time through the for loop
//at the begining of each loop when we set the clock low, it will
//be doing the necessary low to high drop to cause the shift
//register's DataPin to change state based on the value
//of the next bit in its serial information flow.
//The register transmits the information about the pins from pin 7 to pin 0
//so that is why our function counts down
for (i=7; i>=0; i--)
{
digitalWrite(myClockPin, 0);
delayMicroseconds(0.2);
temp = digitalRead(myDataPin);
if (temp) {
pinState = 1;
//set the bit to 0 no matter what
myDataIn = myDataIn | (1 << i);
}
else {
//turn it off -- only necessary for debuging
//print statement since myDataIn starts as 0
pinState = 0;
}
digitalWrite(myClockPin, 1);
}
//debuging print statements whitespace
//Serial.println();
//Serial.println(myDataIn, BIN);
return myDataIn;
}
// 3 April Shift Register Trail A
void setup() {
//start serial
Serial.begin(9600);
void loop() {
if (switchVar1 == 1)
{floorcount = 1;}
else if (switchVar1 == 2)
{floorcount = 2;}
else if (switchVar1 == 4)
{floorcount = 3;}
else if (switchVar1 == 8)
{floorcount = 4;}
else if (switchVar1 == 16)
{floorcount = 5;}
else if (switchVar1 == 32)
{floorcount = 6;}
// else if (switchVar1 == 64)
// {floorcount = 7;}
// else if (switchVar1 == 128)
// {floorcount = 8;}
// else if (switchVar2 == 2)
//{//floorcount = freight move down until released;
// }
// else if (switchVar2 == 4)
// {//elevator_loveletter;
//}
// else if (switchVar2 == 8)
//{//big_brother;
//}
//else if (switchVar2 == 16)
//{//bureaucratic_prostitution;
//}
//else if (switchVar2 == 32)
//{//coordinates_of_social_space;
//}
//else if (switchVar2 == 64)
//{//entrapment;
//}
//else if (switchVar2 == 128)
//{//the_fear;
//}
digitalWrite(ledPin,1);
delay(1000);
digitalWrite (ledPin,0);
}
}
pinMode(myClockPin, OUTPUT);
pinMode(myDataPin, INPUT);
//we will be holding the clock pin high 8 times (0,..,7) at the
//end of each time through the for loop
//at the begining of each loop when we set the clock low, it will
//be doing the necessary low to high drop to cause the shift
//register's DataPin to change state based on the value
//of the next bit in its serial information flow.
//The register transmits the information about the pins from pin 7 to pin 0
//so that is why our function counts down
for (i=7; i>=0; i--)
{
digitalWrite(myClockPin, 0);
delayMicroseconds(0.2);
temp = digitalRead(myDataPin);
if (temp) {
pinState = 1;
//set the bit to 0 no matter what
myDataIn = myDataIn | (1 << i);
}
else {
//turn it off -- only necessary for debuging
//print statement since myDataIn starts as 0
pinState = 0;
}
digitalWrite(myClockPin, 1);
}
//debuging print statements whitespace
//Serial.println();
//Serial.println(myDataIn, BIN);
return myDataIn;
}
// 4 April Shift Register A
void setup() {
//start serial
Serial.begin(9600);
void loop() {
if (switchVar1 == 1)
{floorcount = 1;}
else if (switchVar1 == 2)
{floorcount = 2;}
else if (switchVar1 == 4)
{floorcount = 3;}
else if (switchVar1 == 8)
{floorcount = 4;}
else if (switchVar1 == 16)
{floorcount = 5;}
else if (switchVar1 == 32)
{floorcount = 6;}
// else if (switchVar1 == 64)
// {floorcount = 7;}
// else if (switchVar1 == 128)
// {floorcount = 8;}
else if (switchVar2 == 1)
{//floorcount = freight move up until released;
}
else if (switchVar2 == 2)
{//floorcount = freight move down until released;
}
else if (switchVar2 == 4)
{//elevator_loveletter;
}
else if (switchVar2 == 8)
{//big_brother;
}
else if (switchVar2 == 16)
{//bureaucratic_prostitution;
}
else if (switchVar2 == 32)
{//coordinates_of_social_space;
}
else if (switchvar2 == 64)
{//entrapment;
}
else if (switchvar2 == 128)
{//the_fear;
}
digitalWrite(ledPin,1);
delay(1000);
digitalWrite (ledPin,0);
}
}
pinMode(myClockPin, OUTPUT);
pinMode(myDataPin, INPUT);
//we will be holding the clock pin high 8 times (0,..,7) at the
//end of each time through the for loop
//at the begining of each loop when we set the clock low, it will
//be doing the necessary low to high drop to cause the shift
//register's DataPin to change state based on the value
//of the next bit in its serial information flow.
//The register transmits the information about the pins from pin 7 to pin 0
//so that is why our function counts down
for (i=7; i>=0; i--)
{
digitalWrite(myClockPin, 0);
delayMicroseconds(0.2);
temp = digitalRead(myDataPin);
if (temp) {
pinState = 1;
//set the bit to 0 no matter what
myDataIn = myDataIn | (1 << i);
}
else {
//turn it off -- only necessary for debuging
//print statement since myDataIn starts as 0
pinState = 0;
}
digitalWrite(myClockPin, 1);
}
//debuging print statements whitespace
//Serial.println();
//Serial.println(myDataIn, BIN);
return myDataIn;
}
// 6 April Shift Register Trial
void setup() {
//start serial
Serial.begin(9600);
void loop() {
if (switchVar1 == 1)
{floorcount = 1;}
else if (switchVar1 == 2)
{floorcount = 2;}
else if (switchVar1 == 4)
{floorcount = 3;}
else if (switchVar1 == 8)
{floorcount = 4;}
else if (switchVar1 == 16)
{floorcount = 5;}
else if (switchVar1 == 32)
{floorcount = 6;}
else if (switchVar1 == 64)
{floorcount = 7;}
// else if (switchVar1 == 128)
// {floorcount = 8;}
else if (switchVar2 == 1)
{//floorcount = freight move up until released;
}
else if (switchVar2 == 2)
{//floorcount = freight move down until released;
}
else if (switchVar2 == 4)
{//elevator_loveletter;
}
else if (switchVar2 == 8)
{//big_brother;
}
else if (switchVar2 == 16)
{//bureaucratic_prostitution;
}
else if (switchVar2 == 32)
{//coordinates_of_social_space;
}
else if (switchVar2 == 64)
{//entrapment;
}
else if (switchVar2 == 128)
{//the_fear;
}
digitalWrite(ledPin,1);
delay(1000);
digitalWrite (ledPin,0);
pinMode(myClockPin, OUTPUT);
pinMode(myDataPin, INPUT);
//we will be holding the clock pin high 8 times (0,..,7) at the
//end of each time through the for loop
//at the begining of each loop when we set the clock low, it will
//be doing the necessary low to high drop to cause the shift
//register's DataPin to change state based on the value
//of the next bit in its serial information flow.
//The register transmits the information about the pins from pin 7 to pin 0
//so that is why our function counts down
for (i=7; i>=0; i--)
{
digitalWrite(myClockPin, 0);
delayMicroseconds(0.2);
temp = digitalRead(myDataPin);
if (temp) {
pinState = 1;
//set the bit to 0 no matter what
myDataIn = myDataIn | (1 << i);
}
else {
//turn it off -- only necessary for debuging
//print statement since myDataIn starts as 0
pinState = 0;
}
digitalWrite(myClockPin, 1);
}
//debuging print statements whitespace
//Serial.println();
//Serial.println(myDataIn, BIN);
return myDataIn;
}
// 7 April Shift Register Trial A
void setup() {
//start serial
Serial.begin(9600);
void loop() {
if (switchVar1 == 1)
{floorcount = 1;
// else if (switchVar1 == 2)
// {floorcount = 2;}
// else if (switchVar1 == 4)
// {floorcount = 3;}
// else if (switchVar1 == 8)
// {floorcount = 4;}
// else if (switchVar1 == 16)
// {floorcount = 5;}
// else if (switchVar1 == 32)
// {floorcount = 6;}
// else if (switchVar1 == 64)
// {floorcount = 7;}
// else if (switchVar1 == 128)
// {floorcount = 8;}
// else if (switchVar2 == 1)
// {//floorcount = freight move up until released;
// }
// else if (switchVar2 == 2)
// {//floorcount = freight move down until released;
// }
// else if (switchVar2 == 4)
// {//elevator_loveletter;
//}
// else if (switchVar2 == 8)
// {//big_brother;
//}
// else if (switchVar2 == 16)
// {//bureaucratic_prostitution;
//}
// else if (switchVar2 == 32)
// {//coordinates_of_social_space;
//}
// else if (switchVar2 == 64)
// {//entrapment;
//}
//else if (switchVar2 == 128)
// {//the_fear;
//}
digitalWrite(ledPin,1);
delay(1000);
digitalWrite (ledPin,0);
}
}
pinMode(myClockPin, OUTPUT);
pinMode(myDataPin, INPUT);
//we will be holding the clock pin high 8 times (0,..,7) at the
//end of each time through the for loop
//at the begining of each loop when we set the clock low, it will
//be doing the necessary low to high drop to cause the shift
//register's DataPin to change state based on the value
//of the next bit in its serial information flow.
//The register transmits the information about the pins from pin 7 to pin 0
//so that is why our function counts down
for (i=7; i>=0; i--)
{
digitalWrite(myClockPin, 0);
delayMicroseconds(0.2);
temp = digitalRead(myDataPin);
if (temp) {
pinState = 1;
//set the bit to 0 no matter what
myDataIn = myDataIn | (1 << i);
}
else {
//turn it off -- only necessary for debuging
//print statement since myDataIn starts as 0
pinState = 0;
}
digitalWrite(myClockPin, 1);
}
//debuging print statements whitespace
//Serial.println();
//Serial.println(myDataIn, BIN);
return myDataIn;
}
// 9 April Shift Register Trial A
void setup() {
//start serial
Serial.begin(9600);
void loop() {
if (switchVar1 == 1)
{floorcount = 1;
// else if (switchVar1 == 2)
// {floorcount = 2;}
//else if (switchVar1 == 4)
// {floorcount = 3;}
//else if (switchVar1 == 8)
// {floorcount = 4;}
// else if (switchVar1 == 16)
// {floorcount = 5;}
//else if (switchVar1 == 32)
// {floorcount = 6;}
// else if (switchVar1 == 64)
// {floorcount = 7;
//else if (switchVar1 == 128)
// {floorcount = 8;}
// else if (switchVar2 == 2)
//{//floorcount = freight move down until released;
// }
// else if (switchVar2 == 4)
// {//elevator_loveletter;
//}
// else if (switchVar2 == 8)
// {//big_brother;
//}
// else if (switchVar2 == 16)
// {//bureaucratic_prostitution;
//}
// else if (switchVar2 == 32)
// {//coordinates_of_social_space;
//}
// else if (switchVar2 == 64)
// {//entrapment;
//}
//else if (switchVar2 == 128)
// {//the_fear;
//}
digitalWrite(ledPin,1);
delay(1000);
digitalWrite (ledPin,0);
}
}
pinMode(myClockPin, OUTPUT);
pinMode(myDataPin, INPUT);
//we will be holding the clock pin high 8 times (0,..,7) at the
//end of each time through the for loop
//at the begining of each loop when we set the clock low, it will
//be doing the necessary low to high drop to cause the shift
//register's DataPin to change state based on the value
//of the next bit in its serial information flow.
//The register transmits the information about the pins from pin 7 to pin 0
//so that is why our function counts down
for (i=7; i>=0; i--)
{
digitalWrite(myClockPin, 0);
delayMicroseconds(0.2);
temp = digitalRead(myDataPin);
if (temp) {
pinState = 1;
//set the bit to 0 no matter what
myDataIn = myDataIn | (1 << i);
}
else {
//turn it off -- only necessary for debuging
//print statement since myDataIn starts as 0
pinState = 0;
}
digitalWrite(myClockPin, 1);
}
//debuging print statements whitespace
//Serial.println();
//Serial.println(myDataIn, BIN);
return myDataIn;
}
// 9 April Switch Trial B
void setup() {
//start serial
Serial.begin(9600);
void loop() {
// if (switchVar1 == 1)
// {floorcount = 1;
// else if (switchVar1 == 2)
// {floorcount = 2;}
//else if (switchVar1 == 4)
// {floorcount = 3;}
//else if (switchVar1 == 8)
// {floorcount = 4;}
// else if (switchVar1 == 16)
// {floorcount = 5;}
//else if (switchVar1 == 32)
// {floorcount = 6;}
// else if (switchVar1 == 64)
// {floorcount = 7;
//else if (switchVar1 == 128)
// {floorcount = 8;}
if (switchVar2 == 1)
{//floorcount = 10;
}
else if (switchVar2 == 2)
{//floorcount = freight move down until released;
// }
// else if (switchVar2 == 4)
// {//elevator_loveletter;
//}
// else if (switchVar2 == 8)
// {//big_brother;
//}
// else if (switchVar2 == 16)
// {//bureaucratic_prostitution;
//}
// else if (switchVar2 == 32)
// {//coordinates_of_social_space;
//}
// else if (switchVar2 == 64)
// {//entrapment;
//}
//else if (switchVar2 == 128)
// {//the_fear;
//}
digitalWrite(ledPin,1);
delay(1000);
digitalWrite (ledPin,0);
}
}
pinMode(myClockPin, OUTPUT);
pinMode(myDataPin, INPUT);
//we will be holding the clock pin high 8 times (0,..,7) at the
//end of each time through the for loop
//at the begining of each loop when we set the clock low, it will
//be doing the necessary low to high drop to cause the shift
//register's DataPin to change state based on the value
//of the next bit in its serial information flow.
//The register transmits the information about the pins from pin 7 to pin 0
//so that is why our function counts down
for (i=7; i>=0; i--)
{
digitalWrite(myClockPin, 0);
delayMicroseconds(0.2);
temp = digitalRead(myDataPin);
if (temp) {
pinState = 1;
//set the bit to 0 no matter what
myDataIn = myDataIn | (1 << i);
}
else {
//turn it off -- only necessary for debuging
//print statement since myDataIn starts as 0
pinState = 0;
}
digitalWrite(myClockPin, 1);
}
//debuging print statements whitespace
//Serial.println();
//Serial.println(myDataIn, BIN);
return myDataIn;
}
// April 10 Motor Trial Code
#include <AFMotor.h>
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Stepper test!");
motor_freight.setSpeed(40); // 30 rpm
//motor_passenger.setSpeed(100);
void loop() {
motor_freight.step(1700, BACKWARD, SINGLE);
delay (500);
//motor_passenger.step(1, FORWARD, SINGLE);
//motor_freight.step(350, FORWARD, SINGLE);
//delay(20000);
// motor_passenger.step(200, FORWARD, SINGLE);
delay(500);
}
// April 10 Motor Trial 2
#include <AFMotor.h>
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Stepper test!");
motor_freight.setSpeed(40); // 30 rpm
//motor_passenger.setSpeed(100);
void loop() {
// motor_freight.step(1700, BACKWARD, SINGLE);
//delay (500);
motor_passenger.step(700, BACKWARD, SINGLE);
//motor_freight.step(350, FORWARD, SINGLE);
//delay(20000);
//motor_passenger.step(200, FORWARD, SINGLE);
delay(1000);
}
// Elevator Test_1
void setup() {
//start serial
Serial.begin(9600);
void loop() {
if (switchVar1 = 1)
{floorcount = 1;}
else if (switchVar1 = 2)
{floorcount = 2;}
else if (switchVar1 = 4)
{floorcount = 3;}
else if (switchVar1 = 8)
{floorcount = 4;}
else if (switchVar1 = 16)
{floorcount = 5;}
else if (switchVar1 = 32)
{floorcount = 6;}
else if (switchVar1 = 64)
{floorcount = 7;}
else if (switchVar1 = 128)
{floorcount = 8;}
{digitalWrite(ledPin,1);
delay(1000);
digitalWrite (ledPin,0);
}
pinMode(myClockPin, OUTPUT);
pinMode(myDataPin, INPUT);
//we will be holding the clock pin high 8 times (0,..,7) at the
//end of each time through the for loop
//at the begining of each loop when we set the clock low, it will
//be doing the necessary low to high drop to cause the shift
//register's DataPin to change state based on the value
//of the next bit in its serial information flow.
//The register transmits the information about the pins from pin 7 to pin 0
//so that is why our function counts down
for (i=7; i>=0; i--)
{
digitalWrite(myClockPin, 0);
delayMicroseconds(0.2);
temp = digitalRead(myDataPin);
if (temp) {
pinState = 1;
//set the bit to 0 no matter what
myDataIn = myDataIn | (1 << i);
}
else {
//turn it off -- only necessary for debuging
//print statement since myDataIn starts as 0
pinState = 0;
}
//Debuging print statements
// Serial.print(pinState);
//Serial.print("Marnie");
//Serial.println (dataIn, BIN);
digitalWrite(myClockPin, 1);
}
//debuging print statements whitespace
//Serial.println();
//Serial.println(myDataIn, BIN);
return myDataIn;
}
// Elev Test 2
void setup() {
//start serial
Serial.begin(9600);
void loop() {
if (switchVar1 == 1)
{floorcount = 1;
//else if (switchVar1 = 2)
// {floorcount = 2;}
// else if (switchVar1 = 4)
// {floorcount = 3;}
// else if (switchVar1 = 8)
// {floorcount = 4;}
// else if (switchVar1 = 16)
// {floorcount = 5;}
// else if (switchVar1 = 32)
// {floorcount = 6;}
// else if (switchVar1 = 64)
// {floorcount = 7;}
// else if (switchVar1 = 128)
// {floorcount = 8;}
digitalWrite(ledPin,1);
delay(1000);
digitalWrite (ledPin,0);
}
pinMode(myClockPin, OUTPUT);
pinMode(myDataPin, INPUT);
//we will be holding the clock pin high 8 times (0,..,7) at the
//end of each time through the for loop
//at the begining of each loop when we set the clock low, it will
//be doing the necessary low to high drop to cause the shift
//register's DataPin to change state based on the value
//of the next bit in its serial information flow.
//The register transmits the information about the pins from pin 7 to pin 0
//so that is why our function counts down
for (i=7; i>=0; i--)
{
digitalWrite(myClockPin, 0);
delayMicroseconds(0.2);
temp = digitalRead(myDataPin);
if (temp) {
pinState = 1;
//set the bit to 0 no matter what
myDataIn = myDataIn | (1 << i);
}
else {
//turn it off -- only necessary for debuging
//print statement since myDataIn starts as 0
pinState = 0;
}
//Debuging print statements
// Serial.print(pinState);
//Serial.print("Marnie");
//Serial.println (dataIn, BIN);
digitalWrite(myClockPin, 1);
}
//debuging print statements whitespace
//Serial.println();
//Serial.println(myDataIn, BIN);
return myDataIn;
}
// Elev Test 3
int Pass_elevator_Is = 0; // position of elevator at current point in time. this will change
//int Freight_elevator_Is = 0; // position of elevator at current point in time. this will c
void setup()
{
Serial.begin(9600); //debugging to screen
}
switchvar1 or switchvar2 and elevator_Is from void loop are passed to this
function. switchvar1 and switchvar2 go into outside_Button variable.
elevator_Is goes into current_Pos variable
*/
void loop{
}
// 15 April Elev Control 4B
#include <AFMotor.h>
int latchPin = 2;
int dataPin = 9;
int clockPin = 10;
int ledPin = 13;
void setup() {
//start serial
Serial.begin(9600);
// motor_freight.setSpeed(40); // 30 rpm
motor_passenger.setSpeed(40); // 30 rpm
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, INPUT);
pinMode(ledPin, OUTPUT);
void loop() {
//Pulse the latch pin:
//set it to 1 to collect parallel data
digitalWrite(latchPin,1);
//set it to 1 to collect parallel data, wait
delayMicroseconds(20);
if (switchVar1 != 0)
{
stepamount = amountchecker(switchVar1); // amount of travel necessary
Serial.print("Step Amount value: "); //debugging
Serial.println(stepamount); //debugging
if (passdirection == 2)
{ travel = stepamount - current_pos;
}
else
{ travel = current_pos - stepamount;
}
delay(500);
digitalWrite(ledPin,1);
delay(1000);
digitalWrite (ledPin,0);
}
}
pinState = 0;
}
digitalWrite(myClockPin, 1);
return myDataIn;
}
// 15 April Shift Register Trials A
void setup() {
//start serial
Serial.begin(9600);
void loop() {
//if (switchVar1 == 1)
//{floorcount = 1;
// else if (switchVar1 == 2)
// {floorcount = 2;}
//else if (switchVar1 == 4)
// {floorcount = 3;}
//else if (switchVar1 == 8)
// {floorcount = 4;}
// else if (switchVar1 == 16)
// {floorcount = 5;}
//else if (switchVar1 == 32)
// {floorcount = 6;}
// else if (switchVar1 == 64)
// {floorcount = 7;
//else if (switchVar1 == 128)
// {floorcount = 8;}
// else if (switchVar2 == 2)
//{//floorcount = freight move down until released;
// }
// else if (switchVar2 == 4)
// {//elevator_loveletter;
//}
// else if (switchVar2 == 8)
// {//big_brother;
//}
// else if (switchVar2 == 16)
// {//bureaucratic_prostitution;
//}
// else if (switchVar2 == 32)
// {//coordinates_of_social_space;
//}
// else if (switchVar2 == 64)
// {//entrapment;
//}
//else if (switchVar2 == 128)
// {//the_fear;
//}
if (switchVar3 > 0)
{//floorcount = 1;
// else if (switchVar1 == 2)
// {floorcount = 2;}
//else if (switchVar1 == 4)
// {floorcount = 3;}
//else if (switchVar1 == 8)
// {floorcount = 4;}
// else if (switchVar1 == 16)
// {floorcount = 5;}
//else if (switchVar1 == 32)
// {floorcount = 6;}
// else if (switchVar1 == 64)
// {floorcount = 7;
//else if (switchVar1 == 128)
// {floorcount = 8;}
digitalWrite(ledPin,1);
delay(1000);
digitalWrite (ledPin,0);
}
}
pinMode(myClockPin, OUTPUT);
pinMode(myDataPin, INPUT);
//we will be holding the clock pin high 8 times (0,..,7) at the
//end of each time through the for loop
//at the begining of each loop when we set the clock low, it will
//be doing the necessary low to high drop to cause the shift
//register's DataPin to change state based on the value
//of the next bit in its serial information flow.
//The register transmits the information about the pins from pin 7 to pin 0
//so that is why our function counts down
for (i=7; i>=0; i--)
{
digitalWrite(myClockPin, 0);
delayMicroseconds(0.2);
temp = digitalRead(myDataPin);
if (temp) {
pinState = 1;
//set the bit to 0 no matter what
myDataIn = myDataIn | (1 << i);
}
else {
//turn it off -- only necessary for debuging
//print statement since myDataIn starts as 0
pinState = 0;
}
}
//debuging print statements whitespace
//Serial.println();
//Serial.println(myDataIn, BIN);
return myDataIn;
}
// 15 April Elev Code D
#include <AFMotor.h>
int latchPin = 2;
int dataPin = 9;
int clockPin = 10;
int ledPin = 13;
switch (outside_button)
{
case 1:
floorheight = 1000;
break;
case 2:
floorheight = 1350;
break;
case 4:
floorheight = 1700;
break;
case 8:
floorheight = 2050;
break;
case 16:
floorheight = 2400;
break;
case 32:
floorheight = 2750;
break;
case 64:
floorheight = 3100;
break;
case 128:
floorheight = 3450;
break;
}
return floorheight;
}
void setup() {
//start serial
Serial.begin(9600);
// motor_freight.setSpeed(40); // 30 rpm
motor_passenger.setSpeed(40); // 30 rpm
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, INPUT);
pinMode(ledPin, OUTPUT);
void loop() {
//Pulse the latch pin:
//set it to 1 to collect parallel data
digitalWrite(latchPin,1);
//set it to 1 to collect parallel data, wait
delayMicroseconds(20);
if (switchVar1 != 0)
{
stepamount = amountchecker(switchVar1); // amount of travel necessary
Serial.print("Step Amount value: "); //debugging
Serial.println(stepamount); //debugging
if (passdirection == 2)
{ travel = stepamount - current_pos;
}
else
{ travel = current_pos - stepamount;
}
delay(500);
digitalWrite(ledPin,1);
delay(1000);
digitalWrite (ledPin,0);
}
else if (switchVar2 ! = 0)
{
stepamount = amountchecker(switchVar1); // amount of travel necessary
Serial.print("Step Amount value: "); //debugging
Serial.println(stepamount); //debugging
if (passdirection == 2)
{ travel = stepamount - current_pos;
}
else
{ travel = current_pos - stepamount;
}
delay(500);
digitalWrite(ledPin,1);
delay(1000);
digitalWrite (ledPin,0);
////shift register 3
else if (switchVar 3 == 1)
{//elevator_love letters
//else if (switchVar3 == 2)
//{//
// }
//else if (switchVar2 == 4)
// {//elevator_loveletter;
//move both freight and passenger elevator to the 6 floor
//}
// else if (switchVar2 == 8)
//{//big_brother;
//}
//else if (switchVar2 == 16)
//{//bureaucratic_prostitution;
//}
// else if (switchVar3 == 32)
//{//coordinates_of_social_space;
//}
//else if (switchVar2 == 64)
//{//entrapment;
//}
//else if (switchVar2 == 128)
//{//the_fear;
//}
digitalWrite(ledPin,1);
delay(1000);
digitalWrite (ledPin,0);
}
}
pinState = 0;
}
digitalWrite(myClockPin, 1);
return myDataIn;
}
// 16 April Elev Code A
#include <AFMotor.h>
int latchPin = 2;
int dataPin = 9;
int clockPin = 10;
int ledPin = 13;
switch (outside_button)
{
case 1:
floorheight = 1000;
break;
case 2:
floorheight = 1350;
break;
case 4:
floorheight = 1700;
break;
case 8:
floorheight = 2050;
break;
case 16:
floorheight = 2400;
break;
case 32:
floorheight = 2750;
break;
case 64:
floorheight = 3100;
break;
case 128:
floorheight = 3450;
break;
}
return floorheight;
}
void setup()
{
//start serial
Serial.begin(9600);
// motor_freight.setSpeed(40); // 30 rpm
motor_passenger.setSpeed(40); // 30 rpm
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop()
{
delayMicroseconds(20);
if (switchVar1 != 0)
{
stepamount = amountchecker(switchVar1); // amount of travel necessary
Serial.print("Step Amount value: "); //debugging
Serial.println(stepamount); //debugging
if (passdirection == 2)
{ travel = stepamount - current_pos;
}
else
{ travel = current_pos - stepamount;
}
delay(500);
digitalWrite(ledPin,1);
delay(1000);
digitalWrite (ledPin,0);
}
/// shift register 2
if (switchVar2 != 0)
{
stepamount = amountchecker(switchVar1); // amount of travel necessary
Serial.print("Inside button Step Amount value: "); //debugging
Serial.println(stepamount); //debugging
if (passdirection == 2)
{ travel = stepamount - current_pos;
}
else
{ travel = current_pos - stepamount;
}
delay(500);
digitalWrite(ledPin,1);
delay(1000);
digitalWrite (ledPin,0);
////shift register 3
if (switchVar3 == 1)
{//elevator_love letters
//else if (switchVar3 == 2)
//{//
// }
//else if (switchVar2 == 4)
// {//elevator_loveletter;
//move both freight and passenger elevator to the 6 floor
//}
// else if (switchVar2 == 8)
//{//big_brother;
//}
//else if (switchVar2 == 16)
//{//bureaucratic_prostitution;
//}
// else if (switchVar3 == 32)
//{//coordinates_of_social_space;
//}
//else if (switchVar2 == 64)
//{//entrapment;
//}
//else if (switchVar2 == 128)
//{//the_fear;
//}
digitalWrite(ledPin,1);
delay(1000);
digitalWrite (ledPin,0);
}
}
pinState = 0;
}
digitalWrite(myClockPin, 1);
return myDataIn;
}
// 16 April Elev Code B
#include <AFMotor.h>
int latchPin = 2;
int dataPin = 9;
int clockPin = 10;
int ledPin = 13;
switch (outside_button)
{
case 1:
floorheight = 1000;
break;
case 2:
floorheight = 1350;
break;
case 4:
floorheight = 1700;
break;
case 8:
floorheight = 2050;
break;
case 16:
floorheight = 2400;
break;
case 32:
floorheight = 2750;
break;
case 64:
floorheight = 3100;
break;
case 128:
floorheight = 3450;
break;
}
return floorheight;
}
void setup()
{
//start serial
Serial.begin(9600);
// motor_freight.setSpeed(40); // 30 rpm
motor_passenger.setSpeed(40); // 30 rpm
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop()
{
delayMicroseconds(20);
if (switchVar1 != 0)
{
stepamount = amountchecker(switchVar1); // amount of travel necessary
Serial.print("Step Amount value: "); //debugging
Serial.println(stepamount); //debugging
if (passdirection == 2)
{ travel = stepamount - current_pos;
}
else
{ travel = current_pos - stepamount;
}
delay(500);
digitalWrite(ledPin,1);
delay(1000);
digitalWrite (ledPin,0);
}
/// shift register 2
if (switchVar2 != 0)
{
stepamount = amountchecker(switchVar2); // amount of travel necessary
Serial.print("Inside button Step Amount value: "); //debugging
Serial.println(stepamount); //debugging
if (passdirection == 2)
{ travel = stepamount - current_pos;
}
else
{ travel = current_pos - stepamount;
}
delay(500);
digitalWrite(ledPin,1);
delay(1000);
digitalWrite (ledPin,0);
////shift register 3
if (switchVar3 == 1)
{//elevator_love letters
//else if (switchVar3 == 2)
//{//
// }
//else if (switchVar2 == 4)
// {//elevator_loveletter;
//move both freight and passenger elevator to the 6 floor
//}
// else if (switchVar2 == 8)
//{//big_brother;
//}
//else if (switchVar2 == 16)
//{//bureaucratic_prostitution;
//}
// else if (switchVar3 == 32)
//{//coordinates_of_social_space;
//}
//else if (switchVar2 == 64)
//{//entrapment;
//}
//else if (switchVar2 == 128)
//{//the_fear;
//}
digitalWrite(ledPin,1);
delay(1000);
digitalWrite (ledPin,0);
}
}
pinState = 0;
}
digitalWrite(myClockPin, 1);
return myDataIn;
}
// 17 April Elev Code A
#include <AFMotor.h>
int latchPin = 2;
int dataPin = 9;
int clockPin = 10;
int ledPin = 13;
//Define variables to hold the data for shift registers. Starting with a non-zero numbers can
byte switchVar1 = 0; //default number first comparison first ride of the day
byte switchVar2 = 0;
byte switchVar3 = 251;
delay(3000);
return direction;
}
void elevator_loveletter()
{
}
void big_brother()
{
}
void bureaucratic_prostitution
{
}
void coordinates_of_social_space()
{
}
void the_fear()
{
}
void entrapment()
{
}
void setup()
{
//start serial
Serial.begin(9600);
// motor_freight.setSpeed(40); // 30 rpm
motor_passenger.setSpeed(40); // 30 rpm
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, INPUT);
pinMode(ledPin, OUTPUT);
void loop()
{
delayMicroseconds(20);
if (switchVar1 != 0)
{
stepamount = amountchecker(switchVar1); // returns preset value of floor where button was pre
Serial.print("Outside Button Step Amount value: "); //debugging
Serial.println(stepamount); //debugging
passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of el
Serial.print("Outside Button Pass Direction: ");
Serial.println(passdirection); // debugging
if (passdirection == 2)
{ travel = stepamount - current_pos; // calculate number of steps elevator needs to travel if
}
else
{ travel = current_pos - stepamount; // calculate number of steps elevator needs to travel if
}
delay(500);
digitalWrite(ledPin,1);
delay(1000);
digitalWrite (ledPin,0);
if (switchVar2 != 0)
{
stepamount = amountchecker(switchVar2); // returns preset value of floor where button was pre
Serial.print("Inside button Step Amount value: "); //debugging
Serial.println(stepamount); //debugging
if (passdirection == 2)
{ travel = stepamount - current_pos; // calculate number of steps elevator needs to travel if
}
else
{ travel = current_pos - stepamount; // calculate number of steps elevator needs to travel if
}
digitalWrite(ledPin,1); //debugging
delay(1000); //debugging
digitalWrite (ledPin,0); //debugging
//if (switchVar3 == 1)
// {//elevator_love letters
//else if (switchVar3 == 2)
//{//
// }
//else if (switchVar2 == 4)
// {//elevator_loveletter;
//move both freight and passenger elevator to the 6 floor
//}
// else if (switchVar2 == 8)
//{//big_brother;
//}
//else if (switchVar2 == 16)
//{//bureaucratic_prostitution;
//}
// else if (switchVar3 == 32)
//{//coordinates_of_social_space;
//}
//else if (switchVar2 == 64)
//{//entrapment;
//}
//else if (switchVar2 == 128)
//{//the_fear;
//}
//}
if (switchVar3 != 0)
{
stepamount = amountchecker(switchVar3); // returns preset value of floor where button was pre
Serial.print("SwitchVar3 Step Amount value: "); //debugging
Serial.println(stepamount); //debugging
if (passdirection == 2)
{
travel = stepamount - current_pos; // calculate number of steps elevator needs to travel if
}
else
{
travel = current_pos - stepamount; // calculate number of steps elevator needs to travel if
}
delay(500);
switch (switchVar3)
{
case 1:
elevator_love letters();
break;
case 2:
break;
case 4:
elevator_loveletter();
break;
case 8:
big_brother();
break;
case 16:
bureaucratic_prostitution();
break;
case 32:
coordinates_of_social_space();
break;
case 64:
entrapment();
break;
case 128:
the_fear();
break;
}
digitalWrite(ledPin,1); //debugging
delay(1000); //debugging
digitalWrite (ledPin,0); //debugging
digitalWrite(ledPin,1); //debugging
delay(1000); //debugging
digitalWrite (ledPin,0); //debugging
}
pinState = 0;
}
digitalWrite(myClockPin, 1);
return myDataIn;
}
// 17 April Elev Code B
#include <AFMotor.h>
int latchPin = 2;
int dataPin = 9;
int clockPin = 10;
int ledPin = 13;
//Define variables to hold the data for shift registers. Starting with a non-zero numbers can
byte switchVar1 = 0; //default number first comparison first ride of the day
byte switchVar2 = 0;
byte switchVar3 = 251;
delay(3000);
return direction;
}
switch (button)
{
case 1:
floorheight = 1000;
break;
case 2:
floorheight = 1350;
break;
case 4:
floorheight = 1700;
break;
case 8:
floorheight = 2050;
break;
case 16:
floorheight = 2400;
break;
case 32:
floorheight = 2750;
break;
case 64:
floorheight = 3100;
break;
case 128:
floorheight = 3450;
break;
}
return floorheight;
}
void elevator_love_letters()
{
}
void gateway_to_the_soul()
{
}
void big_brother()
{
}
void bureaucratic_prostitution()
{
}
void coordinates_of_social_space()
{
}
void the_fear()
{
}
void make_nice()
{
}
void we_have_a_situation_here()
{
}
void the_end_of_the_world ()
{
}
void pages_from_a_diary()
{
}
void setup()
{
//start serial
Serial.begin(9600);
motor_freight.setSpeed(40); // 40 rpm
motor_passenger.setSpeed(40); // 40 rpm
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, INPUT);
pinMode(ledPin, OUTPUT);
void loop()
{
delayMicroseconds(20);
if (switchVar1 != 0)
{
stepamount = amountchecker(switchVar1); // returns preset value of floor where button was pre
Serial.print("Outside Button Step Amount value: "); //debugging
Serial.println(stepamount); //debugging
if (passdirection == 2)
{ travel = stepamount - current_pos; // calculate number of steps elevator needs to travel if
}
else
{ travel = current_pos - stepamount; // calculate number of steps elevator needs to travel if
}
delay(500);
digitalWrite(ledPin,1);
delay(1000);
digitalWrite (ledPin,0);
if (switchVar2 != 0)
{
stepamount = amountchecker(switchVar2); // returns preset value of floor where button was pre
Serial.print("Inside button Step Amount value: "); //debugging
Serial.println(stepamount); //debugging
if (passdirection == 2)
{ travel = stepamount - current_pos; // calculate number of steps elevator needs to travel if
}
else
{ travel = current_pos - stepamount; // calculate number of steps elevator needs to travel if
}
delay(500);
digitalWrite(ledPin,1); //debugging
delay(1000); //debugging
digitalWrite (ledPin,0); //debugging
//if (switchVar3 == 1)
// {//elevator_love letters
//else if (switchVar3 == 2)
//{//
// }
//else if (switchVar2 == 4)
// {//elevator_loveletter;
//move both freight and passenger elevator to the 6 floor
//}
// else if (switchVar2 == 8)
//{//big_brother;
//}
//else if (switchVar2 == 16)
//{//bureaucratic_prostitution;
//}
// else if (switchVar3 == 32)
//{//coordinates_of_social_space;
//}
//else if (switchVar2 == 64)
//{//entrapment;
//}
//else if (switchVar2 == 128)
//{//the_fear;
//}
//}
if (switchVar3 != 0)
{
stepamount = amountchecker(switchVar3); // returns preset value of floor where button was pre
Serial.print("SwitchVar3 Step Amount value: "); //debugging
Serial.println(stepamount); //debugging
if (passdirection == 2)
{
travel = stepamount - current_pos; // calculate number of steps elevator needs to travel if
}
else
{
travel = current_pos - stepamount; // calculate number of steps elevator needs to travel if
}
delay(500);
switch (switchVar3)
{
case 1:
elevator_love_letters();
break;
case 2:
break;
case 4:
gateway_to_the_soul();
break;
case 8:
big_brother();
break;
case 16:
bureaucratic_prostitution();
break;
case 32:
coordinates_of_social_space();
break;
case 64:
the_end_of_the_world();
break;
case 128:
the_fear();
break;
}
digitalWrite(ledPin,1); //debugging
delay(1000); //debugging
digitalWrite (ledPin,0); //debugging
digitalWrite(ledPin,1); //debugging
delay(1000); //debugging
digitalWrite (ledPin,0); //debugging
pinState = 0;
}
digitalWrite(myClockPin, 1);
}
return myDataIn;
}
// 17 April Elev Code C
#include <AFMotor.h>
int latchPin = 2;
int dataPin = 9;
int clockPin = 10;
int ledPin = 13;
//Define variables to hold the data for shift registers. Starting with a non-zero numbers can
byte switchVar1 = 0; //default number first comparison first ride of the day
byte switchVar2 = 0;
byte switchVar3 = 251;
delay(3000);
return direction;
}
switch (button)
{
case 1:
floorheight = 1000;
break;
case 2:
floorheight = 1350;
break;
case 4:
floorheight = 1700;
break;
case 8:
floorheight = 2050;
break;
case 16:
floorheight = 2400;
break;
case 32:
floorheight = 2750;
break;
case 64:
floorheight = 3100;
break;
case 128:
floorheight = 3450;
break;
}
return floorheight;
}
void elevator_love_letters()
{
}
void gateway_to_the_soul()
{
}
void big_brother()
{
}
void bureaucratic_prostitution()
{
}
void coordinates_of_social_space()
{
}
void the_fear()
{
}
void make_nice()
{
}
void we_have_a_situation_here()
{
}
void the_end_of_the_world ()
{
}
void pages_from_a_diary()
{
}
void setup()
{
//start serial
Serial.begin(9600);
motor_freight.setSpeed(40); // 40 rpm
motor_passenger.setSpeed(40); // 40 rpm
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, INPUT);
pinMode(ledPin, OUTPUT);
void loop()
{
delayMicroseconds(20);
if (switchVar1 != 0)
{
stepamount = amountchecker(switchVar1); // returns preset value of floor where button was pre
Serial.print("Outside Button Step Amount value: "); //debugging
Serial.println(stepamount); //debugging
if (passdirection == 2)
{ travel = stepamount - current_pos; // calculate number of steps elevator needs to travel if
}
else
{ travel = current_pos - stepamount; // calculate number of steps elevator needs to travel if
}
delay(500);
digitalWrite(ledPin,1);
delay(1000);
digitalWrite (ledPin,0);
if (switchVar2 != 0)
{
stepamount = amountchecker(switchVar2); // returns preset value of floor where button was pre
Serial.print("Inside button Step Amount value: "); //debugging
Serial.println(stepamount); //debugging
if (passdirection == 2)
{ travel = stepamount - current_pos; // calculate number of steps elevator needs to travel if
}
else
{ travel = current_pos - stepamount; // calculate number of steps elevator needs to travel if
}
delay(500);
digitalWrite(ledPin,1); //debugging
delay(1000); //debugging
digitalWrite (ledPin,0); //debugging
//if (switchVar3 == 1)
// {//elevator_love letters
//else if (switchVar3 == 2)
//{//
// }
//else if (switchVar2 == 4)
// {//elevator_loveletter;
//move both freight and passenger elevator to the 6 floor
//}
// else if (switchVar2 == 8)
//{//big_brother;
//}
//else if (switchVar2 == 16)
//{//bureaucratic_prostitution;
//}
// else if (switchVar3 == 32)
//{//coordinates_of_social_space;
//}
//else if (switchVar2 == 64)
//{//entrapment;
//}
//else if (switchVar2 == 128)
//{//the_fear;
//}
//}
if (switchVar3 != 0)
{
stepamount = amountchecker(switchVar3); // returns preset value of floor where button was pre
Serial.print("SwitchVar3 Step Amount value: "); //debugging
Serial.println(stepamount); //debugging
if (passdirection == 2)
{
travel = stepamount - current_pos; // calculate number of steps elevator needs to travel if
}
else
{
travel = current_pos - stepamount; // calculate number of steps elevator needs to travel if
}
delay(500);
switch (switchVar3)
{
case 1: // the Freight Up Button
motor_freight.step(f_speed, BACKWARD, SINGLE);
freight_pos = freight_pos + f_speed;
break;
case 2: //
motor_freight.step(f_speed, FORWARD, SINGLE);
freight_pos = freight_pos - f_speed;
break;
break;
case 4:
stepamount = amountchecker(switchVar3); // returns preset value of floor where button wa
Serial.print("SwitchVar3 Step Amount value: "); //debugging
Serial.println(stepamount); //debugging
if (passdirection == 2)
{
travel = stepamount - current_pos; // calculate number of steps elevator needs to travel if
}
else
{
travel = current_pos - stepamount; // calculate number of steps elevator needs to travel if
}
delay(500);
case 8:
stepamount = 3100;
if (passdirection == 2)
{
travel = stepamount - current_pos; // calculate number of steps elevator needs to travel if
}
else
{
travel = current_pos - stepamount; // calculate number of steps elevator needs to travel if
}
delay(500);
if (passdirection == 2)
{
travel = stepamount - freight_pos; // calculate number of steps elevator needs to travel if
}
else
{
travel = freight_pos - stepamount; // calculate number of steps elevator needs to travel if
}
delay(500);
case 16:
bureaucratic_prostitution();
break;
case 32:
coordinates_of_social_space();
break;
case 64:
the_end_of_the_world();
break;
case 128:
stepamount = amountchecker(switchVar3); // returns preset value of floor where button was
Serial.print("SwitchVar3 Step Amount value: "); //debugging
Serial.println(stepamount); //debugging
if (passdirection == 2)
{
travel = stepamount - current_pos; // calculate number of steps elevator needs to travel if
}
else
{
travel = current_pos - stepamount; // calculate number of steps elevator needs to travel if
}
delay(500);
digitalWrite(ledPin,1); //debugging
delay(1000); //debugging
digitalWrite (ledPin,0); //debugging
digitalWrite(ledPin,1); //debugging
delay(1000); //debugging
digitalWrite (ledPin,0); //debugging
pinState = 0;
}
digitalWrite(myClockPin, 1);
}
return myDataIn;
}
// 17 April Elev Code D
#include <AFMotor.h>
int latchPin = 2;
int dataPin = 9;
int clockPin = 10;
int ledPin = 13;
//Define variables to hold the data for shift registers. Starting with a non-zero numbers can
byte switchVar1 = 0; //default number first comparison first ride of the day
byte switchVar2 = 0;
byte switchVar3 = 251;
delay(3000);
return direction;
}
switch (button)
{
case 1:
floorheight = 1000;
break;
case 2:
floorheight = 1350;
break;
case 4:
floorheight = 1700;
break;
case 8:
floorheight = 2050;
break;
case 16:
floorheight = 2400;
break;
case 32:
floorheight = 2750;
break;
case 64:
floorheight = 3100;
break;
case 128:
floorheight = 3450;
break;
}
return floorheight;
}
void elevator_love_letters()
{
}
void gateway_to_the_soul()
{
}
void big_brother()
{
}
void bureaucratic_prostitution()
{
}
void coordinates_of_social_space()
{
}
void the_fear()
{
}
void make_nice()
{
}
void we_have_a_situation_here()
{
}
void the_end_of_the_world ()
{
}
void pages_from_a_diary()
{
}
void setup()
{
//start serial
Serial.begin(9600);
motor_freight.setSpeed(40); // 40 rpm
motor_passenger.setSpeed(40); // 40 rpm
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, INPUT);
pinMode(ledPin, OUTPUT);
void loop()
{
delayMicroseconds(20);
//set it to 0 to transmit data serially
digitalWrite(latchPin,0);
//while the shift register is in serial mode
//collect each shift register into a byte
//the register attached to the chip comes in first
if (switchVar1 != 0)
{
stepamount = amountchecker(switchVar1); // returns preset value of floor where button was pre
Serial.print("Outside Button Step Amount value: "); //debugging
Serial.println(stepamount); //debugging
if (passdirection == 2)
{ travel = stepamount - current_pos; // calculate number of steps elevator needs to travel if
}
else
{ travel = current_pos - stepamount; // calculate number of steps elevator needs to travel if
}
delay(500);
digitalWrite(ledPin,1);
delay(1000);
digitalWrite (ledPin,0);
if (switchVar2 != 0)
{
stepamount = amountchecker(switchVar2); // returns preset value of floor where button was pre
Serial.print("Inside button Step Amount value: "); //debugging
Serial.println(stepamount); //debugging
passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of el
Serial.print("Inside button Pass Direction: "); //debugging
Serial.println(passdirection); // debugging
if (passdirection == 2)
{ travel = stepamount - current_pos; // calculate number of steps elevator needs to travel if
}
else
{ travel = current_pos - stepamount; // calculate number of steps elevator needs to travel if
}
delay(500);
digitalWrite(ledPin,1); //debugging
delay(1000); //debugging
digitalWrite (ledPin,0); //debugging
//if (switchVar3 == 1)
// {//elevator_love letters
//else if (switchVar3 == 2)
//{//
// }
//else if (switchVar2 == 4)
// {//elevator_loveletter;
//move both freight and passenger elevator to the 6 floor
//}
// else if (switchVar2 == 8)
//{//big_brother;
//}
//else if (switchVar2 == 16)
//{//bureaucratic_prostitution;
//}
// else if (switchVar3 == 32)
//{//coordinates_of_social_space;
//}
//else if (switchVar2 == 64)
//{//entrapment;
//}
//else if (switchVar2 == 128)
//{//the_fear;
//}
//}
if (switchVar3 != 0)
{
stepamount = amountchecker(switchVar3); // returns preset value of floor where button was pre
Serial.print("SwitchVar3 Step Amount value: "); //debugging
Serial.println(stepamount); //debugging
if (passdirection == 2)
{
travel = stepamount - current_pos; // calculate number of steps elevator needs to travel if
}
else
{
travel = current_pos - stepamount; // calculate number of steps elevator needs to travel if
}
delay(500);
switch (switchVar3)
{
case 1: // the Freight Up Button
motor_freight.step(f_speed, BACKWARD, SINGLE);
freight_pos = freight_pos + f_speed;
break;
case 2: //
motor_freight.step(f_speed, FORWARD, SINGLE);
freight_pos = freight_pos - f_speed;
break;
break;
case 4:
stepamount = amountchecker(switchVar3); // returns preset value of floor where button wa
Serial.print("SwitchVar3 Step Amount value: "); //debugging
Serial.println(stepamount); //debugging
if (passdirection == 2)
{
travel = stepamount - current_pos; // calculate number of steps elevator needs to travel if
}
else
{
travel = current_pos - stepamount; // calculate number of steps elevator needs to travel if
}
delay(500);
case 8:
stepamount = 3100;
delay(500);
if (passdirection == 2)
{
travel = stepamount - freight_pos; // calculate number of steps elevator needs to travel if
}
else
{
travel = freight_pos - stepamount; // calculate number of steps elevator needs to travel if
}
delay(500);
case 16:
bureaucratic_prostitution();
break;
case 32:
coordinates_of_social_space();
break;
case 64:
the_end_of_the_world();
break;
case 128:
stepamount = amountchecker(switchVar3); // returns preset value of floor where button was
Serial.print("SwitchVar3 Step Amount value: "); //debugging
Serial.println(stepamount); //debugging
if (passdirection == 2)
{
travel = stepamount - current_pos; // calculate number of steps elevator needs to travel if
}
else
{
travel = current_pos - stepamount; // calculate number of steps elevator needs to travel if
}
delay(500);
digitalWrite(ledPin,1); //debugging
delay(1000); //debugging
digitalWrite (ledPin,0); //debugging
pinState = 0;
}
digitalWrite(myClockPin, 1);
}
return myDataIn;
}
// 18 April Elev Code A
#include <AFMotor.h>
int latchPin = 2;
int dataPin = 9;
int clockPin = 10;
int ledPin = 13;
int passtravel =0; //amount pass elevator will move. is direction independent.
int freighttravel = 0; // amount freight elevator will move.
int passdirection = 0; // direction passenger elevator will travel. will be 1 is Forward or
int freightdirection= 0; // direction freight elevator will travel.
int current_pos = 650; // current position of elevator. set to 1000 ground floor at start up
int stepamount; // variable that holds value assigned to floor where a button is pushed.
//Define variables to hold the data for shift registers. Starting with a non-zero numbers can
byte switchVar1 = 0; //default number first comparison first ride of the day
byte switchVar2 = 0;
byte switchVar3 = 0;
return direction;
}
if (tdirection == 2)
{
travel = stepamount - position; // calculate number of steps elevator needs to travel if dir
}
else
{
travel = position - stepamount; // calculate number of steps elevator needs to travel if di
}
return travel;
}
switch (button)
{
case 1:
floorheight = 1000;
break;
case 2:
floorheight = 1350;
break;
case 4:
floorheight = 1700;
break;
case 8:
floorheight = 2050;
break;
case 16:
floorheight = 2400;
break;
case 32:
floorheight = 2750;
break;
case 64:
floorheight = 3100;
break;
case 128:
floorheight = 3450;
break;
}
return floorheight;
}
// end function amountchecker
//int direction(
void elevator_love_letters()
{
}
void gateway_to_the_soul()
{
}
void big_brother()
{
}
void bureaucratic_prostitution()
{
}
void coordinates_of_social_space()
{
}
void the_fear()
{
}
void make_nice()
{
}
void we_have_a_situation_here()
{
}
void the_end_of_the_world ()
{
}
void pages_from_a_diary()
{
}
void setup()
{
//start serial
Serial.begin(9600);
motor_freight.setSpeed(40); // 40 rpm
motor_passenger.setSpeed(40); // 40 rpm
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, INPUT);
pinMode(ledPin, OUTPUT);
void loop()
{
delayMicroseconds(20);
if (switchVar1 != 0)
{
stepamount = amountchecker(switchVar1); // returns preset value of floor where button was pre
passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of el
passtravel = travel_amount(stepamount, current_pos, passdirection); // determine travel amount
if (switchVar2 != 0)
{
stepamount = amountchecker(switchVar2); // returns preset value of floor where button was pre
passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of el
passtravel = travel_amount(stepamount, current_pos, passdirection); // determine travel amount
motor_passenger.step(passtravel, passdirection, SINGLE);
current_pos = stepamount;
if (switchVar3 != 0)
{
stepamount = amountchecker(switchVar3); // returns preset value of floor where button was pre
passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of el
passtravel = travel_amount(stepamount, current_pos, passdirection); // determine travel amount
switch (switchVar3)
{
case 1: // the Freight Up Button
motor_freight.step(f_speed, BACKWARD, SINGLE);
freight_pos = freight_pos + f_speed;
break;
case 2: //
motor_freight.step(f_speed, FORWARD, SINGLE);
freight_pos = freight_pos - f_speed;
break;
case 4:
stepamount = amountchecker(switchVar3); // returns preset value of floor where button was pre
passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of el
passtravel = travel_amount(stepamount, current_pos, passdirection); // determine travel amount
case 8:
stepamount = 3100;
passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of el
passtravel = travel_amount(stepamount, current_pos, passdirection); // determine travel amount
case 16:
bureaucratic_prostitution();
break;
case 32:
coordinates_of_social_space();
break;
case 64:
the_end_of_the_world();
break;
case 128:
stepamount = 3450; // 8th floor
passdirection = elevator_direction(stepamount, current_pos);//determine travel direction of pa
passtravel = travel_amount(stepamount, current_pos, passdirection);//determine pass travel amo
freightdirection = elevator_direction(stepamount, freight_pos); // returns travel direction of
freighttravel = travel_amount(stepamount, freight_pos, freightdirection); // determine freight
pinState = 0;
}
digitalWrite(myClockPin, 1);
return myDataIn;
}
// 18 April Elev Code A1
#include <AFMotor.h>
int latchPin = 2;
int dataPin = 9;
int clockPin = 10;
int ledPin = 13;
int passtravel =0; //amount pass elevator will move. is direction independent.
int freighttravel = 0; // amount freight elevator will move.
int totalpasstravel = 0; // current_pos + passtravel for moving passenger elevator to desired
int totalfreighttravel = 0; // freight_pos + freighttravel for moving freight elevator to a d
int passdirection = 0; // direction passenger elevator will travel. will be 1 is Forward or
int freightdirection= 0; // direction freight elevator will travel.
int current_pos = 650; // current position of elevator. set to 1000 ground floor at start up
int freight_pos = 650; // current position of freight elevator
int stepamount; // variable that holds value assigned to floor where a button is pushed.
int f_speed = 10; // speed of freight elevator
//Define variables to hold the data for shift registers. Starting with a non-zero numbers can
byte switchVar1 = 0; //default number first comparison first ride of the day
byte switchVar2 = 0;
byte switchVar3 = 0;
return elev_direction;
}
if (travel_direction == 2)
{
travel = stepamount - position; // calculate number of steps elevator needs to travel if dir
}
else
{
travel = position - stepamount; // calculate number of steps elevator needs to travel if di
}
return travel;
}
switch (button)
{
case 1://floor 1
floorheight = 988;
break;
case 2://floor 2
floorheight = 1310;
break;
case 4://floor 3
floorheight = 1630;
break;
case 8://floor 4
floorheight = 1940;
break;
case 16://floor 5
floorheight = 2270;
break;
case 32://floor 6
floorheight = 2600;
break;
case 64://floor 7
floorheight = 3075;
break;
case 128://floor 8
floorheight = 3400;
break;
}
return floorheight;
}
// end function amountchecker
void elevator_love_letters()
{
}
void gateway_to_the_soul()
{
}
void big_brother()
{
}
void bureaucratic_prostitution()
{
}
void coordinates_of_social_space()
{
}
void the_fear()
{
}
void make_nice()
{
}
void we_have_a_situation_here()
{
}
void the_end_of_the_world ()
{
}
void pages_from_a_diary()
{
}
void setup()
{
//start serial
Serial.begin(9600);
motor_freight.setSpeed(40); // 40 rpm
motor_passenger.setSpeed(40); // 40 rpm
//define pin modes
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, INPUT);
pinMode(ledPin, OUTPUT);
void loop()
{
delayMicroseconds(20);
if (switchVar1 != 0)
{
stepamount = amountchecker(switchVar1); // returns preset value of floor where button was pre
passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of el
passtravel = travel_amount(stepamount, current_pos, passdirection); // determine travel amount
if (switchVar2 != 0)
{
stepamount = amountchecker(switchVar2); // returns preset value of floor where button was pre
passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of el
passtravel = travel_amount(stepamount, current_pos, passdirection); // determine travel amount
}
if (switchVar3 != 0)
{
stepamount = amountchecker(switchVar3); // returns preset value of floor where button was pre
passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of el
passtravel = travel_amount(stepamount, current_pos, passdirection); // determine travel amount
switch (switchVar3)
{
case 1: // the Freight Up Button
motor_freight.step(f_speed, BACKWARD, SINGLE);
freight_pos = freight_pos + f_speed;
break;
case 2: //
motor_freight.step(f_speed, FORWARD, SINGLE);
freight_pos = freight_pos - f_speed;
break;
case 4:
stepamount = amountchecker(switchVar3); // returns preset value of floor where button was pre
passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of el
passtravel = travel_amount(stepamount, current_pos, passdirection); // determine travel amount
case 8:
/*
stepamount = 3100;
passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of e
passtravel = travel_amount(stepamount, current_pos, passdirection); // determine travel amoun
break;
case 16:
bureaucratic_prostitution();
break;
case 32:
coordinates_of_social_space();
break;
case 64:
the_end_of_the_world();
break;
case 128:
stepamount = amountchecker(switchVar3); // returns preset value of floor where button was pre
passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of el
passtravel = travel_amount(stepamount, current_pos, passdirection); // determine travel amount
current_pos = stepamount;
Serial.print("Current Position of Passenger: ");
Serial.println(current_pos);
Serial.print("Current Position of Freight: ");
Serial.println(freight_pos);
delay(5000);
break;
} // end switch (case) statement
//current_pos = stepamount;
pinState = 0;
}
digitalWrite(myClockPin, 1);
return myDataIn;
}
// 18 Elev Code B
#include <AFMotor.h>
int latchPin = 2;
int dataPin = 9;
int clockPin = 10;
int ledPin = 13;
int passtravel =0; //amount pass elevator will move. is direction independent.
int freighttravel = 0; // amount freight elevator will move.
int passdirection = 0; // direction passenger elevator will travel. will be 1 is Forward or
int freightdirection= 0; // direction freight elevator will travel.
int current_pos = 650; // current position of elevator. set to 650 basement floor at start u
int stepamount; // variable that holds value assigned to floor where a button is pushed.
//Define variables to hold the data for shift registers. Starting with a non-zero numbers can
byte switchVar1 = 0; //default number first comparison first ride of the day
byte switchVar2 = 0;
byte switchVar3 = 0;
return direction;
}
if (tdirection == 2)
{
travel = stepamount - position; // calculate number of steps elevator needs to travel if dir
}
else
{
travel = position - stepamount; // calculate number of steps elevator needs to travel if di
}
return travel;
}
switch (button)
{
case 1:
floorheight = 1000;
break;
case 2:
floorheight = 1350;
break;
case 4:
floorheight = 1700;
break;
case 8:
floorheight = 2050;
break;
case 16:
floorheight = 2400;
break;
case 32:
floorheight = 2750;
break;
case 64:
floorheight = 3100;
break;
case 128:
floorheight = 3150; // this no. can change it's a safety precaution
break;
}
return floorheight;
}
// end function amountchecker
//int direction(
void elevator_love_letters()
{
}
void gateway_to_the_soul()
{
}
void big_brother()
{
}
void bureaucratic_prostitution()
{
}
void coordinates_of_social_space()
{
}
void the_fear()
{
}
void make_nice()
{
}
void we_have_a_situation_here()
{
}
void the_end_of_the_world ()
{
}
void pages_from_a_diary()
{
}
void setup()
{
//start serial
Serial.begin(9600);
motor_freight.setSpeed(40); // 40 rpm
motor_passenger.setSpeed(40); // 40 rpm
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, INPUT);
pinMode(ledPin, OUTPUT);
void loop()
{
delayMicroseconds(20);
if (switchVar1 != 0)
{
stepamount = amountchecker(switchVar1); // returns preset value of floor where button was pre
passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of el
passtravel = travel_amount(stepamount, current_pos, passdirection); // determine travel amount
if (switchVar2 != 0)
{
stepamount = amountchecker(switchVar2); // returns preset value of floor where button was pre
passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of el
passtravel = travel_amount(stepamount, current_pos, passdirection); // determine travel amount
motor_passenger.step(passtravel, passdirection, SINGLE);
current_pos = stepamount;
if (switchVar3 != 0)
{
stepamount = amountchecker(switchVar3); // returns preset value of floor where button was pre
passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of el
passtravel = travel_amount(stepamount, current_pos, passdirection); // determine travel amount
switch (switchVar3)
{
case 1: // the Freight Up Button
motor_freight.step(f_speed, BACKWARD, SINGLE);
freight_pos = freight_pos + f_speed;
break;
case 2: //
motor_freight.step(f_speed, FORWARD, SINGLE);
freight_pos = freight_pos - f_speed;
break;
case 4:
stepamount = amountchecker(switchVar3); // returns preset value of floor where button was pre
passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of el
passtravel = travel_amount(stepamount, current_pos, passdirection); // determine travel amount
case 8:
stepamount = 3100; // 8th floor
passdirection = elevator_direction(stepamount, current_pos);//determine travel direction of pa
passtravel = travel_amount(stepamount, current_pos, passdirection);//determine pass travel amo
freightdirection = elevator_direction(stepamount, freight_pos); // returns travel direction of
freighttravel = travel_amount(stepamount, freight_pos, freightdirection); // determine freight
case 16:
bureaucratic_prostitution();
break;
case 32:
coordinates_of_social_space();
break;
case 64:
the_end_of_the_world();
break;
case 128:
// goes to high. need to change that number//
stepamount = amountchecker(switchVar3); // returns preset value of floor where button was pre
passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of el
passtravel = travel_amount(stepamount, current_pos, passdirection); // determine travel amount
current_pos = stepamount;
}
}
}
pinState = 0;
}
digitalWrite(myClockPin, 1);
return myDataIn;
}
// 18 April Elev Code C
#include <AFMotor.h>
int latchPin = 2;
int dataPin = 9;
int clockPin = 10;
int ledPin = 13;
int passtravel =0; //amount pass elevator will move. is direction independent.
int freighttravel = 0; // amount freight elevator will move.
int totalpasstravel = 0; // current_pos + passtravel for moving passenger elevator to desired
int totalfreighttravel = 0; // freight_pos + freighttravel for moving freight elevator to a d
int passdirection = 0; // direction passenger elevator will travel. will be 1 is Forward or
int freightdirection= 0; // direction freight elevator will travel.
int current_pos = 650; // current position of elevator. set to 1000 ground floor at start up
int freight_pos = 650; // current position of freight elevator
int stepamount; // variable that holds value assigned to floor where a button is pushed.
int f_speed = 10; // speed of freight elevator
//Define variables to hold the data for shift registers. Starting with a non-zero numbers can
byte switchVar1 = 0; //default number first comparison first ride of the day
byte switchVar2 = 0;
byte switchVar3 = 0;
return elev_direction;
}
if (travel_direction == 2)
{
travel = stepamount - position; // calculate number of steps elevator needs to travel if dir
}
else
{
travel = position - stepamount; // calculate number of steps elevator needs to travel if di
}
return travel;
}
switch (button)
{
case 1:
floorheight = 1000;
break;
case 2:
floorheight = 1350;
break;
case 4:
floorheight = 1700;
break;
case 8:
floorheight = 2050;
break;
case 16:
floorheight = 2400;
break;
case 32:
floorheight = 2750;
break;
case 64:
floorheight = 3100;
break;
case 128:
floorheight = 3450;
break;
}
return floorheight;
}
// end function amountchecker
void elevator_love_letters()
{
}
void gateway_to_the_soul()
{
}
void big_brother()
{
}
void bureaucratic_prostitution()
{
}
void coordinates_of_social_space()
{
}
void the_fear()
{
}
void make_nice()
{
}
void we_have_a_situation_here()
{
}
void the_end_of_the_world ()
{
}
void pages_from_a_diary()
{
}
void setup()
{
//start serial
Serial.begin(9600);
motor_freight.setSpeed(40); // 40 rpm
motor_passenger.setSpeed(40); // 40 rpm
//define pin modes
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, INPUT);
pinMode(ledPin, OUTPUT);
void loop()
{
delayMicroseconds(20);
if (switchVar1 != 0)
{
stepamount = amountchecker(switchVar1); // returns preset value of floor where button was pre
passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of el
passtravel = travel_amount(stepamount, current_pos, passdirection); // determine travel amount
if (switchVar2 != 0)
{
stepamount = amountchecker(switchVar2); // returns preset value of floor where button was pre
passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of el
passtravel = travel_amount(stepamount, current_pos, passdirection); // determine travel amount
}
if (switchVar3 != 0)
{
stepamount = amountchecker(switchVar3); // returns preset value of floor where button was pre
passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of el
passtravel = travel_amount(stepamount, current_pos, passdirection); // determine travel amount
switch (switchVar3)
{
case 1: // the Freight Up Button
motor_freight.step(f_speed, BACKWARD, SINGLE);
freight_pos = freight_pos + f_speed;
break;
case 2: //
motor_freight.step(f_speed, FORWARD, SINGLE);
freight_pos = freight_pos - f_speed;
break;
case 4:
stepamount = amountchecker(switchVar3); // returns preset value of floor where button was pre
passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of el
passtravel = travel_amount(stepamount, current_pos, passdirection); // determine travel amount
case 8:
/*
stepamount = 3100;
passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of e
passtravel = travel_amount(stepamount, current_pos, passdirection); // determine travel amoun
break;
case 16:
bureaucratic_prostitution();
break;
case 32:
coordinates_of_social_space();
break;
case 64:
the_end_of_the_world();
break;
case 128:
stepamount = amountchecker(switchVar3); // returns preset value of floor where button was pre
passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of el
passtravel = travel_amount(stepamount, current_pos, passdirection); // determine travel amount
current_pos = stepamount;
Serial.print("Current Position of Passenger: ");
Serial.println(current_pos);
Serial.print("Current Position of Freight: ");
Serial.println(freight_pos);
delay(5000);
break;
} // end switch (case) statement
//current_pos = stepamount;
pinState = 0;
}
digitalWrite(myClockPin, 1);
return myDataIn;
}
// April 19 Elevator Code
#include <AFMotor.h>
int latchPin = 2;
int dataPin = 9;
int clockPin = 10;
int ledPin = 13;
int passtravel =0; //amount pass elevator will move. is direction independent.
int freighttravel = 0; // amount freight elevator will move.
int totalpasstravel = 0; // current_pos + passtravel for moving passenger elevator to desired
int totalfreighttravel = 0; // freight_pos + freighttravel for moving freight elevator to a d
int passdirection = 0; // direction passenger elevator will travel. will be 1 is Forward or
int freightdirection= 0; // direction freight elevator will travel.
int current_pos = 650; // current position of elevator. set to 1000 ground floor at start up
int freight_pos = 650; // current position of freight elevator
int stepamount; // variable that holds value assigned to floor where a button is pushed.
int f_speed = 10; // speed of freight elevator
//Define variables to hold the data for shift registers. Starting with a non-zero numbers can
byte switchVar1 = 0; //default number first comparison first ride of the day
byte switchVar2 = 0;
byte switchVar3 = 0;
return elev_direction;
}
if (travel_direction == 2)
{
travel = stepamount - position; // calculate number of steps elevator needs to travel if dir
}
else
{
travel = position - stepamount; // calculate number of steps elevator needs to travel if di
}
return travel;
}
switch (button)
{
case 1://floor 1
floorheight = 988;
break;
case 2://floor 2
floorheight = 1320;
break;
case 4://floor 3
floorheight = 1660;
break;
case 8://floor 4
floorheight = 1999;
break;
case 16://floor 5
floorheight = 2350;
break;
case 32://floor 6
floorheight = 2670;
break;
case 64://floor 7
floorheight = 3000;
break;
case 128://floor 8
floorheight = 3300;
break;
}
return floorheight;
}
// end function amountchecker
void elevator_love_letters()
{
}
void gateway_to_the_soul()
{
}
void big_brother()
{
}
void bureaucratic_prostitution()
{
}
void coordinates_of_social_space()
{
}
void the_fear()
{
}
void make_nice()
{
}
void we_have_a_situation_here()
{
}
void the_end_of_the_world ()
{
}
void pages_from_a_diary()
{
}
void setup()
{
//start serial
Serial.begin(9600);
motor_freight.setSpeed(40); // 40 rpm
motor_passenger.setSpeed(40); // 40 rpm
//define pin modes
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, INPUT);
pinMode(ledPin, OUTPUT);
void loop()
{
delayMicroseconds(20);
if (switchVar1 != 0)
{
stepamount = amountchecker(switchVar1); // returns preset value of floor where button was pre
passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of el
passtravel = travel_amount(stepamount, current_pos, passdirection); // determine travel amount
if (switchVar2 != 0)
{
stepamount = amountchecker(switchVar2); // returns preset value of floor where button was pre
passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of el
passtravel = travel_amount(stepamount, current_pos, passdirection); // determine travel amount
}
if (switchVar3 != 0)
{
stepamount = amountchecker(switchVar3); // returns preset value of floor where button was pre
passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of el
passtravel = travel_amount(stepamount, current_pos, passdirection); // determine travel amount
switch (switchVar3)
{
case 1: // the Freight Up Button
// make_nice Part A
motor_freight.step(f_speed, BACKWARD, SINGLE);
freight_pos = freight_pos + f_speed;
break;
//case 3:
case 4:
stepamount = amountchecker(switchVar3); // returns preset value of floor where button was pre
passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of el
passtravel = travel_amount(stepamount, current_pos, passdirection); // determine travel amount
case 8:
/*
stepamount = 3100;
passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of e
passtravel = travel_amount(stepamount, current_pos, passdirection); // determine travel amoun
motor_passenger.step(passtravel, passdirection, SINGLE);
current_pos = stepamount;
break;
case 16:
bureaucratic_prostitution();
break;
case 32:
coordinates_of_social_space();
break;
case 64:
the_end_of_the_world();
break;
current_pos = stepamount;
//Serial.print("Current Position of Passenger: ");
//Serial.println(current_pos);
//Serial.print("Current Position of Freight: ");
//Serial.println(freight_pos);
//delay(20);
break;
} // end switch (case) statement
//current_pos = stepamount;
pinState = 0;
}
digitalWrite(myClockPin, 1);
return myDataIn;