Hey guys,
I am trying to complete a fairly simple project as a gift for someone and all that I need to be able to do is get a servo to spin when someone waves something in front of an IR sensor.
So I have a full rotation servo and I want it to continue to rotate for a second or two whenever the IR sensor is tripped.
Well I had a few sketches that I was using and they were uploading just fine. Then when I changed the way my object was going to be connected to my servo I decided to change the rotation from partial to full.
So I quickly made the fairly simple change of removing the for loops to cause the servo to turn back and forth and just told it to spin.
I verified the code and it fully compiled. However when I went to upload it, the upload never appears to be finishing. I verified that the usb port selected is the correct port and that the board I was using was also correctly selected. I am using an Arduino Uno on my Mac using OS X version 10.11.4
I have never had this problem before. I then reset my Mac, twice, as well as unplugged and re-plugged in the usb cord. I also pressed the manual reset switch on the Arduino board itself multiple times. I have been tying to let it upload now for about 10 minutes and it still isn't doing anything useful.
Also anytime that I trip the IR sensor the old code runs which indicates to me that it is still on there.
The upload bar is full as well. I am at a loss as to what I can do. In about 2 weeks I am going to a workshop called RockOn! in Virginia to build a payload that will go on a sounding rocket and the payload uses an Arduino so I really need to fix this as soon as possible.
I don't know if I am using the latest Arduino IDE but I think that I am and I will check to see if there are any updates that I can install.
Please help me. For reference purposes I have included the code that I was trying to run.
// Type code here for setting variables and including libraries and such.
/********************************
- Servo Setup Code
********************************/
#include <Servo.h> //enters the servo library
Servo myservo; //Creates a variable for a servo to be controlled
int pos = 0; // this is a variable to store the position of the servo
/**********************************
- IR Setup Code
**********************************/
int IRsensorPin = A2;
int IRsensorValue = 0;
int movePuppet = 400;
// Create a reset pin to reset the program
int resetPin = 12;
void setup() {
digitalWrite(resetPin, HIGH);
delay(200);
pinMode(resetPin, OUTPUT);
Serial.begin(9600);
myservo.attach(9); // this places the control pin for the servo to pin 9
}
void loop() {
IRsensorPin = analogRead(A2);
Serial.print("I see something ");
Serial.print(IRsensorPin);
Serial.println(" undescribed units away!!!");
delay(50);
//myservo.write(20);
if (IRsensorPin > movePuppet){
spin();
}
}
/************
- Functions
***********/
void spin(){
myservo.write(20);
delay(1500);
digitalWrite(resetPin, LOW);
}
Thank you for any and all help that you can provide.