Pages: [1]   Go Down
Author Topic: Buttons '+' '-'  (Read 437 times)
0 Members and 1 Guest are viewing this topic.
Mumbai India
Offline Offline
Newbie
*
Karma: 1
Posts: 32
Analog guy in Digital world!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi All
This is my first post. I have ordered Arduino mega! (I'll receive it by next weekend). I want help in my writing a simple code for CNC machine I have written majority of code I'm confused only with two steps.

1) I want to input number in my code so I'm having two buttons marked as '+' and '-' initially variable(assuming it as i) is zero for every press of '+' i should increment and on pressing '-' it should decrease but value of i should not exceed 999. when i press button labeled as "Enter" Arduino should accept my value and execute the code. (I have connected LCD to display value) (Is there any way to do away with enter button?)

2) I want to run two stepper motor together and then some point in program one after another.
following will run motors one after another. How to implement code to start them simultaneously?
{
  motorA.step(50, Forward);
    motorB.step(100, Forward);
  }

Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 76
Posts: 7305
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You can use my phi_prompt user interface library. There is a function to input integer. It has low and high limits and step size so you can say low=0, high=999, step=1. Take a look:

This example asks for a number between 0 and 20 with step size 2.



Logged


Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34726
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
How to implement code to start them simultaneously?

Do not use that stepping motor library but write your own code to drive the motors. What sort of driver do you have. Are you generating the switching patterns or are you using a step and direction type.
Logged

Mumbai India
Offline Offline
Newbie
*
Karma: 1
Posts: 32
Analog guy in Digital world!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry for late reply! I'll post my code in couple of days.
@Grumpy_Mike Im using L298 for motor and im using step() function.
@liudr thanks for helping!
Logged

Pages: [1]   Go Up
Jump to: