Project showcase
uBUG

uBUG © GPL3+

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

  • 2,932 views
  • 4 comments
  • 11 respects

Components and supplies

About this project

Click to see uBUG in action

Code

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

Schematics

uBUG Schematic
Schematic j0i7lh7cev

Comments

Similar projects you might like

Nipkow Disk Based Digital Display Device

Project showcase by christopheArduino

  • 16,292 views
  • 8 comments
  • 53 respects

Beautifully Finished Humidity and Temperature Sensor

Project tutorial by Wicked Makers

  • 16,864 views
  • 21 comments
  • 135 respects

Gixie Clock

Project showcase by xingda

  • 15,388 views
  • 17 comments
  • 94 respects

Magic Cauldron

Project showcase by Ian McKay

  • 5,957 views
  • 3 comments
  • 21 respects

Colors of Photons

Project showcase by Eva Konya and Janos Magyar

  • 4,421 views
  • 4 comments
  • 21 respects

Arduino LED Matrix Game of Life

Project showcase by aerodynamics

  • 2,803 views
  • 0 comments
  • 19 respects
Add projectSign up / Login