Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Servo.h>
- const int switchPin = 8; //active low
- const int servoPin = 9;
- const int blade_home = 90;
- const int blade_cut = 145;
- Servo servo;
- void setup() {
- pinMode(switchPin, HIGH);
- servo.attach(servoPin); // connect to servo
- servo.write(blade_home); // move blade to open position
- delay(1000); // wait for servo to complete movement
- servo.detach(); // disconnect from servo
- }
- void loop() {
- if (digitalRead(switchPin)) // when button is depressed upon filament insertion
- { delay(500); // wait for filament insertion to complete
- servo.attach(servoPin); // connect to servo
- servo.write(blade_cut); // move blade to cut position
- delay(1000); // wait for servo to complete movement
- servo.write(blade_home); // move blade to home position
- delay(2500); // wait for servo to complete movement
- servo.detach(); // disconnect from servo
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment