lorenzo brick
Published © CC BY-NC

Sonar Pill Launcher

Ever been bored having to place all your solutes into solvents? With this, you can happily catapult them into their respective beakers.

BeginnerShowcase (no instructions)5 hours28
Sonar Pill Launcher

Things used in this project

Hardware components

SG90 Micro-servo motor
SG90 Micro-servo motor
×2
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Arduino Nano R3
Arduino Nano R3
×1

Software apps and online services

Arduino IDE
Arduino IDE
Tinkercad
Autodesk Tinkercad

Hand tools and fabrication machines

Tape, Double Sided
Tape, Double Sided
Tape, Gaffer / Duct / Cloth
Tape, Gaffer / Duct / Cloth
3D Printer (generic)
3D Printer (generic)
UHMWPE (Ultra High Molecular Weight Poly-Ethylene) String

Story

Read more

Custom parts and enclosures

Catapult 3D Print

TinkerCAD file for printing the catapult

Sonar Pill Launcher Setup

TinkerCAD file for printing the tower and the Ultrasonic Range Finder holder

Schematics

Circuit Diagram

wires

Code

Sonar Pill Launcher Code

C/C++
Code to rotate the Ultrasonic rangefinder and to position the catapult to the right angle.
#include <LiquidCrystal_I2C.h>
#include "NewPing.h"
#include <Servo.h>

Servo myservo;  
Servo myservo1;

int pos = 0;
int pos1 = 0;


LiquidCrystal_I2C lcd(0x27,16,2);  


#define TRIGGER_PIN 9
#define ECHO_PIN 10
#define MAX_DISTANCE 400




NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);

void setup() {
  myservo.attach(3);
  myservo1.attach(7);
  lcd.begin(16, 2); 

  lcd.backlight();
  lcd.clear();
  Serial.begin(9600);
}



void loop() {
  for (pos = 0; pos <= 90; pos += 1) { 
    lcd.clear();
    lcd.setCursor(1,0);
    int distance = sonar.ping_cm(); 
    lcd.print(distance);
    
    if (distance == 35){
      pos1 = pos;
      Serial.println(pos1);
      myservo1.write(pos1);
    }
    myservo.write(pos);  
    delay(75);                       
  }
  
  for (pos = 90; pos >= 0; pos -= 1) {
    lcd.clear();
    lcd.setCursor(1,0); 
    
    int distance = sonar.ping_cm();
    lcd.print(distance);              
    
    if (distance == 35){
      pos1 = pos;
      Serial.println(pos1);
      myservo1.write(pos1);
    }
    myservo.write(pos);
    delay(75);                       
  }
}

Credits

lorenzo brick
1 project • 0 followers

Comments