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
Puffin Rock Characters Plush Toy Set
anil1961
Updated:
Yesterday at 3:51 PM
Toyota Vitz scp10 For Sale
Lakmal Bandara
Updated:
Wednesday at 10:50 AM
Kandy
Welcome all my all new pet shop Bark.lk
dilumrane
Updated:
Monday at 12:26 PM
Windows RDP Only Rs.500 a month
Blogerwiki
Updated:
Nov 1, 2026
Ad icon
V2ray VPN for Tunneling
hu KANNA
Updated:
Oct 22, 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: 24117090" data-attributes="member: 470863"><p><span style="font-size: 15px"><span style="color: Blue">Macho podi logics awulak thibba...eka heduwa (** walin mark karala tiyenne)</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"></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"> 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><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p></blockquote><p></p>
[QUOTE="apikaluda?, post: 24117090, member: 470863"] [SIZE=4][COLOR=Blue]Macho podi logics awulak thibba...eka heduwa (** walin mark karala tiyenne)[/COLOR][/SIZE] [SIZE=3]const int ForwardLimitSwitchPin = 2; 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 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) 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] [SIZE=3] [/SIZE] [SIZE=3][/SIZE] [/QUOTE]
Insert quotes…
Verification
Hathara warak wissa keeyada? (Hathara wadi karanna 20)
Post reply
Top
Bottom