My project needs for a stepper motor to spin to a position determined by a photo-resistor.
Example:
The stepper motor is at X position when there is no light in the room, and then to spin a set amount of turns Y when there is a lot of light in the room. But if there is medium light it should spin midways between X and Y positions.
I'm using arduino UNO
The arduino motor shield
This stepper
a Photo-resistor
and a 9 volt battery.
Now... I'm a total idiot. :~
Can I actually do this?
I've wired the stepper correctly and it does spin.
And if I can, can somebody help me with the coding? This is my first time using arduino and quite frankly the coding
is driving me insane.
I would really appreciate some help, or for someone to point me into the right direction.
Read the light sensor input.
Decide which of the three bands the light level is in.
Decide which position the motor should be in as a result.
Compare that to where the motor currently is.
Move the motor towards its desired position.
have it find point 0, either by having the dial hit a button or something so you know where it should start.
find out how many ticks it needs to go
Then:
Read the light sensor input.
Decide which of the three bands the light level is in.
Decide which position the motor should be in as a result.
Compare that to where the motor currently is.
Move the motor towards its desired position.
Hi, are you trying to make a big indicator, like a meter, the angle of the indicator responding to light level?
I suggest you use a SERVO, it will make your application soooo much simpler and easier to program.
A normal servo only turns through 180Degrees, is that enough?
TomGeorge:
Hi, are you trying to make a big indicator, like a meter, the angle of the indicator responding to light level?
I suggest you use a SERVO, it will make your application soooo much simpler and easier to program.
A normal servo only turns through 180Degrees, is that enough?
Tom.......
Hey Tom.
No. I'm connecting the Stepper to a log screw, then fitting a nut to it. The nut is connected to a bearing in a fixed pole
so the turning of the stepper will make the nut go up or down without rotating. So I can only use a stepper because I need multiple rotations.
Now. does anyone knows a good step by step tutorial and examples I can follow to code this.
I just cant get the syntax right, feels like I'm reading hieroglyphs.
FrankPB:
Now. does anyone knows a good step by step tutorial and examples I can follow to code this.
Divide and conquer. Break the problem down into simple parts that you can tackle separately. For example:
Read the light sensor input.
Decide which of the three bands the light level is in.
Decide which position the motor should be in as a result.
Compare that to where the motor currently is.
Move the motor towards its desired position.
Do you know how to connect your Arduino to a PC?
Can you run the example sketches on it and see the output?
Do you know how to wire up the light sensor and get a reading from it?
FrankPB:
Now. does anyone knows a good step by step tutorial and examples I can follow to code this.
Divide and conquer. Break the problem down into simple parts that you can tackle separately. For example:
Read the light sensor input.
Decide which of the three bands the light level is in.
Decide which position the motor should be in as a result.
Compare that to where the motor currently is.
Move the motor towards its desired position.
Do you know how to connect your Arduino to a PC?
Can you run the example sketches on it and see the output?
Do you know how to wire up the light sensor and get a reading from it?
Yes, I can connect the Arduino to the PC. I run the example sketches without a problem.
I've paired up the light sensor with an LED with an example sketch the turned the LED BRIGHTER when there was more light, but I couldn't make it turn on and off depending on the light, or reverse the setting so it was brighter when there was low light. I'm stupid.
I've connected the stepper motor to the motor shield and could make it spin indefinitely in one direction, or another, but I could not edit the sketch to change the direction with say a button.
Thanks for reading, everyone.
This forum is pretty amazing, I'm surprised so many people took interest in my question.
Thank you all, you're all really nice guys.
TomGeorge:
Hi, so you are making a linear actuator?
Tom.....
Hey Tom.
Yes, a pretty crude one
it "works". The wooden piece is attached to a plastic hub. This all goes inside a plastic tube. When there is low light the stepper will activate and the bulb will rise an a led will turn on. its a lamp.
If you guys want I can post pictures tomorrow of the whole project.
Anyways, back to the question.
Does anyone knows a good tutorial on how to code this, or where should I look.
If it's possible I would love for someone to guide me or personally help me, I could pay a little bit too.
You have to build up the code a step at a time.
The way it works is you post the code that does a bit of the project, you say what it does and what you want it to do. We the. Pich in and tell you what is wrong. You make corrections and post your code again.
In a few iterations you have written your project with our help.
I think that you should
read a few examples in your arduino IDE
read some of the reference section here
write a program to increment a counter every 10ms while one pushbutton switch is pressed,
decrement that counter every 10ms while the other pushbutton switch is pressed
Serial.print(n); the value of your counter int n every 10ms
In getting that to work, you'll read the relevant pages of reference.
Next change from pushbutton operated to something using your sensor.
When you have that working, you'll have found out enough to finish your project.
If you don't have money to buy pushbutton switches, you can test with only a few bits of single strand wire on pinboard and some 10kOhm resistors to make sure that you are not being unkind to your digital input pins.
Heya guys. I think I solved some issues and also simpliefied the whole thing a lot. I have a new problem but after that I think I'm done! I made a new thread for the new issues here: