Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Help with java coding (http://www.chiefdelphi.com/forums/showthread.php?t=103987)

Team1605 28-02-2012 22:27

Help with java coding
 
How can i program a motor to spin 180 degrees forward when i press a button and then spin 180 degrees backwards when i press a different button?

ProjectZero 28-02-2012 22:40

Re: Help with java coding
 
Well, if you want to spin a certain number of degrees you'll need a sensor on your motor shaft.

You can attach a potentiometer to your motor shaft. A potentiometer is an analog sensor that measures how far you have rotated based on the change in its resistance. Sure "program potentiometer" on Chief Delphi and I'm sure there are threads devoted to it. If I recall, you can hook the potentiometer up to an analog channel and read the data it gives you (a certain change in voltage will correspond to a certain change in degrees). You would read your potentiometer, then tell the motor to run. You would continue to read your potentiometer and tell the motor to stop running when it had turned a certain amount.

If it's an arm of some sorts, you can use a limit switch. A limit switch is a very simple sensor that gives off a signal when a small lever is touched. One came in the kit of parts. You could tell your motor to stop running when the arm or whatever is attached to it rotated 180 degrees.

Of course, the simplest and crudest way would be to set your motor to a certain speed, measure how long it takes to turn 180 degrees, then tell your motor to turn for that amount of time and stop.

Hope this helps.

Team1605 01-03-2012 13:11

Re: Help with java coding
 
it kinda helped but m confused how to do the coding

for it in operated controls. i am programing in java BTW


All times are GMT -5. The time now is 09:48.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi