3688894 Elevator Programming Code

download 3688894 Elevator Programming Code

of 178

description

elevator programming code

Transcript of 3688894 Elevator Programming Code

  • #include

    AF_Stepper motor_freight(200, 1);AF_Stepper motor_passenger(200, 2);

    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

    AF_Stepper motor_freight(200, 1);AF_Stepper motor_passenger(200, 2);

    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 #include "WProgram.h"#include "AFMotor.h"

    static uint8_t latch_state;

    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"

    ENABLE_PORT &= ~_BV(ENABLE); // enable the chip outputs!}

    void AFMotorController::latch_tx(void) { uint8_t i;

    LATCH_PORT &= ~_BV(LATCH); SER_PORT &= ~_BV(SER); for (i=0; i

  • file:///Users/mg/Documents/M2%20Thesis%202008/Tech/03%20Arduino%20Code%20/AFMotornoservo.txt

    /****************************************** MOTORS******************************************/

    AF_DCMotor::AF_DCMotor(uint8_t num, uint8_t freq) { motornum = num; pwmfreq = freq;

    MC.enable();

    switch (num) { case 1: latch_state &= ~_BV(MOTOR1_A) & ~_BV(MOTOR1_B); // set both motor pins to 0 MC.latch_tx(); // use PWM from timer2A TCCR2A |= _BV(COM2A1) | _BV(WGM20) | _BV(WGM21); // fast PWM, turn on oc0 TCCR2B = freq & 0x7; OCR2A = 0; DDRB |= _BV(3); break; case 2: latch_state &= ~_BV(MOTOR2_A) & ~_BV(MOTOR2_B); // set both motor pins to 0 MC.latch_tx(); // use PWM from timer2B TCCR2A |= _BV(COM2B1) | _BV(WGM20) | _BV(WGM21); // fast PWM, turn on oc0a TCCR2B = _BV(CS22); // clk/256*64 = ~1Khz TCCR2B = freq & 0x7; DDRD |= _BV(3); break; case 3: latch_state &= ~_BV(MOTOR3_A) & ~_BV(MOTOR3_B); // set both motor pins to 0 MC.latch_tx(); // use PWM from timer0B TCCR0A |= _BV(COM0B1) | _BV(WGM00) | _BV(WGM01); // fast PWM, turn on oc0a TCCR0B = freq & 0x7; OCR0B = 0; DDRD |= _BV(5); break; case 4:

    file:///Users/mg/Documents/M2%20Thesis%202008/Tech/03%20Arduino%20Code%20/AFMotornoservo.txt (2 of 8) [26/04/08 4:33:39 PM]

  • file:///Users/mg/Documents/M2%20Thesis%202008/Tech/03%20Arduino%20Code%20/AFMotornoservo.txt

    latch_state &= ~_BV(MOTOR4_A) & ~_BV(MOTOR4_B); // set both motor pins to 0 MC.latch_tx(); // use PWM from timer0A TCCR0A |= _BV(COM0A1) | _BV(WGM00) | _BV(WGM01); // fast PWM, turn on oc0a TCCR0B = freq & 0x7; OCR0A = 0; DDRD |= _BV(6); break; }}

    void AF_DCMotor::run(uint8_t cmd) { uint8_t a, b; switch (motornum) { case 1: a = MOTOR1_A; b = MOTOR1_B; break; case 2: a = MOTOR2_A; b = MOTOR2_B; break; case 3: a = MOTOR3_A; b = MOTOR3_B; break; case 4: a = MOTOR4_A; b = MOTOR4_B; break; default: return; } 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;

    file:///Users/mg/Documents/M2%20Thesis%202008/Tech/03%20Arduino%20Code%20/AFMotornoservo.txt (3 of 8) [26/04/08 4:33:39 PM]

  • file:///Users/mg/Documents/M2%20Thesis%202008/Tech/03%20Arduino%20Code%20/AFMotornoservo.txt

    }}

    void AF_DCMotor::setSpeed(uint8_t speed) { switch (motornum) { case 1: OCR2A = speed; break; case 2: OCR2B = speed; break; case 3: OCR0B = speed; break; case 4: OCR0A = speed; break; }}

    /****************************************** STEPPERS******************************************/

    AF_Stepper::AF_Stepper(uint16_t steps, uint8_t num) { MC.enable();

    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(); // do not use PWM! TCCR2B = 0; // turn off PWM OCR2A = 0;

    // enable both H bridges DDRD |= _BV(3); PORTD |= _BV(3); DDRB |= _BV(3); PORTB |= _BV(3); } else if (steppernum == 2) { latch_state &= ~_BV(MOTOR3_A) & ~_BV(MOTOR3_B) & ~_BV(MOTOR4_A) & ~_BV(MOTOR4_B); // all motor pins to 0

    file:///Users/mg/Documents/M2%20Thesis%202008/Tech/03%20Arduino%20Code%20/AFMotornoservo.txt (4 of 8) [26/04/08 4:33:39 PM]

  • file:///Users/mg/Documents/M2%20Thesis%202008/Tech/03%20Arduino%20Code%20/AFMotornoservo.txt

    MC.latch_tx(); // do not use PWM! TCCR0B = 0; // turn off PWM OCR0A = 0; // enable both H bridges DDRD |= _BV(5) | _BV(6); PORTD |= _BV(5) | _BV(6); }}

    void AF_Stepper::setSpeed(uint16_t rpm) { usperstep = 60000000 / (revsteps * rpm); steppingcounter = 0;}

    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(); }}

    void AF_Stepper::step(uint16_t steps, uint8_t dir, uint8_t style) { uint32_t uspers = usperstep; if (style == INTERLEAVE) { uspers /= 2; }

    while (steps--) { onestep(dir, style); delay(uspers/1000); // in ms steppingcounter += (uspers % 1000); if (steppingcounter >= 1000) { delay(1); steppingcounter -= 1000; }

    file:///Users/mg/Documents/M2%20Thesis%202008/Tech/03%20Arduino%20Code%20/AFMotornoservo.txt (5 of 8) [26/04/08 4:33:39 PM]

  • file:///Users/mg/Documents/M2%20Thesis%202008/Tech/03%20Arduino%20Code%20/AFMotornoservo.txt

    }}

    void AF_Stepper::onestep(uint8_t dir, uint8_t style) { uint8_t a, b, c, d; uint8_t step;

    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; }

    // OK next determine what step we are at if ((latch_state & (a | b)) == (a | b)) step = 1; else if ((latch_state & (b | c)) == (b | c)) step = 3; else if ((latch_state & (c | d)) == (c | d)) step = 5; else if ((latch_state & (d | a)) == (d | a)) step = 7; else if (latch_state & a) step = 0; else if (latch_state & b) step = 2; else if (latch_state & c) step = 4; else step = 6;

    // next determine what sort of stepping procedure we're up to if (style == SINGLE) { if (step % 2) { // we're at an odd step, weird

    file:///Users/mg/Documents/M2%20Thesis%202008/Tech/03%20Arduino%20Code%20/AFMotornoservo.txt (6 of 8) [26/04/08 4:33:39 PM]

  • file:///Users/mg/Documents/M2%20Thesis%202008/Tech/03%20Arduino%20Code%20/AFMotornoservo.txt

    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

    file:///Users/mg/Documents/M2%20Thesis%202008/Tech/03%20Arduino%20Code%20/AFMotornoservo.txt (7 of 8) [26/04/08 4:33:39 PM]

  • file:///Users/mg/Documents/M2%20Thesis%202008/Tech/03%20Arduino%20Code%20/AFMotornoservo.txt

    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();}

    file:///Users/mg/Documents/M2%20Thesis%202008/Tech/03%20Arduino%20Code%20/AFMotornoservo.txt (8 of 8) [26/04/08 4:33:39 PM]

  • // H Bridge Trouble Shooting

    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 Motor Controller language: Wiring/Arduino

    This program drives a unipolar or bipolar stepper motor. The motor is attached to digital pins 8 and 9 of the Arduino.

    The motor moves 100 steps in one direction, then 100 in the other.

    Created 11 Mar. 2007 Modified 7 Apr. 2007 by Tom Igoe

    */

    // define the pins that the motor is attached to. You can use// any digital I/O pins.

    #include

    #define motorSteps 50 // change this depending on the number of steps // per revolution of your motor#define motorPin1 8#define motorPin2 9#define motorPin3 7#define motorPin4 6#define ledPin 13

    // initialize of the Stepper library:Stepper myStepper(motorSteps, motorPin1,motorPin2,motorPin3,motorPin4);

    void setup() { // set the motor speed at 60 RPMS: myStepper.setSpeed(120);

    // Initialize the Serial port: Serial.begin(9600);

    // set up the LED pin: pinMode(ledPin, OUTPUT); // blink the LED: blink(3);}

    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);

    }

    // Blink the reset LED:void blink(int howManyTimes) { int i; for (i=0; i< howManyTimes; i++) { digitalWrite(ledPin, HIGH); delay(200); digitalWrite(ledPin, LOW); delay(200); }}

  • // 15 March Shift Register B//define where your pins areint latchPin = 7;int dataPin = 8;int clockPin = 9;int ledPin = 13;

    //Define variables to hold the data //for shift register.//starting with a non-zero numbers can help//troubleshootbyte switchVar1 = 72; //01001000

    void setup() { //start serial Serial.begin(9600);

    //define pin modes 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); //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 switchVar1 = shiftIn(dataPin, clockPin); if (switchVar1 > 0)//{digitalWrite(ledPin,1);//delay(1000);//digitalWrite (ledPin,0);//} //Print out the results. //leading 0's at the top of the byte //(7, 6, 5, etc) will be dropped before //the first pin that has a high input //reading Serial.println(switchVar1, BIN);

    //white spaceSerial.println("Marnie");//delay so all these print satements can keep up.

  • delay(500);

    }

    //------------------------------------------------end main loop

    ////// ----------------------------------------shiftIn function///// just needs the location of the data pin and the clock pin///// it returns a byte with each bit in the byte corresponding///// to a pin on the shift register. leftBit 7 = Pin 7 / Bit 0= Pin 0

    byte shiftIn(int myDataPin, int myClockPin) { int i; int temp = 0; int pinState; byte myDataIn = 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

  • //Serial.println(myDataIn, BIN); return myDataIn;}

  • //15 March Shift Register 1

    //define where your pins areint latchPin = 2;int dataPin = 9;int clockPin = 10;int ledPin = 13;

    //Define variables to hold the data //for shift register.//starting with a non-zero numbers can help//troubleshootbyte switchVar1 = 72; //01001000

    void setup() { //start serial Serial.begin(9600);

    //define pin modes 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); //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 switchVar1 = shiftIn(dataPin, clockPin); if (switchVar1 == 1){digitalWrite(ledPin,1);delay(1000);digitalWrite (ledPin,0);} //Print out the results. //leading 0's at the top of the byte //(7, 6, 5, etc) will be dropped before //the first pin that has a high input //reading Serial.println(switchVar1, BIN);

    //white space

  • Serial.println("Marnie");//delay so all these print satements can keep up. delay(500);

    }

    //------------------------------------------------end main loop

    ////// ----------------------------------------shiftIn function///// just needs the location of the data pin and the clock pin///// it returns a byte with each bit in the byte corresponding///// to a pin on the shift register. leftBit 7 = Pin 7 / Bit 0= Pin 0

    byte shiftIn(int myDataPin, int myClockPin) { int i; int temp = 0; int pinState; byte myDataIn = 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

  • //debuging print statements whitespace //Serial.println(); //Serial.println(myDataIn, BIN); return myDataIn;}

  • // 1 April Shift Register Trials A

    //define where your pins areint latchPin = 8;int dataPin = 9;int clockPin = 7;int ledPin = 13;

    //Define variables to hold the data //for shift register.//starting with a non-zero numbers can help//troubleshootbyte switchVar1 = 72; //default number first comparison first ride of the dayint floorcount = 0;

    void setup() { //start serial Serial.begin(9600);

    //define pin modes 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); //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 switchVar1 = shiftIn(dataPin, clockPin); 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);}

    }

    //------------------------------------------------end main loop

    ////// ----------------------------------------shiftIn function///// just needs the location of the data pin and the clock pin///// it returns a byte with each bit in the byte corresponding///// to a pin on the shift register. leftBit 7 = Pin 7 / Bit 0= Pin 0

    byte shiftIn(int myDataPin, int myClockPin) { int i; int temp = 0; int pinState; byte myDataIn = 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

  • //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

    //define where your pins areint latchPin = 2;int dataPin = 9;int clockPin = 10;int ledPin = 13;

    //Define variables to hold the data //for shift register.//starting with a non-zero numbers can help//troubleshootbyte switchVar1 = 72; //default number first comparison first ride of the daybyte switchVar2 = 159;int floorcount = 0;

    void setup() { //start serial Serial.begin(9600);

    //define pin modes 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); //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 switchVar1 = shiftIn(dataPin, clockPin); //switchVar2 = shiftIn(dataPin, clockPin);

    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);}}

    //------------------------------------------------end main loop

    ////// ----------------------------------------shiftIn function///// just needs the location of the data pin and the clock pin///// it returns a byte with each bit in the byte corresponding///// to a pin on the shift register. leftBit 7 = Pin 7 / Bit 0= Pin 0

    byte shiftIn(int myDataPin, int myClockPin) { int i; int temp = 0;

  • int pinState; byte myDataIn = 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

  • // 1 April Shift Register Trial B

    //define where your pins areint latchPin = 8;int dataPin = 9;int clockPin = 7;int ledPin = 13;

    //Define variables to hold the data //for shift register.//starting with a non-zero numbers can help//troubleshootbyte switchVar1 = 72; //default number first comparison first ride of the dayint floorcount = 0;

    void setup() { //start serial Serial.begin(9600);

    //define pin modes 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); //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 switchVar1 = shiftIn(dataPin, clockPin); 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);}

    //------------------------------------------------end main loop

    ////// ----------------------------------------shiftIn function///// just needs the location of the data pin and the clock pin///// it returns a byte with each bit in the byte corresponding///// to a pin on the shift register. leftBit 7 = Pin 7 / Bit 0= Pin 0

    byte shiftIn(int myDataPin, int myClockPin) { int i; int temp = 0; int pinState; byte myDataIn = 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
  • // 3 April Shift Register Trail A

    //define where your pins areint latchPin = 2;int dataPin = 9;int clockPin = 10;int ledPin = 13;

    //Define variables to hold the data //for shift register.//starting with a non-zero numbers can help//troubleshootbyte switchVar1 = 72; //default number first comparison first ride of the daybyte switchVar2 = 159;int floorcount = 0;

    void setup() { //start serial Serial.begin(9600);

    //define pin modes 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); //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 switchVar1 = shiftIn(dataPin, clockPin); switchVar2 = shiftIn(dataPin, clockPin);

    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 > 255) {//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);}}

    //------------------------------------------------end main loop

    ////// ----------------------------------------shiftIn function///// just needs the location of the data pin and the clock pin///// it returns a byte with each bit in the byte corresponding///// to a pin on the shift register. leftBit 7 = Pin 7 / Bit 0= Pin 0

    byte shiftIn(int myDataPin, int myClockPin) { int i;

  • int temp = 0; int pinState; byte myDataIn = 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

  • // 4 April Shift Register A

    //define where your pins areint latchPin = 2;int dataPin = 9;int clockPin = 7;int ledPin = 13;

    //Define variables to hold the data //for shift register.//starting with a non-zero numbers can help//troubleshootbyte switchVar1 = 72; //default number first comparison first ride of the daybyte switchVar2 = 159;int floorcount = 0;

    void setup() { //start serial Serial.begin(9600);

    //define pin modes 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); //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 switchVar1 = shiftIn(dataPin, clockPin); switchVar2 = shiftIn(dataPin, clockPin);

    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);}}

    //------------------------------------------------end main loop

    ////// ----------------------------------------shiftIn function///// just needs the location of the data pin and the clock pin///// it returns a byte with each bit in the byte corresponding///// to a pin on the shift register. leftBit 7 = Pin 7 / Bit 0= Pin 0

    byte shiftIn(int myDataPin, int myClockPin) { int i;

  • int temp = 0; int pinState; byte myDataIn = 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

  • // 6 April Shift Register Trial

    //define where your pins areint latchPin = 2;int dataPin = 9;int clockPin = 10;int ledPin = 13;

    //Define variables to hold the data //for shift register.//starting with a non-zero numbers can help//troubleshootbyte switchVar1 = 72; //default number first comparison first ride of the daybyte switchVar2 = 159;int floorcount = 0;

    void setup() { //start serial Serial.begin(9600);

    //define pin modes 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); //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 switchVar1 = shiftIn(dataPin, clockPin); switchVar2 = shiftIn(dataPin, clockPin);

    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);

    }

    //------------------------------------------------end main loop

    ////// ----------------------------------------shiftIn function///// just needs the location of the data pin and the clock pin///// it returns a byte with each bit in the byte corresponding///// to a pin on the shift register. leftBit 7 = Pin 7 / Bit 0= Pin 0

    byte shiftIn(int myDataPin, int myClockPin) { int i;

  • int temp = 0; int pinState; byte myDataIn = 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

  • // 7 April Shift Register Trial A

    //define where your pins areint latchPin = 2;int dataPin = 9;int clockPin = 10;int ledPin = 13;

    //Define variables to hold the data //for shift register.//starting with a non-zero numbers can help//troubleshootbyte switchVar1 = 72; //default number first comparison first ride of the daybyte switchVar2 = 159;int floorcount = 0;

    void setup() { //start serial Serial.begin(9600);

    //define pin modes 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); //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 switchVar1 = shiftIn(dataPin, clockPin); //switchVar2 = shiftIn(dataPin, clockPin);

    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);}}

    //------------------------------------------------end main loop

    ////// ----------------------------------------shiftIn function///// just needs the location of the data pin and the clock pin///// it returns a byte with each bit in the byte corresponding///// to a pin on the shift register. leftBit 7 = Pin 7 / Bit 0= Pin 0

    byte shiftIn(int myDataPin, int myClockPin) { int i; int temp = 0;

  • int pinState; byte myDataIn = 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

  • // 9 April Shift Register Trial A

    //define where your pins areint latchPin = 2;int dataPin = 9;int clockPin = 10;int ledPin = 13;

    //Define variables to hold the data //for shift register.//starting with a non-zero numbers can help//troubleshootbyte switchVar1 = 72; //default number first comparison first ride of the daybyte switchVar2 = 159;int floorcount = 0;

    void setup() { //start serial Serial.begin(9600);

    //define pin modes 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); //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 switchVar1 = shiftIn(dataPin, clockPin); //switchVar2 = shiftIn(dataPin, clockPin);

    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 > 128) //{//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);}}

    //------------------------------------------------end main loop

    ////// ----------------------------------------shiftIn function///// just needs the location of the data pin and the clock pin///// it returns a byte with each bit in the byte corresponding///// to a pin on the shift register. leftBit 7 = Pin 7 / Bit 0= Pin 0

    byte shiftIn(int myDataPin, int myClockPin) { int i; int temp = 0;

  • int pinState; byte myDataIn = 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

  • // 9 April Switch Trial B

    //define where your pins areint latchPin = 2;int dataPin = 9;int clockPin = 10;int ledPin = 13;

    //Define variables to hold the data //for shift register.//starting with a non-zero numbers can help//troubleshootbyte switchVar1 = 72; //default number first comparison first ride of the daybyte switchVar2 = 201;int floorcount = 0;

    void setup() { //start serial Serial.begin(9600);

    //define pin modes 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); //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 switchVar1 = shiftIn(dataPin, clockPin); switchVar2 = shiftIn(dataPin, clockPin);

    // 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);}}

    //------------------------------------------------end main loop

    ////// ----------------------------------------shiftIn function///// just needs the location of the data pin and the clock pin///// it returns a byte with each bit in the byte corresponding///// to a pin on the shift register. leftBit 7 = Pin 7 / Bit 0= Pin 0

    byte shiftIn(int myDataPin, int myClockPin) { int i; int temp = 0;

  • int pinState; byte myDataIn = 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

  • // April 10 Motor Trial Code

    #include

    AF_Stepper motor_freight(200, 2);//AF_Stepper motor_passenger(200, 2);

    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

    AF_Stepper motor_freight(200, 2);AF_Stepper motor_passenger(200, 1);

    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

    //define where your pins areint latchPin = 8;int dataPin = 9;int clockPin = 7;int ledPin = 13;

    //Define variables to hold the data //for shift register.//starting with a non-zero numbers can help//troubleshootbyte switchVar1 = 72; //default number first comparison first ride of the dayint floorcount = 0;

    void setup() { //start serial Serial.begin(9600);

    //define pin modes 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); //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 switchVar1 = shiftIn(dataPin, clockPin); 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);}

    }

    //------------------------------------------------end main loop

    ////// ----------------------------------------shiftIn function///// just needs the location of the data pin and the clock pin///// it returns a byte with each bit in the byte corresponding///// to a pin on the shift register. leftBit 7 = Pin 7 / Bit 0= Pin 0

    byte shiftIn(int myDataPin, int myClockPin) { int i; int temp = 0; int pinState; byte myDataIn = 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

  • //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

    //define where your pins areint latchPin = 8;int dataPin = 9;int clockPin = 7;int ledPin = 13;

    //Define variables to hold the data //for shift register.//starting with a non-zero numbers can help//troubleshootbyte switchVar1 = 72; //default number first comparison first ride of the dayint floorcount = 0;

    void setup() { //start serial Serial.begin(9600);

    //define pin modes 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); //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 switchVar1 = shiftIn(dataPin, clockPin); 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);}

    }

    //------------------------------------------------end main loop

    ////// ----------------------------------------shiftIn function///// just needs the location of the data pin and the clock pin///// it returns a byte with each bit in the byte corresponding///// to a pin on the shift register. leftBit 7 = Pin 7 / Bit 0= Pin 0

    byte shiftIn(int myDataPin, int myClockPin) { int i; int temp = 0; int pinState; byte myDataIn = 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

  • //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

    char passDirection; // hold whether passenger goes up or down//char freightDirection; // hold whether freight goes up or down

    int Pass_elevator_Is = 0; // position of elevator at current point in time. this will change with motor movement//int Freight_elevator_Is = 0; // position of elevator at current point in time. this will change with motor movement

    void setup(){Serial.begin(9600); //debugging to screen}

    /* determine whether motor needs to go forward or backward to bring elevator to pushed call button.

    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*/

    char elevator_Position( byte outside_Button, byte current_Pos){char direction;

    if (outside_Button > current_Pos){direction = "F";}else{direction = "B";}}

    void loop{

    // button push function here. probably a while loop.

    passDirection = elevator_Position(switchVar1, Pass_elevator_Is);freightDirection = elevator_Position(switchVar2, Freight_elevator_Is);

    // display value of passDirection and freightDirection. ouput to screenSerial.print("Passenger Direction: ");Serial.println(passDirection);delay(5000);Serial.print("Freight Direction: ");Serial.println(freightDirection);delay(5000);

    }

  • // 15 April Elev Control 4B#include

    //AF_Stepper motor_freight(200, 1);

    AF_Stepper motor_passenger(200, 1);

    //define where your Shift Register pins are

    int latchPin = 2;int dataPin = 9;int clockPin = 10;int ledPin = 13;

    int travel =0; //amount elevator will move. is directionless.int passdirection = 0; // direction elevator will travel. will be 1 is Forward or 2 is Backward.int current_pos = 1000; // current position of eleveator. set to 1000 ground floor at start upint stepamount; // variable that holds outside button push

    //Define variables to hold the data //for shift register.//starting with a non-zero numbers can help//troubleshootbyte switchVar1 = 0; //default number first comparison first ride of the daybyte switchVar2 = 159;

    // function that returns direction the elevator needs to travel

    int elevator_direction(int outside_button, int current_pos){ int direction = 0; //direction elevator travels if (outside_button > current_pos) { direction = 2; // this is up } else { direction = 1; // this is down } Serial.print("direction value FROM FUNCTION: "); Serial.println(direction); delay(3000); return direction;}

    // end elevator_direction function

    // function that returns floorheight value// at 3/8th scale this means 4.5 inches is one floor which is 350 steps per floor

    int amountchecker(byte outside_button){ int floorheight;

  • 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;}

    // end function amountchecker

    void setup() {

    //start serial

    Serial.begin(9600);

    // motor_freight.setSpeed(40); // 30 rpm motor_passenger.setSpeed(40); // 30 rpm

    //define pin modes

    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 datadigitalWrite(latchPin,1);//set it to 1 to collect parallel data, wait

    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

    switchVar1 = shiftIn(dataPin, clockPin);//switchVar2 = shiftIn(dataPin, clockPin);

    if (switchVar1 != 0){stepamount = amountchecker(switchVar1); // amount of travel necessarySerial.print("Step Amount value: "); //debuggingSerial.println(stepamount); //debugging

    passdirection = elevator_direction(stepamount, current_pos); // get direction elevator needs to travel we had switchVar1 here and got 1279Serial.print("Pass Direction from void loop: ");Serial.println(passdirection); // debugging

    Serial.print("Current position: ");Serial.println(current_pos); //debugging

    // stepamount = amountchecker(switchVar1); // amount of travel necessary//Serial.println(stepamount);

    if (passdirection == 2){ travel = stepamount - current_pos;} else{ travel = current_pos - stepamount;}

    Serial.print("Travel value: ");Serial.println(travel);

    delay(500);

    motor_passenger.step(travel, passdirection, SINGLE);current_pos = stepamount;

    digitalWrite(ledPin,1);delay(1000);digitalWrite (ledPin,0);

    }

  • }//------------------------------------------------end main loop

    ////// ----------------------------------------shiftIn function///// just needs the location of the data pin and the clock pin///// it returns a byte with each bit in the byte corresponding///// to a pin on the shift register. leftBit 7 = Pin 7 / Bit 0= Pin 0

    byte shiftIn(int myDataPin, int myClockPin) { int i;int temp = 0;int pinState;byte myDataIn = 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 downfor (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

  • // 15 April Shift Register Trials A

    //define where your pins areint latchPin = 2;int dataPin = 9;int clockPin = 10;int ledPin = 13;

    //Define variables to hold the data //for shift register.//starting with a non-zero numbers can help//troubleshootbyte switchVar1 = 72; //default number first comparison first ride of the daybyte switchVar2 = 159;byte switchVar3 = 251;int floorcount = 0;

    void setup() { //start serial Serial.begin(9600);

    //define pin modes 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); //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 switchVar1 = shiftIn(dataPin, clockPin); //switchVar2 = shiftIn(dataPin, clockPin); switchVar3 = shiftIn(dataPin, clockPin);

    //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 > 128) //{//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;//} 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);}}

    //------------------------------------------------end main loop

    ////// ----------------------------------------shiftIn function///// just needs the location of the data pin and the clock pin///// it returns a byte with each bit in the byte corresponding///// to a pin on the shift register. leftBit 7 = Pin 7 / Bit 0= Pin 0

    byte shiftIn(int myDataPin, int myClockPin) { int i; int temp = 0; int pinState; byte myDataIn = 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

  • digitalWrite(myClockPin, 1);

    } //debuging print statements whitespace //Serial.println(); //Serial.println(myDataIn, BIN); return myDataIn;}

  • // 15 April Elev Code D

    #include

    //AF_Stepper motor_freight(200, 1);

    AF_Stepper motor_passenger(200, 1);

    //define where your Shift Register pins are

    int latchPin = 2;int dataPin = 9;int clockPin = 10;int ledPin = 13;

    int travel =0; //amount elevator will move. is directionless.int passdirection = 0; // direction elevator will travel. will be 1 is Forward or 2 is Backward.int current_pos = 1000; // current position of eleveator. set to 1000 ground floor at start upint stepamount; // variable that holds outside button push

    //Define variables to hold the data //for shift register.//starting with a non-zero numbers can help//troubleshootbyte switchVar1 = 0; //default number first comparison first ride of the daybyte switchVar2 = 159;byte switchVar3 = 251,

    // function that returns direction the elevator needs to travel

    int elevator_direction(int outside_button, int current_pos){ int direction = 0; //direction elevator travels if (outside_button > current_pos) { direction = 2; // this is up } else { direction = 1; // this is down } Serial.print("direction value FROM FUNCTION: "); Serial.println(direction); delay(3000); return direction;}

    // end elevator_direction function

    // function that returns floorheight value// at 3/8th scale this means 4.5 inches is one floor which is 350 steps per floor

    int amountchecker(byte outside_button)

  • { int floorheight; 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;}

    // end function amountchecker

    void setup() {

    //start serial

    Serial.begin(9600);

    // motor_freight.setSpeed(40); // 30 rpm motor_passenger.setSpeed(40); // 30 rpm

    //define pin modes

    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 datadigitalWrite(latchPin,1);//set it to 1 to collect parallel data, wait

    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

    switchVar1 = shiftIn(dataPin, clockPin);switchVar2 = shiftIn(dataPin, clockPin);switchVar3 = shiftIn(dataPin, clockPin);

    if (switchVar1 != 0){stepamount = amountchecker(switchVar1); // amount of travel necessarySerial.print("Step Amount value: "); //debuggingSerial.println(stepamount); //debugging

    passdirection = elevator_direction(stepamount, current_pos); // get direction elevator needs to travel we had switchVar1 here and got 1279Serial.print("Pass Direction from void loop: ");Serial.println(passdirection); // debugging

    Serial.print("Current position: ");Serial.println(current_pos); //debugging

    // stepamount = amountchecker(switchVar1); // amount of travel necessary//Serial.println(stepamount);

    if (passdirection == 2){ travel = stepamount - current_pos;} else{ travel = current_pos - stepamount;}

    Serial.print("Travel value: ");Serial.println(travel);

    delay(500);

    motor_passenger.step(travel, passdirection, SINGLE);current_pos = stepamount;

    digitalWrite(ledPin,1);delay(1000);digitalWrite (ledPin,0);

  • }/// shift register 2

    else if (switchVar2 ! = 0){stepamount = amountchecker(switchVar1); // amount of travel necessarySerial.print("Step Amount value: "); //debuggingSerial.println(stepamount); //debugging

    passdirection = elevator_direction(stepamount, current_pos); // get direction elevator needs to travel we had switchVar1 here and got 1279Serial.print("Pass Direction from void loop: ");Serial.println(passdirection); // debugging

    Serial.print("Current position: ");Serial.println(current_pos); //debugging

    // stepamount = amountchecker(switchVar1); // amount of travel necessary//Serial.println(stepamount);

    if (passdirection == 2){ travel = stepamount - current_pos;} else{ travel = current_pos - stepamount;}

    Serial.print("Travel value: ");Serial.println(travel);

    delay(500);

    motor_passenger.step(travel, passdirection, SINGLE);current_pos = stepamount;

    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);} }

    //------------------------------------------------end main loop

    ////// ----------------------------------------shiftIn function///// just needs the location of the data pin and the clock pin///// it returns a byte with each bit in the byte corresponding///// to a pin on the shift register. leftBit 7 = Pin 7 / Bit 0= Pin 0

    byte shiftIn(int myDataPin, int myClockPin) { int i;int temp = 0;int pinState;byte myDataIn = 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 downfor (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
  • // 16 April Elev Code A

    #include

    //AF_Stepper motor_freight(200, 2);

    AF_Stepper motor_passenger(200, 1);

    //define where your Shift Register pins are

    int latchPin = 2;int dataPin = 9;int clockPin = 10;int ledPin = 13;

    int travel =0; //amount elevator will move. is direction independent.int passdirection = 0; // direction elevator will travel. will be 1 is Forward or 2 is Backward.int current_pos = 1000; // current position of eleveator. set to 1000 ground floor at start upint stepamount; // variable that holds value assigned to floor where the outside button is pushed

    //Define variables to hold the data //for shift register.//starting with a non-zero numbers can help//troubleshootbyte switchVar1 = 0; //default number first comparison first ride of the daybyte switchVar2 = 159;byte switchVar3 = 251;

    // function that returns direction the elevator needs to travel

    int elevator_direction(int outside_button, int current_pos){ int direction = 0; //direction elevator travels

    if (outside_button > current_pos) { direction = 2; // this is up } else { direction = 1; // this is down } Serial.print("direction value FROM FUNCTION: "); Serial.println(direction); delay(3000); return direction;}

    // end elevator_direction function

    // function that returns floorheight value// at 3/8th scale this means 4.5 inches is one floor which is 350 steps per floor

    int amountchecker(byte outside_button)

  • { int floorheight;

    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;}

    // end function amountchecker

    void setup(){

    //start serial

    Serial.begin(9600);

    // motor_freight.setSpeed(40); // 30 rpm motor_passenger.setSpeed(40); // 30 rpm

    //define pin modes

    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 datadigitalWrite(latchPin,1);//set it to 1 to collect parallel data, wait

    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

    switchVar1 = shiftIn(dataPin, clockPin);switchVar2 = shiftIn(dataPin, clockPin);switchVar3 = shiftIn(dataPin, clockPin);

    if (switchVar1 != 0){stepamount = amountchecker(switchVar1); // amount of travel necessarySerial.print("Step Amount value: "); //debuggingSerial.println(stepamount); //debugging

    passdirection = elevator_direction(stepamount, current_pos); // get direction elevator needs to travel we had switchVar1 here and got 1279Serial.print("Pass Direction from void loop: ");Serial.println(passdirection); // debugging

    Serial.print("Current position: ");Serial.println(current_pos); //debugging

    if (passdirection == 2){ travel = stepamount - current_pos;} else{ travel = current_pos - stepamount;}

    Serial.print("Travel value: ");Serial.println(travel);

    delay(500);

    motor_passenger.step(travel, passdirection, SINGLE);current_pos = stepamount;

    digitalWrite(ledPin,1);delay(1000);digitalWrite (ledPin,0);

    }

  • /// shift register 2

    if (switchVar2 != 0){stepamount = amountchecker(switchVar1); // amount of travel necessarySerial.print("Inside button Step Amount value: "); //debuggingSerial.println(stepamount); //debugging

    passdirection = elevator_direction(stepamount, current_pos); // get direction elevator needs to travel we had switchVar1 here and got 1279Serial.print("Inside button Pass Direction from void loop: ");Serial.println(passdirection); // debugging

    Serial.print("Current position: ");Serial.println(current_pos); //debugging

    if (passdirection == 2){ travel = stepamount - current_pos;} else{ travel = current_pos - stepamount;}

    Serial.print("Travel value: ");Serial.println(travel);

    delay(500);

    motor_passenger.step(travel, passdirection, SINGLE);current_pos = stepamount;

    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);} }

    //------------------------------------------------end main loop

    ////// ----------------------------------------shiftIn function///// just needs the location of the data pin and the clock pin///// it returns a byte with each bit in the byte corresponding///// to a pin on the shift register. leftBit 7 = Pin 7 / Bit 0= Pin 0

    byte shiftIn(int myDataPin, int myClockPin) { int i;int temp = 0;int pinState;byte myDataIn = 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 downfor (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

  • }digitalWrite(myClockPin, 1);

    }

    return myDataIn;

    }

  • // 16 April Elev Code B

    #include

    //AF_Stepper motor_freight(200, 1);

    AF_Stepper motor_passenger(200, 1);

    //define where your Shift Register pins are

    int latchPin = 2;int dataPin = 9;int clockPin = 10;int ledPin = 13;

    int travel =0; //amount elevator will move. is direction independent.int passdirection = 0; // direction elevator will travel. will be 1 is Forward or 2 is Backward.int current_pos = 1000; // current position of eleveator. set to 1000 ground floor at start upint stepamount; // variable that holds value assigned to floor where the outside button is pushed

    //Define variables to hold the data //for shift register.//starting with a non-zero numbers can help//troubleshootbyte switchVar1 = 0; //default number first comparison first ride of the daybyte switchVar2 = 0;byte switchVar3 = 251;

    // function that returns direction the elevator needs to travel

    int elevator_direction(int outside_button, int current_pos){ int direction = 0; //direction elevator travels

    if (outside_button > current_pos) { direction = 2; // this is up } else { direction = 1; // this is down } Serial.print("direction value FROM FUNCTION: "); Serial.println(direction); delay(3000); return direction;}

    // end elevator_direction function

    // function that returns floorheight value// at 3/8th scale this means 4.5 inches is one floor which is 350 steps per floor

    int amountchecker(byte outside_button)

  • { int floorheight;

    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;}

    // end function amountchecker

    void setup(){

    //start serial

    Serial.begin(9600);

    // motor_freight.setSpeed(40); // 30 rpm motor_passenger.setSpeed(40); // 30 rpm

    //define pin modes

    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 datadigitalWrite(latchPin,1);//set it to 1 to collect parallel data, wait

    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

    switchVar1 = shiftIn(dataPin, clockPin);switchVar2 = shiftIn(dataPin, clockPin);switchVar3 = shiftIn(dataPin, clockPin);

    if (switchVar1 != 0){stepamount = amountchecker(switchVar1); // amount of travel necessarySerial.print("Step Amount value: "); //debuggingSerial.println(stepamount); //debugging

    passdirection = elevator_direction(stepamount, current_pos); // get direction elevator needs to travel we had switchVar1 here and got 1279Serial.print("Pass Direction from void loop: ");Serial.println(passdirection); // debugging

    Serial.print("Current position: ");Serial.println(current_pos); //debugging

    if (passdirection == 2){ travel = stepamount - current_pos;} else{ travel = current_pos - stepamount;}

    Serial.print("Travel value: ");Serial.println(travel);

    delay(500);

    motor_passenger.step(travel, passdirection, SINGLE);current_pos = stepamount;

    digitalWrite(ledPin,1);delay(1000);digitalWrite (ledPin,0);

    }

  • /// shift register 2

    if (switchVar2 != 0){stepamount = amountchecker(switchVar2); // amount of travel necessarySerial.print("Inside button Step Amount value: "); //debuggingSerial.println(stepamount); //debugging

    passdirection = elevator_direction(stepamount, current_pos); // get direction elevator needs to travel we had switchVar1 here and got 1279Serial.print("Inside button Pass Direction from void loop: ");Serial.println(passdirection); // debugging

    Serial.print("Current position: ");Serial.println(current_pos); //debugging

    if (passdirection == 2){ travel = stepamount - current_pos;} else{ travel = current_pos - stepamount;}

    Serial.print("Travel value from inside button: ");Serial.println(travel);

    delay(500);

    motor_passenger.step(travel, passdirection, SINGLE);current_pos = stepamount;

    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);} }

    //------------------------------------------------end main loop

    ////// ----------------------------------------shiftIn function///// just needs the location of the data pin and the clock pin///// it returns a byte with each bit in the byte corresponding///// to a pin on the shift register. leftBit 7 = Pin 7 / Bit 0= Pin 0

    byte shiftIn(int myDataPin, int myClockPin) { int i;int temp = 0;int pinState;byte myDataIn = 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 downfor (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

  • }digitalWrite(myClockPin, 1);

    }

    return myDataIn;

    }

  • // 17 April Elev Code A

    #include

    //AF_Stepper motor_freight(200, 1);

    AF_Stepper motor_passenger(200, 1);

    //define where your Shift Register pins are

    int latchPin = 2;int dataPin = 9;int clockPin = 10;int ledPin = 13;

    int travel =0; //amount elevator will move. is direction independent.int passdirection = 0; // direction elevator will travel. will be 1 is Forward or 2 is Backward.int current_pos = 1000; // 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 help troubleshoot

    byte switchVar1 = 0; //default number first comparison first ride of the daybyte switchVar2 = 0;byte switchVar3 = 251;

    // Function that returns direction the elevator needs to travel.

    int elevator_direction(int button, int current_pos){ int direction = 0; //direction elevator travels

    if (button > current_pos) { direction = 2; // this is up } else { direction = 1; // this is down }

    delay(3000); return direction;}

    // end elevator_direction function

    // Function amountchecker. Returns preset floorheight value// at 3/8th scale this means 4.5 inches is one floor which is 350 steps per floor

    int amountchecker(byte button){ int floorheight;

  • 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 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

    //define pin modes

    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 datadigitalWrite(latchPin,1);//set it to 1 to collect parallel data, wait

    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

    switchVar1 = shiftIn(dataPin, clockPin); // outside buttonsswitchVar2 = shiftIn(dataPin, clockPin); // inside buttonsswitchVar3 = shiftIn(dataPin, clockPin); // special features buttons

    // shift register 1 Outside buttons

    if (switchVar1 != 0){stepamount = amountchecker(switchVar1); // returns preset value of floor where button was pressedSerial.print("Outside Button Step Amount value: "); //debuggingSerial.println(stepamount); //debugging

  • passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of elevatorSerial.print("Outside Button Pass Direction: ");Serial.println(passdirection); // debugging

    Serial.print("Current position of elevator: ");Serial.println(current_pos); //debugging

    if (passdirection == 2){ travel = stepamount - current_pos; // calculate number of steps elevator needs to travel if direction equals 2} else{ travel = current_pos - stepamount; // calculate number of steps elevator needs to travel if direction equals 1}

    Serial.print("Outside Button Travel Value: ");Serial.println(travel);

    delay(500);

    motor_passenger.step(travel, passdirection, SINGLE);current_pos = stepamount;

    digitalWrite(ledPin,1);delay(1000);digitalWrite (ledPin,0);

    }

    /// shift register 2 Inside buttons

    if (switchVar2 != 0){stepamount = amountchecker(switchVar2); // returns preset value of floor where button was pressedSerial.print("Inside button Step Amount value: "); //debuggingSerial.println(stepamount); //debugging

    passdirection = elevator_direction(stepamount, current_pos); // returns travel direction of elevatorSerial.print("Inside button Pass Direction: "); //debuggingSerial.println(passdirection); // debugging

    Serial.print("Current position of elevator: "); //debuggingSerial.println(current_pos); //debugging

    if (passdirection == 2){ travel = stepamount - current_pos; // calculate number of steps elevator needs to travel if direction equals 2} else{ travel = current_pos - stepamount; // calculate number of steps elevator needs to travel if direction equals 1}

    Serial.print("Inside Button Travel Value: "); //debuggingSerial.println(travel); //debugging

  • delay(500);

    motor_passenger.step(travel, passdirection, SINGLE);current_pos = stepamount;

    digitalWrite(ledPin,1); //debuggingdelay(1000); //debuggingdigitalWrite (ledPin,0); //debugging

    }

    ////shift register 3 Special Features

    //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