…

Which of the examples have you looked at yet? Find all the ones

that are relevant to potentiometers and stepper motors and study them...

The playground http://playground.arduino.cc/ is a good place to look.

I want to do two clocks .

Your post is all but impossible to understand. Use Google Translate to translate your language (whatever that is) to ENGLISH.

Your English is so bad I can't understand what you want.

This took a while, but I get it. I have a knack for translating human-speak into tech-speak, and vice-versa. Even from a non-native-English speaker. You gave enough -descriptive- clues to understand it, which helped a lot, but yes it was moderately difficult.

I want to do two clocks

I don't quite understand what you mean by clock, but I'll take it to mean 'something that rotates around like a dial.'

It is controlled by Analog Rotary Potentiometer. (Analog Rotary Potentiometer can be rotated up to 300-degree.)

It can spin as 360 degrees and stop at 0,15,30,45,60,90,180,270,360 degrees.when i rotation a potentiometer to 30 degrees. two stepper motor is spin to 45 degrees.

OK. You wan the pot input to be reflected in a -certain- way by the steppers.

The pot can rotate only 300-deg, and you need to 'translate' that into a certain stepper position.

The pot can be set to an -arbitrary- position, but you want the stepper to go to a certain limited -set- of positions. Actually I can see a use for this. Instead of clicking -9- buttons marked 0, 15, 30, 45, just -one- pot is turned to 'about' where you want the stepper to turn to. This is pretty cool.

and when i rotation a potentiometer to 0 degrees. two stepper motor is spin to original (0 degree.)

when i rotation a potentiometer to 300 degrees. two stepper motor is spin to 360 degrees

Sure, that's full rotation of the pot, which must perform full rotation on the stepper. Similarly, half rotation 150-deg must perform 180-deg rotation of the stepper. Got it.

The trick is to use a **multiplicative factor** to 'convert' the 300-deg rotation to the 360-deg rotation. The factor is found using cross multiplication. This is a basic aspect of 'fractions arithmetic. I was SOOOOOO glad I learned this so young, because I use it literally on a daily basis to 'guess' at the proportions of things. Here's your cross multiply:

```
360 x
--- = ---
300 100
```

Solve for x.

```
x = (360 x 100) / 300 = 1.2
```

That 1.2 is your multiplicative factor that you will use to convert a pot position of 0-300-deg to a stepper position of 0-360-deg.

Examples...

```
30-deg pot rotation x 1.2 = 36-deg stepper rotation
150-deg pot rotation x 1.2 = 180-deg stepper rotation.
```

Cool, eh?

BUT!!! You said '...stop at 0,15,30,45,60,90,180,270,360 degrees.'

I interpret that to mean you -don't- want the stepper to -exactly- reflect the pot position. You want a SMALL RANGE of pot positions to select a SPECIFIC POSITION on the stepper out of the LIST of positions.

For example you said these: '...potentiometer to 30 degrees. two stepper motor is spin to 45 degrees' and

'...and when i rotation a potentiometer to 250 degrees. two stepper motor is spin to 270 degrees.'

Now using the 1.2 factor, 30-deg is represented -exactly- as 36-deg, and 250-deg is exactly represented as 300.

The 36 and 300 are -not- in the list of 0, 15, 30 etc required positions.

So, you need to calculate what -range- of pot positions is *BEST* represented by the 0, 15, 30 list.

That's not hard to do: read the position, see what it's greater/less then, or however, and that says what position to set the stepper to.

But... there's a problem... Not a big problem but a decision you need to make about how to read the pot when it's 'near' the endpoints of 0 and 300-deg.

At the endpoints it's easy the pot at 0-deg, the stepper is at 0-deg, and at 300-deg the stepper is at 360-deg.

The problem/question is, at exactly what point in the pot rotation does the stepper move to the next stepper position of 15-deg?

And, at what higher end of pot rotation does the stepper move to 360-deg.

The reason this is a minor problem is that for all other 15-30, 30-45 position it's easy to figure out where 'halfway between' is, to tell whether the stepper should go from 15 to 30, or from 30 to 45.

But below 15 you need to decide exactly where the position -starts- to move, to make the stepper move to 15-deg. As I see it from a user interface point of view it might be uncomfortable to be turning the pot, and 'nothing happens.' And nothing happens, and nothing happens, and eventually something happens.

Same as the top end of the dial. The last stepper position before 360 (maximum rotation) is 270. That factor-divides -exactly- to a pot position of 225-deg. So 'somewhere' between 225-deg and 300-deg pot position the stepper must move to the full rotation of 360-deg, but 'where' that should happen is the question.

The SIMPLEST answer is that from pot position 0-deg to 'half' of 15-deg stepper position, it should do nothing. That's from 0 to about 6-deg pot position. That'll be a 'dead zone' where nothing happens. You'll have to try it out to see if that's annoying or not, and you might want to lower it to 5-deg or 4-deg.

and similarly at the high end of the rotation, a pot position of 194 to 296 (depending on what feels 'right' for you) should move the stepper to the last 360-deg position.

Your choice.

I don't know how to write code.

Or know too much about how to calculate proportions either. LOL! Kidding. That really is elementary school arithmetic. Heck, maybe you're only in a middle school type level now and they never taught you that. Whatever - you know it now.

Help me please.

I'm not going to write the code for you. There are plenty of examples that tell you how to read a pot and rotate a stepper. I described how to 'convert' the 300-deg pot rotation to 360-deg stepper rotation, which was the real knowledge you did not have. The exact code to do that is up to you. (And it's spectacularly simple anyway.)

When you try it, and something doesn't work right, then post your code here, describe what you're doing to the pot and the effects you see on the stepper, and then we'll try more to help, but you need to demonstrate effort first.