hi guys,
i have a question stay on my level a beginner to arduino. ive raised this before in a other way (project)
ill place my sketch i wanna know why i cant place my 328p in a standby mode in driving a stepper application.
(now in my sketch)
i switch on my power supply for the atmega 328p, current draws 100ma, stays there lovely.
As soon as the chip gets awakened by sensor and the motor starts its job, it draws +- 700ma.
i understand that.
If there is nothing to activate the sensor ie (no motor running) the currnt goes to +- 450ma. This is the state i would like to change after a set time.(the time before i awake the chip as explained before.
i want to basically put my chip in this state.
Pls im using a L293N board, i know its a shit board too late now, i got it.
other problem im having if someone can add on to my sketch my inching of the motor pin 5 i cant seem to get my head around this.
thanks all
[code]
//*
// Control of a 4 wire stepper motor with optical-sensor (TCST2103) high and low
// readings with led confirming sensor status, reading 28mm x 32mm label on a roll
// sensor reading 28mm edge of label. { Motor inch function included (Under Construction.) }
//*
#include <Stepper.h>
//#include <AccelStepper.h>
//#include <MultiStepper.h>
const int buttonPin = 5; // pushbutton on pin 3(motor inch)
const int led = 13; // led indicator on pin 4
const int sensor = 2; // sensor on pin 19
const int stepsPerRevolution = 200; // 1.8 degree step motor
int state = LOW; // default, no motion detected
int val = 0; // variable to store the sensor status (value)
// initialize the stepper library on pins 9 through 12:
Stepper myStepper(stepsPerRevolution, 9, 10, 11, 12);
int stepCount = 0; // number of steps the motor has taken
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
pinMode(led, OUTPUT); // initialize LED as an output
pinMode(sensor, INPUT); // initialize sensor as an input
pinMode(buttonPin, INPUT); // initialize pushbutton pin as an input:
}
void loop() {
val = digitalRead(sensor); // read sensor value
if (val == LOW) { // check if the sensor is HIGH
digitalWrite(led, LOW); // turn led off
buttonState = digitalRead(buttonPin); // read the state of the pushbutton value:
// check if the pushbutton is pressed.
if (buttonState == HIGH); // the buttonState is HIGH:
// if (val == HIGH)
// myStepper.step(10);
} else {
//if (buttonState == LOW);
digitalWrite(led, HIGH); // turn led on
int sensorReading = analogRead(A0); // pot to adjust motor speed
// map it to a range from 10 to 255:
int motorSpeed = map(sensorReading, 0, 1023, 10, 255);
if (motorSpeed > 0)
myStepper.setSpeed(motorSpeed); // set the motor speed:
// step 1/200 of a revolution:
myStepper.step(stepsPerRevolution / 200); // step 1/200 of a revolution:
val = digitalRead(sensor); // read sensor value
//if (val == LOW)
//myStepper.step(10);
}
}
[/code]
Stepper Mptor FL39ST34-0404A.pdf (106 KB)
l298n_dual_motor_controller_module.pdf (1020 KB)
