//License: Creative Commons CC-BY-SA-compatible Open Source Ecology (OSE) License //Purpose: for testing Open Source Ecology's CEB Press //Orientation: when you face the CEB Press, the ejection side is to your left //Motion Control: the CEB Press has 5 motions- it can move its primary cylinder up and down, its secondary cylinder left and right, and rotate its shaker motor //Sensors: the CEB Press has 2 hall effect sensors; on the primary cylinder and the secondary cylinder. The sensors switch and latch on and off when magnets move past them. //Test Selection: type true or false for the tests you want to do or not //Starting Tests: boolean StartDown = true; //Want the primary cylinder to move down? int DownTime = 6000; //For how long in milliseconds? boolean StartRight = true; //Want the secondary cylinder to move right? int RightTime = 3000; //For how long in milliseconds? boolean StartShake = true; //Want the shaker motor to spin? int ShakeTime = 3000; //For how long in milliseconds? //Repeating Tests: boolean RepeatPrimary = true; //Want the primary cylinder to cycle up and down according to the primary sensor and magnets? boolean RepeatSecondary = true; //Want the secondary cylinder to cycle left and right according to the secondary sensor and magnets? int CycleDelay = 500; //How much time between each motion (up, down, left, or right) in milliseconds? //Sensor Variables: int S1 = A0; //Set the primary sensor pin int S2 = A1; //Set the secondary sensor pin //Sensor Data Processing Variables int samplenumber = 10; //How many samples per reading? int samples[10]; //Variables to store each sample value - this should equal samplenumber int sampledelay = 2;//Time delay between getting each sample in milliseconds float Trigger = 0.09; //Sensor threshold in volts int i; //Variable for sample repetition count float Reading = 0; //Variable to store averaged signal value int ActiveSensor = 0; //Variable that tells which sensor should be read by the averaging function //Signal Averaging Function: void average(){ Reading = 0; for(i = 0;i Trigger){ break; } } } void belowtrigger(){ Serial.println("Wait for Below Trigger"); while(1==1){ average(); if (Reading < Trigger){ break; } } } //Starting! void setup(){ //Serial communication on! Serial.begin(9600); //Pins assigned as inputs! pinMode(S1,INPUT);//Primary Sensor pinMode(S2,INPUT);//Secondary Sensor //Pins assigned as outputs! pinMode(3, OUTPUT);//Primary Down pinMode(6, OUTPUT);//Primary Up pinMode(9, OUTPUT);//Secondary Left pinMode(10, OUTPUT);//Secondary Right pinMode(11, OUTPUT);//Shaker //Starting Motion: Primary Down! if (StartDown == true){ Serial.println("Down Time"); digitalWrite(3, HIGH); delay(DownTime); digitalWrite(3, LOW); } //Starting Motion: Secondary Right! if (StartRight == true){ Serial.println("Right Time"); digitalWrite(10, HIGH); delay(RightTime); digitalWrite(10, LOW); } //Starting Motion: Shaker Spin! if (StartShake == true){ Serial.println("Shake Time"); digitalWrite(11, HIGH); delay(ShakeTime); digitalWrite(11, LOW); } } //Repeating! void loop(){ //Primary Cylinder Cycle: Up and Down! if (RepeatPrimary == true){ Serial.println("Up Full"); ActiveSensor = S1; digitalWrite(6, HIGH); abovetrigger(); belowtrigger(); abovetrigger(); digitalWrite(6, LOW); delay(CycleDelay); Serial.println("Down Full"); digitalWrite(3, HIGH); abovetrigger(); belowtrigger(); abovetrigger(); digitalWrite(3, LOW); delay(CycleDelay); } //Secondary Cylinder Cycle: Left and Right! if (RepeatSecondary == true){ Serial.println("Left Full"); ActiveSensor = S2; digitalWrite(9, HIGH); abovetrigger(); belowtrigger(); abovetrigger(); digitalWrite(9, LOW); delay(CycleDelay); Serial.println("Right Full"); digitalWrite(10, HIGH); abovetrigger(); belowtrigger(); abovetrigger(); digitalWrite(10, LOW); delay(CycleDelay); } } //Repeating the loop!