I made an original plotter "eddyWrite."
OperationConstitutionMove the crane with two types of servos and turn the base with a stepping motor.
The base and various fixtures were output with a 3D printer.
I have processed my child's crane game toy.
The housing was mainly made of wood.
- Button 1: Start drawing
- Button 2: Control the servo motor to raise and lower the pen
- Button 3: Controls 360 ° continuous rotation servo and returns slider
When drawing, rotate the base with a stepping motor to read the data (graphics.h) and raise and lower the pen.
#include <Servo.h>
#include "graphics.h"
int APHASE = 4;
int AENBL = 5;
int BPHASE = 6;
int BENBL = 7;
int waitStep = 4;
int servoAngle = 0;
int rot = 0;
Servo servo;
Servo servoR;
int Button1 = 10;
int Button2 = 11;
int Button3 = 12;
void setup() {
Serial.begin(115200);
pinMode(Button1, INPUT_PULLUP);
pinMode(Button2, INPUT_PULLUP);
pinMode(Button3, INPUT_PULLUP);
pinMode(APHASE,OUTPUT);
pinMode(AENBL,OUTPUT);
pinMode(BPHASE,OUTPUT);
pinMode(BENBL,OUTPUT);
digitalWrite(AENBL,HIGH);
digitalWrite(BENBL,HIGH);
servo.attach(8); //SG90
servoR.attach(9); //FS90R
servoR.write(90);
servo.write(0);
}
void loop() {
if(digitalRead(Button1) == 0 && rot == 0){
rot = 1;
for(int i = 0; i <= 15; i++){
//Pen up
if(servoAngle == 18){
for(servoAngle = 18; servoAngle >= 0; servoAngle--){
servo.attach(8);
servo.write(servoAngle);
delay(10);
}
servo.detach();
}
servoAngle = 0;
//Slider movement
if(i != 0){
servoR.write(120);
delay(252);
servoR.write(90);
}
// One rotation of base
for(int j = 99; j >= 0; j--){
if(pgm_read_byte_near(pic[j]+i) == 1){
//Pen up
if(servoAngle == 0){
for(servoAngle = 0; servoAngle <= 18; servoAngle++){
servo.attach(8);
servo.write(servoAngle);
delay(20);
}
servo.detach();
}
servoAngle = 18;
}else{
//Pen down
if(servoAngle == 18){
for(servoAngle = 18; servoAngle >= 0; servoAngle--){
servo.attach(8);
servo.write(servoAngle);
delay(10);
}
}
servo.detach();
servoAngle = 0;
}
digitalWrite(APHASE,HIGH);
delay(waitStep);
digitalWrite(BPHASE,HIGH);
delay(waitStep);
digitalWrite(APHASE,LOW);
delay(waitStep);
digitalWrite(BPHASE,LOW);
delay(waitStep);
}
}
servo.attach(8);
servo.write(0);
delay(800);
servoAngle = 0;
}
//pen up and down
if(digitalRead(Button2) == 0){
servo.write(18);
}else{
servo.write(0);
}
//Slider back
if(digitalRead(Button3) == 0){
rot = 0;
servoR.write(77);
servo.write(0);
}else{
servoR.write(90);
}
}
Drawing data (graphics.h)
An array for drawing was created, and if it is 1, the pen is lowered and 0 is raised. eddyWrite can draw with a resolution of 16 in the sliding direction and 100 divisions per rotation.
The drawing data was generated in Python.
The left image was read with python code, reduced and converted to polar coordinates to generate drawing array data, and the right picture was output.
ありがとう
Comments