A simple library that turns an Arduino and a couple of motors into a 2D plotter. The microcontroller uses two stepper motors to set the horizontal position of the end effector and uses a servo to move it closer and further away from the surface.
- main class representing the plotter
- stepper motor controlling movement along X axis
- stepper motor controlling movement along Y axis
- servo for lifting of the end effector
- EEPROM address for storing X position of the end effector
- default value: 0
- EEPROM address for storing Y position of the end effector
- default value: 2
- size of the character in stepper motor moves (same for both axes)
- actual line where the end effector works (starts from 0)
- actual character (position in line) where the end effector works (starts from 0)
- number of lines on the page
- number of chars in the line
- saves current EE position (in stepper motor moves from start of the page) to the EEPROM
- loads saved EE position from the EEPROM (loaded values are divided by the size of the char)
- moves EE to the surface
- lifts EE from the surface
- moves EE for one stepper motor move upwards (along the Y axis)
- moves EE for one stepper motor move upwards to the right
- moves EE for one stepper motor move to the right (along the X axis)
- moves EE for one stepper motor move downwards to the right
- moves EE for one stepper motor move downwards (along the Y axis)
- moves EE for one stepper motor move downwards to the left
- moves EE for one stepper motor move to the left (along the X axis)
- moves EE for one stepper motor move upwards to the left
- writes letter A
- writes letter B
- writes letter C
- writes letter D
- writes letter E
- writes letter F
- writes letter G
- writes letter H
- writes letter I
- writes letter J
- writes letter K
- writes letter L
- writes letter M
- writes letter N
- writes letter O
- writes letter P
- writes letter Q
- writes letter R
- writes letter S
- writes letter T
- writes letter U
- writes letter V
- writes letter W
- writes letter X
- writes letter Y
- writes letter Z
- writes space sign
- writes dot sign
- writes dash sign
- writes slash sign
- writes plus sign
- initializes attributes sets maximal number of lines and chars (depends on char size)
- arguments:
- StepperMotor* motorX - see private attributes
- StepperMotor* motorY - see private attributes
- Servo* servo - see private attributes
- uint16_t charSize - see private attributes
- bool loadPositionOnStart - indicates, if the position of the EE should be loaded from EEPROM
- changes the size of the char
- arguments:
- uint16_t newSize - new value of the
charSize
- uint16_t newSize - new value of the
- moves EE to the start of the page (line 0, char 0)
- moves EE to the start of the next line
- draws test picture
- Writes given string. If the number of characters exceeds the line length, EE is moved to the next line. If the entire page is used, the remaining characters are discarded.
- arguments:
- String* text - string to be written
The library was tested with Arduino Nano, two 28BYJ-48 stepper motors and SG90 servo.
- EEPROM
- Servo
- Stepper Motor
Contributions are welcome!
The library is licensed under the MIT license.