Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Handmade Character Soft Toys
anil1961
Updated:
Yesterday at 2:11 PM
Bodim.lk out now !
Manoj Suranga Bandara
Updated:
Sunday at 3:05 AM
Power Lifting Lever Belt
SkullVamp
Updated:
Jun 13, 2026
Ad icon
port.lk Domain for sale
Lankan-Tech
Updated:
Jun 13, 2026
Colombo
Kaduwela - Two Storey House for Sale
dilrasan
Updated:
Jun 11, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Help
Arduino help
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="apikaluda?" data-source="post: 24117117" data-attributes="member: 470863"><p><span style="font-size: 15px"><span style="color: Blue">Addaa...sorry eka mis wuna...meka balanna</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"></span></span></p><p></p><p></p><p><span style="font-size: 12px">const int ForwardLimitSwitchPin = 2;</span></p><p><span style="font-size: 12px">const int ReverseLimitSwitchPin = 3;</span></p><p><span style="font-size: 12px">const int StepperStepPin = 4;</span></p><p><span style="font-size: 12px">const int StepperDirectionPin = 5;</span></p><p><span style="font-size: 12px">const int LimitSwitchActivated = LOW; // Limit switch grounds pin</span></p><p><span style="font-size: 12px">const int StepperMaxRPM = 100;</span></p><p><span style="font-size: 12px">const int buttonPin = 6; // the number of the pushbutton pin (choose the correct pin here)</span></p><p><span style="font-size: 12px">bool ispushbuttonpressed = false; // Boolean to store push button logic </span></p><p><span style="font-size: 12px">int buttonState = 0; //**correction</span></p><p><span style="font-size: 12px">Stepper stepper(200, StepperStepPin, StepperDirectionPin);</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">void setup() {</span></p><p><span style="font-size: 12px"> pinMode(ForwardLimitSwitchPin, INPUT_PULLUP);</span></p><p><span style="font-size: 12px"> pinMode(ReverseLimitSwitchPin, INPUT_PULLUP);</span></p><p><span style="font-size: 12px"> stepper.setSpeed(StepperMaxRPM);</span></p><p><span style="font-size: 12px"> pinMode(buttonPin, INPUT); //declare push button signal as an input</span></p><p><span style="font-size: 12px">}</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">void loop() {</span></p><p><span style="font-size: 12px"> buttonState = digitalRead(buttonPin); // read push button on-off</span></p><p><span style="font-size: 12px"> if (buttonState == HIGH) {</span></p><p><span style="font-size: 12px"> ispushbuttonpressed = true;</span></p><p><span style="font-size: 12px"> }</span></p><p><span style="font-size: 12px"> // Step forward until the limit switch is activated (forward rotating when hits S1)</span></p><p><span style="font-size: 12px"> if ((ispushbuttonpressed == true) && (digitalRead(ForwardLimitSwitchPin) != LimitSwitchActivated)) { //**corrections added</span></p><p><span style="font-size: 12px"> while (digitalRead(ForwardLimitSwitchPin) != LimitSwitchActivated) {</span></p><p><span style="font-size: 12px"> stepper.step(1);</span></p><p><span style="font-size: 12px"> }</span></p><p><span style="font-size: 12px"> ispushbuttonpressed == false; //re-set to avoid motor turning backward once reached S2</span></p><p><span style="font-size: 12px"> }</span></p><p><span style="font-size: 12px"> </span></p><p><span style="font-size: 12px"> // Step reverse until the limit switch is activated (forward rotating when hits S2)</span></p><p><span style="font-size: 12px"> else if ((ispushbuttonpressed == true) && (digitalRead(ReverseLimitSwitchPin) != LimitSwitchActivated)) //**corrections added</span></p><p><span style="font-size: 12px"> while (digitalRead(ReverseLimitSwitchPin) != LimitSwitchActivated) {</span></p><p><span style="font-size: 12px"> stepper.step(-1);</span></p><p><span style="font-size: 12px"> }</span></p><p><span style="font-size: 12px"> spushbuttonpressed == false; //re-set to avoid motor turning backward once reached S1</span></p><p><span style="font-size: 12px"> }</span></p><p><span style="font-size: 12px">} </span></p></blockquote><p></p>
[QUOTE="apikaluda?, post: 24117117, member: 470863"] [SIZE=4][COLOR=Blue]Addaa...sorry eka mis wuna...meka balanna [/COLOR][/SIZE] [SIZE=3]const int ForwardLimitSwitchPin = 2;[/SIZE] [SIZE=3]const int ReverseLimitSwitchPin = 3; const int StepperStepPin = 4; const int StepperDirectionPin = 5; const int LimitSwitchActivated = LOW; // Limit switch grounds pin const int StepperMaxRPM = 100; const int buttonPin = 6; // the number of the pushbutton pin (choose the correct pin here) bool ispushbuttonpressed = false; // Boolean to store push button logic int buttonState = 0; //**correction Stepper stepper(200, StepperStepPin, StepperDirectionPin); void setup() { pinMode(ForwardLimitSwitchPin, INPUT_PULLUP); pinMode(ReverseLimitSwitchPin, INPUT_PULLUP); stepper.setSpeed(StepperMaxRPM); pinMode(buttonPin, INPUT); //declare push button signal as an input } void loop() { buttonState = digitalRead(buttonPin); // read push button on-off if (buttonState == HIGH) { ispushbuttonpressed = true; } // Step forward until the limit switch is activated (forward rotating when hits S1) if ((ispushbuttonpressed == true) && (digitalRead(ForwardLimitSwitchPin) != LimitSwitchActivated)) { //**corrections added while (digitalRead(ForwardLimitSwitchPin) != LimitSwitchActivated) { stepper.step(1); } ispushbuttonpressed == false; //re-set to avoid motor turning backward once reached S2 } // Step reverse until the limit switch is activated (forward rotating when hits S2) else if ((ispushbuttonpressed == true) && (digitalRead(ReverseLimitSwitchPin) != LimitSwitchActivated)) //**corrections added while (digitalRead(ReverseLimitSwitchPin) != LimitSwitchActivated) { stepper.step(-1); } spushbuttonpressed == false; //re-set to avoid motor turning backward once reached S1 } } [/SIZE] [/QUOTE]
Insert quotes…
Verification
Dahaya deken beduwama keeyada?
Post reply
Top
Bottom