I have 2 alternatives to power the turning plant- a DC motor or a stepper motor. I have run through a test of a DC motor (attached to a fan) and 2 tests for a stepper motor. I was inclined to try to use the stepper motor, but neither of the stepper motor tests have worked. It appears that the power supply module I’m using (which is supposed to be compatible with the driver and stepper motor I’m using) is failing to provide power to the driver and the stepper motor. Not clear yet where the failure is happening, although the dim LED light on the power supply module suggests that the 9V battery power supply I am using is not adequate. I will need to test another power supply to see if I can get the stepper motor to work. Since the DC motor with fan seemed to have varying success depending on the speed, I tried two stepper motor tests just in case a difference in the speed would make the stepper motor move.
UPDATE 2/28: With a new power supply (wall plug), the stepper motor code is working. Next step is to make a sketch that combines the stepper motor and the light sensor TEMT6000.
Stepper Motor Test 1 Sketch:
#include <Stepper.h> int stepsPerRevolution=2048; //see motor spec sheet int motSpeed=10; int dt=500; Stepper stepmot(stepsPerRevolution, 8,10,9,11);//see motor and driver specs void setup() { // put your setup code here, to run once: Serial.begin(9600); stepmot.setSpeed(motSpeed); } void loop() { // put your main code here, to run repeatedly: stepmot.step(stepsPerRevolution); delay(dt); stepmot.step(-stepsPerRevolution); delay(dt); }
Stepper Motor Test 2 Sketch:
#include <Stepper.h> const float STEPS_PER_REV=32; //see motor spec sheet const float GEAR_RED = 64; const float STEPS_PER_OUT_REV = STEPS_PER_REV * GEAR_RED; int stepsReq; int motSpeed=10; int dt=500; Stepper steppermotor(STEPS_PER_REV, 8,10,9,11);//see motor and driver specs void setup() { // put your setup code here, to run once: Serial.begin(9600); } void loop() { // put your main code here, to run repeatedly: steppermotor.setSpeed(1); stepsReq=4; steppermotor.step(stepsReq); delay(2000); stepsReq = STEPS_PER_OUT_REV / 2; steppermotor.setSpeed(100); steppermotor.step(stepsReq); delay(1000); }