Show Posts
Pages: [1]
1  Using Arduino / Installation & Troubleshooting / Re: Cannot Upload anymore on: May 31, 2011, 02:46:38 pm
I bought a new board thinking that was the issue (this one is a UNO) but again I have the same problems.  Also Serial Port Comm1 is now the only one that is showing up.  I don't know what else to do.  I even tried changing which USB I plug it into.
2  Using Arduino / Programming Questions / Re: Help programming a servo on: May 09, 2011, 10:49:45 am
Quote
Wild Bill this looks really good my only question is will the servo stay at that position?

Did you not test the code with your servo?

I am waiting for my new Arduino to come in before I can test.
3  Using Arduino / Programming Questions / Re: Help programming a servo on: May 09, 2011, 10:10:50 am
Try this:
Code:
int inPin = 0;    // select the input pin for the Hall Effect Sensor
int ledPin = 13;   // select the pin for the LED
int val = 0;       // variable to store the value coming from the sensor
int mean = 508;
int sensitivity = 20;

void setup()
{
pinMode(ledPin, OUTPUT);  // declare the ledPin as an OUTPUT
}


void loop()
{
static bool DetectingHallEffect=false; // We will likely detect the hall effect sensor several times, make sure we only react when we first detect it.

val = analogRead(inPin);  // Read the Hall Effect Sensor
if((val < (mean + sensitivity)) && (val > (mean - sensitivity))) // Do we see the sensor?
  {
  if(!DetectingHallEffect)     // Make sure we only do this once for each detection of the hall effect sensor
    {
    DetectingHallEffect=true;  // This will be true until we don't see the sensor any more
    if(servo.read()==0)        // Check where the servo is and move it to the other position
      servo.write(170);
    else
      servo.write(0);
    }
  }
else
  DetectingHallEffect=false;   // Don't see the sensor any more, permit action the next time we see it
}    

Note that I've assumed that the analogread is close to the mean value when the sensor is detected, rather than the way you have it in your led example. Note also that I don't have a compiler on this machine to syntax check it. Might get you a bit closer though.

Wild Bill this looks really good my only question is will the servo stay at that position?  I need it to start at zero then when hall effect is true go to 170 and stay there and then hall effect is true again go to 0 and stay there.
4  Using Arduino / Programming Questions / Re: Help programming a servo on: May 09, 2011, 10:09:01 am
Code:
for(pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees
Code:
for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees

{ taps fingers impatiently }

This was the original program.  I changed mine to move at 170 degree increments.

Both of the examples above look good but again since my knowledge of programming is VERY limited I don't know which one would be better to use.  Maybe a third party can help?
5  Using Arduino / Programming Questions / Re: Help programming a servo on: May 09, 2011, 09:31:06 am
So let me go into a little more detail on how I came to the program in my original post.  I combine this program for running a servo:
#include <Servo.h> //include the servo libary

Servo myservo;  // create servo object to control a servo
// a maximum of eight servo objects can be created

int pos = 0;    // variable to store the servo position

void setup()
{
myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop()
{
for(pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees
{                                  // in steps of 1 degree
myservo.write(pos);              // tell servo to go to position in variable ‘pos’
delay(15);                       // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees
{
myservo.write(pos);              // tell servo to go to position in variable ‘pos’
delay(15);                       // waits 15ms for the servo to reach the position
}
}

which turns a servo on a delay.  With this program which used a hall effect sensor to turn on a LED:
int inPin = 0;    // select the input pin for the Hall Effect Sensor
int ledPin = 13;   // select the pin for the LED
int val = 0;       // variable to store the value coming from the sensor
int mean = 508;
int sensitivity = 20;

void setup() {
 pinMode(ledPin, OUTPUT);  // declare the ledPin as an OUTPUT
}

void loop() {
 val = analogRead(inPin);  // read the Hall Effect Sensor
 if (val > (mean + sensitivity) || val < (mean - sensitivity)) {
   digitalWrite(ledPin, HIGH);  // turn the ledPin on
 }
 else {                 
   digitalWrite(ledPin, LOW);   // turn the ledPin off
 }
}

I used both programs separately with no problems but I can't seem to find the right way to combine the two to make the hall effect sensor be the trigger for the servo to move.
6  Using Arduino / Installation & Troubleshooting / Re: Cannot Upload anymore on: May 09, 2011, 08:38:38 am
I cant even burn a bootloader.  I tried doing it with every possible option.
7  Using Arduino / Installation & Troubleshooting / Re: Cannot Upload anymore on: May 09, 2011, 07:38:49 am
So is there anything else I can try?
8  Using Arduino / Programming Questions / Re: Help programming a servo on: May 06, 2011, 02:53:27 pm
According to what Groove said my "for" argument is set up incorrectly.  Would this be correct to do what I need to do?

#include <Servo.h> //include the servo libary

Servo servo;  // create servo object to control a servo
// a maximum of eight servo objects can be created

int pos = 0;    // variable to store the servo position
int inPin = 8;    // select the input pin for the Hall Effect Sensor
int servoPin = 9;  // select the pin for the servo
int val = 0;       // variable to store the value coming from the sensor
int mean = 508;
int sensitivity = 20;

void setup()
{
servo.attach(9);  // attaches the servo on pin 9 to the servo object
{
 pinMode(servoPin, OUTPUT);  // declare the servo as an OUTPUT
}
}

void loop()
{
for(int pos = 0; pos < 170; pos += 170)
val = analogRead(inPin);  // read the Hall Effect Sensor
if (val > (mean + sensitivity) || val < (mean - sensitivity))
{
digitalWrite(servoPin, pos += 170);  // goes from 0 degrees to 170 degrees
servo.write(pos);              // tell servo to go to position in variable ‘pos’
}
for(int pos = 170; pos>=1; pos-=170)
val = analogRead(inPin);  // read the Hall Effect Sensor
 if (val > (mean + sensitivity) || val < (mean - sensitivity))
{
digitalWrite(servoPin, pos -= 170);  // goes from 170 degrees to 0 degrees
servo.write(pos);              // tell servo to go to position in variable ‘pos’
}
}

9  Using Arduino / Programming Questions / Re: Help programming a servo on: May 06, 2011, 02:27:08 pm
I just need to make the code that I have listed above work.  It needs to be triggered by the hall effect sensor to go from 0 to 170 then sit at 170.  Then the next time the hall effect sensor is activated it needs to go from 170 to 0 and sit at zero.  Then it needs to repeat the process until I turn off the power.
10  Using Arduino / Programming Questions / Re: Help programming a servo on: May 06, 2011, 02:11:11 pm
Sorry I didn't mean to sound dismissive to your help Groove.  This is the first and only time I will need to program an Arduino as I need to create this program for a project for work.  If you can see what I am missing in my original code and help me out in order to achieve what I stated I needed this code to do I would be grateful.
11  Using Arduino / Installation & Troubleshooting / Re: Cannot Upload anymore on: May 06, 2011, 02:09:22 pm
I have nothing plugged into it at all and the TX and RX blink for about a second when I first plugged in the USB then they stop.
12  Using Arduino / Programming Questions / Re: Help programming a servo on: May 06, 2011, 01:04:53 pm
I've already looked at that and that really doesn't answer my question.
13  Using Arduino / Installation & Troubleshooting / Re: Cannot Upload anymore on: May 06, 2011, 01:00:24 pm
I've tried this as well and it does not work.
14  Using Arduino / Programming Questions / Help programming a servo on: May 06, 2011, 10:13:22 am
Hi I need a servo to be activated by a hall effect sensor.  I need the servo to start at 0 degrees then once the hall effect sensor is triggered I need the servo to move to 170 degrees and stay there. Once the hall effect sensor is triggered again I need it to move back to 0 degrees.  So far I have come up with the following but need help.

#include <Servo.h> //include the servo library

Servo servo;  // create servo object to control a servo

int pos = 0;    // variable to store the servo position
int inPin = 0;    // select the input pin for the Hall Effect Sensor
int servoPin = 9;  // select the pin for the servo
int val = 0;       // variable to store the value coming from the sensor
int mean = 508;
int sensitivity = 20;

void setup()
{
servo.attach(9);  // attaches the servo on pin 9 to the servo object
{
 pinMode(servoPin, OUTPUT);  // declare the servo as an OUTPUT
}
}

void loop()
{
for(int servoPin; pos = 0;)
val = analogRead(inPin);  // read the Hall Effect Sensor
if (val > (mean + sensitivity) || val < (mean - sensitivity))
{
digitalWrite(servoPin, pos += 170);  // goes from 0 degrees to 170 degrees
servo.write(pos);              // tell servo to go to position in variable ‘pos’
}
for(int servoPin; pos = 170;)
val = analogRead(inPin);  // read the Hall Effect Sensor
 if (val > (mean + sensitivity) || val < (mean - sensitivity))
{
digitalWrite(servoPin, pos -= 170);  // goes from 170 degrees to 0 degrees
servo.write(pos);              // tell servo to go to position in variable ‘pos’
}
}

Thanks in advance.
15  Using Arduino / Installation & Troubleshooting / Cannot Upload anymore on: May 06, 2011, 10:08:49 am
Hi, I used to be able to upload no problem to my Arduino Duemilanove but now I can't upload anything.  I get an error saying:
avrdude: stk500_getsync(): not in sync: resp=0x00
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

I had no problems before and I haven't changed any of the settings or done any updates since.  My original program was for a servo that moved 170 degrees back and forth after a given time.  I needed to update this however to only move when a hall effect sensor was triggered.  After I installed the new program I tried running it and it wasn't working properly so I tried to go back to the original program but it wouldn't let me and gave me the error above.  Again nothing was changed and there was only a 2 day time period between installing the new program and trying to go back to the old.  Now I cannot get any program to upload at all.  I have tried everything recommended in the troubleshooting and nothing is working.

So again, I didn't change my Comm port I didn't change which board was selected, I am running this on Windows XP and I am using an Arduino Duemilanove w/ ATmega 328.

Please help me.
Pages: [1]