//Descending Spider Code //MrSirLRD //L293D Pins int a1 = 1; //Input pin 1 int a2 = 2; //Input pin2 int Enable = 3; //Enable pin //IR sensor pins const int irled = 8; //IR LED output const int IRtrans = 0; //IR analoge input pin void setup() { // put your setup code here, to run once: pinMode(a1, OUTPUT); pinMode(a2, OUTPUT); pinMode(Enable, OUTPUT); pinMode(irled, INPUT); pinMode(outpin, OUTPUT); //USe this to print out IR read in values //Serial.begin(9600); }//end setup void loop() { // put your main code here, to run repeatedly: //Only need to loop IRsens IRsens(); }//end loop //Moveing the spider code void updown () { digitalWrite(Enable, HIGH); down(); delay(90000); up(); delay(95000); digitalWrite(Enable, LOW); delay(60000); }//end updown //An analog value is read before and after the IR LEDs are turned on //the difference is taken //this value is "value" //if this goes above a certain number (TriggVal) the spider move code is triggered void IRsens() { int reading1; int reading2; int value; int TriggVal = 40; digitalWrite(irled, LOW); delay(100); reading1 = analogRead(IRtrans); digitalWrite(irled, HIGH); delay(200); reading2 = analogRead(IRtrans); digitalWrite(irled, LOW); value = reading1 - reading2; // Serial.println(value); if (value > TriggVal) { // Serial.println("yes"); updown(); }//end if` }//end IRsens //move up void up() { digitalWrite(a1, LOW); digitalWrite(a2, HIGH); }//end up //move down void down() { digitalWrite(a1, HIGH); digitalWrite(a2, LOW); }//end down