Professional Documents
Culture Documents
Solar
Solar
#include <Stepper.h>
void setup() {
// Nothing to do (Stepper Library sets pins as outputs)
}
void loop() {
// Rotate CW slowly at 5 RPM
myStepper.setSpeed(5);
myStepper.step(stepsPerRevolution);
delay(1000);
// using unipolar stepper motors 28BYJ-48 with ULN2003 driver breakout board
#include <Stepper.h> // include stepper library
const int stepsPerRevolution = 4076; // the number of steps per revolution for your motor
void setup()
{
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
Serial.begin(9600); // initialize the serial port:
myStepperH.setSpeed(15);
myStepperV.setSpeed(15);
}
void loop()
{
//int count = millis(); //start millisecond count
int tr = analogRead(ldrtopright);
int tl = analogRead(ldrtopleft);
int bl = analogRead(ldrbottomleft);
int br = analogRead(ldrbottomright);
count++;
int dvert = avt - avd; // check the difference of top and bottom LDRs
int dhoriz = avl - avr;// check the difference of left and right LDRs
if (-1*tolerance > dvert || dvert > tolerance) // check if the difference is in the tolerance else change
vertical angle
{
if (avt > avd) //if average resistance on top is greater than on bottom
{
myStepperV.step(stepsPerRevolution);
}
else //avg resistance on bottom is greater than on top
{
myStepperV.step(-stepsPerRevolution);
}
}
else if (-1*tolerance < dvert || dvert < tolerance) //if difference is smaller than tolerance, stop
vertical stepper
{
myStepperV.setSpeed(0);
}
if (-1*tolerance > dhoriz || dhoriz > tolerance) // check if the difference is in the tolerance else
change horizontal angle
{
if (avl > avr)
{
myStepperH.step(-stepsPerRevolution);
}
else
{
myStepperH.step(stepsPerRevolution);
}
}
else if (-1*tolerance < dhoriz || dhoriz < tolerance) //if difference in horizontal
{
myStepperH.setSpeed(0);
}
delay(dtime);
}
First, reformat your code using Ctrl-T in the IDE...it will be easier to read. Second,
replace these statements:
int dvert = avt - avd; // check the difference of top and bottom LDRs
int dhoriz = avl - avr;// check the difference of left and right LDRs
loop() {
// read LDRs
if (leftLDR > rightLDR) {
// move one step left // move towards brighter LDR
}
else if (rightLDR > leftLDR) {
// move one step right
}
}
...R
if a0 and a3 is 1
motor 2 is move left until a2 a3 is 1
then
if a2 a3 is 1
move motor 1 down until a0 a1 a2 a3 is 1
Hey econjack i tried ctrl-t but says no changes necessary for auto format. And i dont
know what am I expected for these values My friends send to these codes