Need help with a project, my code is correct but the programer is not responding

//www.elegoo.com
//2016.12.12

#include "Stepper.h"
#define STEPS 32 // Number of steps for one revolution of Internal shaft
// 2048 steps for one revolution of External shaft

volatile boolean TurnDetected; // need volatile for Interrupts
volatile boolean rotationdirection; // CW or CCW rotation

const int PinCLK=2; // Generating interrupts using CLK signal
const int PinDT=3; // Reading DT signal
const int PinSW=4; // Reading Push Button switch

int RotaryPosition=0; // To store Stepper Motor Position

int PrevPosition; // Previous Rotary position Value to check accuracy
int StepsToTake; // How much to move Stepper

// Setup of proper sequencing for Motor Driver Pins
// In1, In2, In3, In4 in the sequence 1-3-2-4
Stepper small_stepper(STEPS, 8, 10, 9, 11);

// Interrupt routine runs if CLK goes from HIGH to LOW
void isr () {
delay(4); // delay for Debouncing
if (digitalRead(PinCLK))
rotationdirection= digitalRead(PinDT);
else
rotationdirection= !digitalRead(PinDT);
TurnDetected = true;
}

void setup () {

pinMode(PinCLK,INPUT);
pinMode(PinDT,INPUT);
pinMode(PinSW,INPUT);
digitalWrite(PinSW, HIGH); // Pull-Up resistor for switch
attachInterrupt (0,isr,FALLING); // interrupt 0 always connected to pin 2 on Arduino UNO
}

void loop () {
small_stepper.setSpeed(700); //Max seems to be 700
if (!(digitalRead(PinSW))) { // check if button is pressed
if (RotaryPosition == 0) { // check if button was already pressed
} else {
small_stepper.step(-(RotaryPosition*50));
RotaryPosition=0; // Reset position to ZERO
}
}

// Runs if rotation was detected
if (TurnDetected) {
PrevPosition = RotaryPosition; // Save previous position in variable
if (rotationdirection) {
RotaryPosition=RotaryPosition-1;} // decrase Position by 1
else {
RotaryPosition=RotaryPosition+1;} // increase Position by 1

TurnDetected = false; // do NOT repeat IF loop until new rotation detected

// Which direction to move Stepper motor
if ((PrevPosition + 1) == RotaryPosition) { // Move motor CW
StepsToTake=50;
small_stepper.step(StepsToTake);
}

if ((RotaryPosition + 1) == PrevPosition) { // Move motor CCW
StepsToTake=-50;
small_stepper.step(StepsToTake);
}
}
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
}

./opt/arduino-builder/arduino-builder -compile -core-api-version 10611 -hardware opt/arduino-builder/hardware -hardware ./opt/cores -tools opt/arduino-builder/tools -tools ./opt/tools -built-in-libraries opt/libraries/latest -logger humantags -fqbn arduino:avr:mega:cpu=atmega1280 -build-cache /tmp -build-path /tmp/579526865/build -verbose -libraries /tmp/579526865/custom -libraries /tmp/579526865/pinned /tmp/579526865/sketch_aug29a

Sketch uses 3996 bytes (3%) of program storage space. Maximum is 126976 bytes.

Global variables use 59 bytes (0%) of dynamic memory, leaving 8133 bytes for local variables. Maximum is 8192 bytes.

Programming with: Serial

Flashing with command:C:/Users/9MAKM/.arduino-create/arduino/avrdude/6.3.0-arduino9/bin/avrdude.exe -CC:/Users/9MAKM/.arduino-create/arduino/avrdude/6.3.0-arduino9/etc/avrdude.conf -q -q -patmega1280 -carduino -PCOM5 -b57600 -D -Uflash:w:C:/Users/9MAKM/AppData/Local/Temp/arduino-create-agent630800148/sketch_aug29a.hex:i

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x25

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x25

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x25

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x25

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x25

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x25

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x25

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x25

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x25

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x25

Probably something wrong with the config of your PC, how its connected to the Arduino, or the Arduino itself.

But you provided no details on your setup.

its connected to the Arduino, and i Upload the Code, but is says that the programer is not operating.

What info do i have to check about my PC Configuration??

Always read the instructions BEFORE doing anything! You have posted inthe wrong form and you posted incorrectly.

Maybe if you read the instructions you will find out what you have done wrong

Mark

The message "avrdude: stk500_recv(): programmer is not responding" usually means that the Arduino IDE cannot make connection with the Arduino board via the COM port.

Are you sure you have selected the correct COM port?

Have you tried disconnecting and re-connecting the Arduino USB cable and then checking which COM port it is connected to?

Have you tried closing and re-opening the Arduino IDE?

Have you tried re-starting your PC?

...R
PS ... To make it easy for people to help you please use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum Do the same for the error messages.

(deleted)

If the TX light is on you probably have a sketch installed that is flooding the USB input buffer. That could be why you are getting "resp=0x25" for every command.

Hold down the Reset buttom.
Unplug the USB cable. (This flushes the USB input buffer.)
Plug the USB cable back in.
Start the sketch upload.
When the RX light blinks, release the Reset button.

manuelosuna:
its connected to the Arduino, and I Upload the Code, but is says that the programmer is not operating.

What info do i have to check about my PC Configuration??

There is an obvious problem with your question here.

You have posted a quite complex program here and say "my code is correct". I presume you mean that it compiles without error, which is an achievement in itself, but absolutely no indication that it is logically correct and appropriate to do what you want.

And why do I mention that as the problem? Well, whether or not the code is correct, it suggests that you have "got the cart before the horse" here. :astonished:

You need to start with a simple program - such as the "blink" program, which does nothing more than flash the status LED on pin 13. And you need to download this to the Arduino with no other modules connected. Perhaps you did do this but have failed to mention something that seems obvious to you, but it critical to your problem since if you could do that, and also load progressively more sophisticated code but not the present code, it would simply mean you had made a wrong connection at a certain point.

If you have not started by practising "blink" programs ("sketches"), and verified they worked by altering the timing parameters to give the expected results, then you need immediately to go back and do that, following the instructions for troubleshooting that you will find in the forums sensibly titled "Introductory Tutorials" or "Installation & Troubleshooting", which is what holmes4 (and the others) have pointed out.

But also speaking of "going back," please go and read the instructions, then go back and modify your post using the "More --> Modify" option you will find to the bottom right of the post, to mark up the code (but it always needs to be the complete code) as such so we can examine it conveniently and accurately. Please do not post a ".ino" file as an attachment - that would mean that you are expecting people to actually load it to their IDE to look at it and that is extra unnecessary labour. In fact, attachments do not always show properly on different operating systems.

If you do not mark it up as code, whatever code you do post could well be garbled and is certainly anything but easy to read. Yours seems to have survived so far but I didn't look too closely.

Note: Also mark up any data - as a separate section - in the same way. This includes error output that you get from the IDE.

And - before you post any code, use "Auto Format" in the Tools menu of the IDE to properly present the code.

Try and avoid unnecessary white space (blank lines). You should only use these to separate functional blocks of code.