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:
Today 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:
Sunday at 12:41 PM
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: 24117051" data-attributes="member: 470863"><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) {</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) {</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><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><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: 15px"><span style="color: Blue">Machan meka weda karanne mehemai....</span></span></p><p><span style="font-size: 15px"><span style="color: Blue">1) push button eka ekapaarak press kalaama logic eken buttonState == HIGH -> ispushbuttonpressed = true</span></span></p><p><span style="font-size: 15px"><span style="color: Blue">2) ethakota motor eka touch wela thiyena switch eka (S1/S2) anuwa forward hari backward hari rotate wenawa</span></span></p><p><span style="font-size: 15px"><span style="color: Blue">3) rotate wela anith switch eka touch wunama nawathinawa. Newathunata passe ispushbuttonpressed = false wenawa</span></span></p><p><span style="font-size: 15px"><span style="color: Blue">4) Ethakota aaye anith pettata rotate wenne ne</span></span></p><p><span style="font-size: 15px"><span style="color: Blue">5) ehema anith pettata rotate karanna nam aaye push buttona eka press karanna one. Ethakota aaye (1) indan steps tika follow wenawa.</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"></span></span></p><p><span style="font-size: 15px"><span style="color: Blue"></span></span></p><p><span style="font-size: 15px"><span style="color: Blue">meka balanna machan....weede karala awulak thiyenawanam kiyanna....logic wala awul thenak thibboth ahanna...mama kiyannam. </span></span></p><p><span style="font-size: 15px"><span style="color: Blue"></span></span></p><p><span style="font-size: 15px"><span style="color: Blue"></span></span></p><p><span style="font-size: 15px"><span style="color: Blue"></span></span></p><p><span style="font-size: 15px"><span style="color: Blue">** thawa ekak machan motor eka start ekedi kisima switch ekak touch wela nettan (S1/S2) me logic eken weda karanne ne mata hithenne....ekath balanna...ema nethinam thawa meka improve karala wede goda daagamu...</span></span></p><p><span style="font-size: 15px"><span style="color: Blue">balala kiyanna.</span></span></p></blockquote><p></p>
[QUOTE="apikaluda?, post: 24117051, member: 470863"] [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) { 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) { 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] [SIZE=3] [/SIZE] [SIZE=3] [/SIZE] [SIZE=4][COLOR=Blue]Machan meka weda karanne mehemai....[/COLOR][/SIZE] [SIZE=4][COLOR=Blue]1) push button eka ekapaarak press kalaama logic eken buttonState == HIGH -> ispushbuttonpressed = true[/COLOR][/SIZE] [SIZE=4][COLOR=Blue]2) ethakota motor eka touch wela thiyena switch eka (S1/S2) anuwa forward hari backward hari rotate wenawa[/COLOR][/SIZE] [SIZE=4][COLOR=Blue]3) rotate wela anith switch eka touch wunama nawathinawa. Newathunata passe ispushbuttonpressed = false wenawa[/COLOR][/SIZE] [SIZE=4][COLOR=Blue]4) Ethakota aaye anith pettata rotate wenne ne[/COLOR][/SIZE] [SIZE=4][COLOR=Blue]5) ehema anith pettata rotate karanna nam aaye push buttona eka press karanna one. Ethakota aaye (1) indan steps tika follow wenawa.[/COLOR][/SIZE] [SIZE=4][COLOR=Blue] [/COLOR][/SIZE] [SIZE=4][COLOR=Blue]meka balanna machan....weede karala awulak thiyenawanam kiyanna....logic wala awul thenak thibboth ahanna...mama kiyannam. [/COLOR][/SIZE] [SIZE=4][COLOR=Blue] [/COLOR][/SIZE] [SIZE=4][COLOR=Blue]** thawa ekak machan motor eka start ekedi kisima switch ekak touch wela nettan (S1/S2) me logic eken weda karanne ne mata hithenne....ekath balanna...ema nethinam thawa meka improve karala wede goda daagamu...[/COLOR][/SIZE] [SIZE=4][COLOR=Blue]balala kiyanna.[/COLOR][/SIZE] [/QUOTE]
Insert quotes…
Verification
Nawa warak dahaya keeyada? (Namaya wadi kireema dahaya)
Post reply
Top
Bottom