JHG
Published © GPL3+

uBUG

uBUG: Bubble Unik Guillotine delves in sheer electro-magnetic POETRY (small u stand for useless!)

IntermediateShowcase (no instructions)3,847
uBUG

Things used in this project

Story

Read more

Schematics

uBUG Schematic

Code

uBUG file

Arduino
// uBUG Bubble Unik Guillotine

// Helix Fan  : Inverted polarities since a drone helix is not a fan !

#include <Stepper.h>
#include <Servo.h>// Grid gate operation

#define STEPS_PER_MOTOR_REVOLUTION 32 // Number of steps per revolution of INTERNAL motor in 4-step mode
#define RevShaft 32 * 64 //2048, steps NB per 1 revolution of OUTPUT SHAFT (= gear reduction; 2048 steps)

Stepper small_stepper(STEPS_PER_MOTOR_REVOLUTION, 8, 10, 9, 11);// Declare 'small_stepper' variable pins
Servo GridServo;  // create a servo object

//Parameters ===================================================
  const float topLevelHatchet = 2.0; // : this defines Hatchet elevation level around 2.0

  int HelixOnMilliSec = 900;
  int MaxMapMtr = 255; //controls Helix speed range. NB MAX = 255

  int OPENGrid = 185;   // Grid Angle
  int CLOSEGrid = 55;   // Grid Angle
//Constants ====================================================
  const int SwitchPin = 2; //lateral Switch 
  const int HelixPin = 6; //Helix blower
  const int potPin = A0;// analog Potentiometer regulates Helix speed
  const int DOWN = 1; 
  const int UP = -1;
//Variables ====================================================
  int Steps2Take;
  int SwitchState = 0;
  
//MAIN =========================================================  
//MAIN =========================================================
void setup() {
    Serial.begin(9600); 
    
    GridServo.attach(5); // PWM pin required
    GridServo.write(CLOSEGrid); 
    
// NB NB NB Stepper Library sets pins as outputs NB NB NB
    pinMode(SwitchPin, INPUT);
    pinMode(HelixPin, OUTPUT);
    digitalWrite (HelixPin,LOW);
    
// To bring Hatchet to bottom reference level with lateral Switch 
    SwitchState = digitalRead(SwitchPin);
       while (SwitchState == LOW){
Serial.print("SwitchState: ");
Serial.println(SwitchState);    
          Steps2Take  =  DOWN * RevShaft * 0.0454;
          small_stepper.setSpeed(1000);   
          small_stepper.step(Steps2Take);
          SwitchState = digitalRead(SwitchPin);
          delay(2);
       }//END while
       
       delay(200);
       
 // Small Up step to clear Switch lever : this defines Hatchet bottom level
        Steps2Take  =  UP * RevShaft * 0.1;
        small_stepper.setSpeed(1000);   
        small_stepper.step(Steps2Take);
        delay(200);
        
Serial.print("SwitchState  after WHILE: ");
Serial.println(SwitchState);   
}//END setup

void loop() {
Serial.println("===============================");
 // Hatchet emerge from reservoir 
    Steps2Take  =  UP * RevShaft * topLevelHatchet;  //Up
    small_stepper.setSpeed(1000);   
    small_stepper.step(Steps2Take);

  // Grid OPEN
     GridServo.write(OPENGrid);
     delay(400);

 // Helix blows Bubble   
    analogWrite(HelixPin,(fPotControl())); 
    delay(HelixOnMilliSec);
    digitalWrite (HelixPin,LOW);

// Grid CLOSE
     delay(200);
     GridServo.write(CLOSEGrid);

     
 // Hatchet dips into reservoir
    Steps2Take  =  DOWN * RevShaft * topLevelHatchet; //Down
    small_stepper.setSpeed(1000);   
    small_stepper.step(Steps2Take);
    delay(500);

    }// END loop

// SUBs &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
int fPotControl(){ // Potentiometer regulates Helix speed
 int   potVal = analogRead(potPin);
 int   mtrVal = map(potVal,0, 1023, 0, MaxMapMtr); // motorVal
    
Serial.print (potVal);
Serial.print (" ; ");
Serial.println (mtrVal);

    return mtrVal;
}//END sPotControl

Credits

JHG

JHG

0 projects • 1 follower

Comments