florida
Offline
Newbie
Karma: 0
Posts: 42
|
 |
« Reply #15 on: February 02, 2012, 09:38:26 pm » |
yeah i looked at that im not clever enough to swap out 8,9,10,11 pins with steppin and directionpin with out it saying stepper not ....whatever
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 298
Posts: 26024
Solder is electric glue
|
 |
« Reply #16 on: February 02, 2012, 09:41:30 pm » |
So post the code as you have changed it, along with the error message and some one will tell you where you have gone wrong. When posting code, select it and then hit the # icon in the reply box before posting.
|
|
|
|
|
Logged
|
|
|
|
|
florida
Offline
Newbie
Karma: 0
Posts: 42
|
 |
« Reply #17 on: February 02, 2012, 09:42:46 pm » |
ok thanks alot
|
|
|
|
|
Logged
|
|
|
|
|
florida
Offline
Newbie
Karma: 0
Posts: 42
|
 |
« Reply #18 on: February 02, 2012, 09:51:26 pm » |
#include <Stepper.h>
// change this to the number of steps on your motor #define STEPS 200 #define directionPin 22 #define stepPin 24 // create an instance of the stepper class, specifying // the number of steps of the motor and the pins it's // attached to
// the previous reading from the analog input int previous = 0;
void setup() { // set the speed of the motor to 30 RPMs stepper.setSpeed(30); }
void loop() { // get the sensor value int val = analogRead(0);
// move a number of steps equal to the change in the // sensor reading stepper.step(val - previous);
// remember the previous value of the sensor previous = val; } there it is I told you I am simple the error code it gives me is stepper was not declared in this scope motorknob.cpp: in function void loop etc. it gets very angry at me
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 298
Posts: 26024
Solder is electric glue
|
 |
« Reply #19 on: February 02, 2012, 10:02:34 pm » |
You need this line:- Stepper stepper(STEPS, 8, 9, 10, 11); In order to tell the software what pins to use. Change the numbers to match the pins your hardware is using. Without this line the software doesn't know what the word 'stepper' means and so it tells you it doesn't know with the error message "not declared in scope" which means "WTF no on told be about this word stepper, I don't know what to do with it.
|
|
|
|
|
Logged
|
|
|
|
|
florida
Offline
Newbie
Karma: 0
Posts: 42
|
 |
« Reply #20 on: February 02, 2012, 10:14:23 pm » |
ok now we're getting somewhere i have a pololu a4988 with the direction pin and step pin when i assigned those 2 pins numbers and gave it a go the motor wont move. i have everything set up right because it works with the code that goes forward then backward
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 298
Posts: 26024
Solder is electric glue
|
 |
« Reply #21 on: February 02, 2012, 10:30:13 pm » |
No it won't. This is because that code uses the stepping motor library and this is designed to produce the on / off pattern for powering the coils. The code is totally unsuitable for the hardware you have. Try this code, I have just written it for you so I haven't tested it but it compiles:- // change this to the number of steps on your motor #define dirPin 10 #define stepPin 11
// the previous reading from the analog input int previous = 0; int val =0; int dir = 0; // direction of movement int steps = 0; // number of steps to take
void setup() { pinMode(stepPin, OUTPUT); digitalWrite(stepPin, LOW); pinMode(dirPin, OUTPUT); }
void loop() { // get the sensor value val = analogRead(0);
// move a number of steps equal to the change in the // sensor reading steps = (val - previous); if(steps > 0){ dir = 0; } else { dir = 1; steps = -steps; } digitalWrite(dirPin, dir); // set up the direction for(int i = 0; i< steps; i++){ digitalWrite(stepPin, HIGH); // pulse the step pin digitalWrite(stepPin, LOW); } // remember the previous value of the sensor previous = val; } Be sure to change the first two lines to match what you have.
|
|
|
|
|
Logged
|
|
|
|
|
Berks, UK
Offline
Full Member
Karma: 0
Posts: 145
|
 |
« Reply #22 on: February 03, 2012, 03:58:14 am » |
You need this line:- Stepper stepper(STEPS, 8, 9, 10, 11); In order to tell the software what pins to use. Change the numbers to match the pins your hardware is using. Without this line the software doesn't know what the word 'stepper' means and so it tells you it doesn't know with the error message "not declared in scope" which means "WTF no on told be about this word stepper, I don't know what to do with it. LOL, spoken like a true Brit.
|
|
|
|
|
Logged
|
|
|
|
|
florida
Offline
Newbie
Karma: 0
Posts: 42
|
 |
« Reply #23 on: February 03, 2012, 10:12:30 pm » |
first thank you grumpy mike. good karma for you  when i try the code and move the pot the motor does nothing. sorry it took so long to get back i have an 11 month old and work. my projects always get put on the back burner
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 298
Posts: 26024
Solder is electric glue
|
 |
« Reply #24 on: February 04, 2012, 12:13:21 pm » |
Try adding a delay(100); after the digitalWrite(stepPin, LOW);
|
|
|
|
|
Logged
|
|
|
|
|
Pittsburgh, PA, USA
Offline
Faraday Member
Karma: 33
Posts: 3015
I only know some basic electricity....
|
 |
« Reply #25 on: February 05, 2012, 02:12:07 am » |
Hehe, hehe! He said
...
delay
hehe, hehe, hehehehehe.
j/k!
|
|
|
|
|
Logged
|
Examples can be found at Learning in the Main Site and at the Playground
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 298
Posts: 26024
Solder is electric glue
|
 |
« Reply #26 on: February 05, 2012, 04:08:45 am » |
Well in a post where I said WTF I thought WTF I will say delay.
|
|
|
|
|
Logged
|
|
|
|
|
Pittsburgh, PA, USA
Offline
Faraday Member
Karma: 33
Posts: 3015
I only know some basic electricity....
|
 |
« Reply #27 on: February 05, 2012, 07:48:23 am » |
Just the thought of going through how not to use delay has me agreeing, show him something quicker than it would take to explain why not.
|
|
|
|
|
Logged
|
Examples can be found at Learning in the Main Site and at the Playground
|
|
|
|
florida
Offline
Newbie
Karma: 0
Posts: 42
|
 |
« Reply #28 on: February 06, 2012, 10:34:54 pm » |
do i need to turn on the a0 pin for the pot to work thanks again for being patient and helpful
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 298
Posts: 26024
Solder is electric glue
|
 |
« Reply #29 on: February 07, 2012, 01:05:26 pm » |
do i need to turn on the a0 pin for the pot to work No.
|
|
|
|
|
Logged
|
|
|
|
|
|