Electronic Miter Box! Control A Stepper Motor With A Keypad - Brainy-Bits
Electronic Miter Box! Control A Stepper Motor With A Keypad - Brainy-Bits
Metal 3D Printing
Electronic Miter box! Control a Stepper Motor with a Keypad Home / Tutorials / Electronic Miter box! Control a Stepper Motor with a Keypad
TUTORIAL OVERVIEW
In this tutorial we will see how to move a stepper motor to an exact position that we enter on a keypad.
Plus we will display some information like current position and the entered distance on the keypad on a Nokia 5110
LCD module.
CONNECTIONS
Descarga
Chrome en el
trabajo
La solución de
navegador empresarial
para tu organización.
Implementa Chrome
ahora mismo.
There’s quite a bit of connections needed for this project, which is why we are using a MEGA2560 R3.
Keypad connections:
Pin 22, 24, 26, and 28 of the MEGA are connected to the Rows Pins of the Keypad.
Pin 31, 33 and 35 are connected to the Columns Pins of the Keypad.
Pin 3, 4, 5, 6, 7 of the MEGA are connected to Pins CLK, DIN (or mosi), DC, CE (or sce) and RST.
The GND and VCC Pins of the Nokia are connected to GND and 3.3V pins of the MEGA.
Pin A0 and A1 of the MEGA are connected to Pins STEP and DIR of the Easy Driver.
Another GND pin of the MEGA is connected to the GND pin of the Easy Driver.
THE CODE
We are using 3 Libraries in this tutorial, “AccelStepper” to control the stepper motor, “Keypad” to map the keys of the
keypad and “U8glib” to draw the information on the nokia 5110 LCD.
You can nd download links for all these libraries at the bottom of this tutorial page.
As always you can have a look at the tutorial video for more information.
Descarga el
navegador Chrome
Instalación o ine, políticas
basadas en dispositivos y
más. Implementa el MSI de
Google Chrome
*/
// Keypad Setup
const byte ROWS = 4; // Four Rows
const byte COLS = 4; // Four Columns
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {22, 24, 26, 28}; // Arduino pins connected to the row pins of the ke
byte colPins[COLS] = {31, 33, 35, 37}; // Arduino pins connected to the column pins of the
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS ); // Keypad Libra
// AccelStepper Setup
AccelStepper stepper(1, A0, A1); // 1 = Easy Driver interface
// Arduino A0 connected to STEP pin of Easy Driver
// Arduino A1 connected to DIR pin of Easy Driver
void setup(void) {
void loop(){
case '1':
checknumber(1);
break;
case '2':
checknumber(2);
break;
case '3':
checknumber(3);
break;
case '4':
checknumber(4);
break;
case '5':
checknumber(5);
break;
case '6':
checknumber(6);
break;
case '7':
checknumber(7);
break;
case '8':
checknumber(8);
break;
case '9':
checknumber(9);
break;
case '0':
checknumber(0);
break;
case '*':
deletenumber();
break;
case '#':
calculatedistance();
break;
}
}
} else {
if (secondnumber == 99) { // Check if it's the second number entered
secondnumber=x;
String displayvalue = (String(firstnumber) + String(secondnumber));
drawnokiascreen(displayvalue);
}
}
}
thirdnumber=99;
}
else {
if (secondnumber !=99) {
String displayvalue = String(firstnumber);
drawnokiascreen(displayvalue);
secondnumber=99;
}
else {
if (firstnumber !=99) {
String displayvalue = "";
drawnokiascreen(displayvalue);
firstnumber=99;
}
}
}
}
if (thirdnumber != 99) {
keyfullnumber=(firstnumber*100)+(secondnumber*10)+thirdnumber;
movestepper(keyfullnumber);
}
void drawnokiascreen(String y) {
u8g.firstPage();
do {
u8g.drawHLine(0, 15, 84);
u8g.drawVLine(50, 16, 38);
u8g.drawHLine(0, 35, 84);
u8g.setFont(u8g_font_profont11);
u8g.drawStr(0, 10, "ENTER DISTANCE");
u8g.setPrintPos(0,29);
u8g.print(y); // Put entered number on Nokia lcd
u8g.drawStr(62, 29, "MM");
u8g.drawStr(4, 46, "cur-pos");
u8g.setPrintPos(57,47);
u8g.print(currentposition); // Display current position of stepper
}
while( u8g.nextPage() );
TUTORIAL VIDEO
Arduino DIY electronic miter box? Stepper control with keypad and LCD - Tutorial
DOWNLOAD
Copy the above Sketch code in your Arduino IDE software to program your Arduino.
Used Libraries:
Once downloaded, just extract the content of the zip les inside your “arduino\libraries\” folder.
Related Posts
18 Comments
Hello,
I have just your found your great website and videos. I would like to replicate your electronic miter saw stop, however, I am new to Arduino programming and
design. Since you no longer offer the hardware kits can you provide a parts list for this project?
Thanks,
Mike
Hi,
my post seems to have disappeared so I’ll try again. Your code works well, but I am making a variable length antenna using a stepper motor, I could do with some
help to get the motor to extend a 10mtr length of copper strip. I have tried to modify your code without success.
Thanks for the projects.
hi, can you launched sensor uxgate c100 magnetometr with ardunio and conected to pc wiht bleuthos? thack you very much
Hello,
I am attempting to make an antenna similar to a steppir, I watched your tutorial and thought I could modify your code to suit, I failed. I need to have a linear
movement of about 10mtrs. The last time I attempted programming was in 1982 with a ZX81 computer, didn’t do too well then either. I would appreciate some
help or a point in the right direction.
Thanks for the original code, I keep trying.
Thanks for the project. Interesting. If you can change it to enter 4 numbers. Thank you. I can not modify it. I admit I’m a beginner.
hi Brainy Bits
i’m trying to make a positioning system with a lead screw for witch i used mainly your code. it works quite well, but an input over 84 makes the motor run in the
wrong direction. do you have any idea what the reason for this may be and what i can do to make it work right?
many thanks
1-48 Lagen ab 1AT z.B. Prototyp 2L 35€ in 4AT, 4L 59€ in 5AT, kein Privatverkauf
Another question. Is it possible to mount a L239d motor shield on a MEGA 2560 and still use the 4×4 keypad and LCD?
What driver do you recommend for a NEMA 23 stepper motor?.7.4v, 1Amp per phase
I built this using a longs NEMA34 stepper and a longs 2H microstep driver. the only thing I changed in the code is INT calculatemove = (z*3007) ; . this
makes the gear train move in meters rather than MM. the problem is everything works ne until I enter any number over 10. then it will rotate the
opposite direction or not move the proper distance. any help would be great.
Hi I want the motor move in degrees position & in continuous motion with rev & fwd option. I also want Home switch from where I have started rotation.
Hi. I have tried this project. I use a 4×4 keypad. there are 4 buttons that have not been used, namely the A, B, C & D button. it’s a pity if this button is not used. if I
want to make the A button function as the home position button. can you help me add the home button function in this program.
Thank You…
Rgd
Fandi
Hi Brainy Bits,
I have watched all of your videos on youtube and am inspired by your work. I want to make a miter box much like the tigerstop and the same as neo7cnc on
youtube. However I want to use mm and be able to insert a decimal place (eg 1.7mm), and I also want to use a 16×2 LCD I2C screen with just 4 wires. How do I
change the code so that it is able to do this?
Hi, I’m trying to do program in inches with decimal inputs from keypad, but unsuccessfully, maybe you have something similar and can you show me the code.
Thank you in advance.
RElative simple -most steppers have 200 stps per turn – I have spindle which needs 78 steps per mm (1mm /turn Spindle with production tolerances) so
you simply have to do the maths…
Very nice project!!!But what happen with decimal numbers movement? If for example i want to move the stepper motor 1.5 mm?
Thanks in advance.
Hi, this project code can you convert for 4×3 keypad and for simple 16×2 LCD? i use I2C for LCD so just use 4 wire.like this can be use whit UNO. thanx
Leave A Comment
Comment...
POST COMMENT