Show Posts
Pages: 1 2 [3] 4 5 6
31  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 28, 2012, 01:15:49 pm
This is what I meant:
Code:
PanServoPos = PanServoMovement +  PanServoPos
PanServo.write(PanServoPos);

When the button is pressed, you change PanServoPos, then tell the servo to move to that position.

Okay, thank you for clearing that up for me.
This is what I have than:

Code:
#include <Servo.h>
#include <IRremote.h>
#include <IRremoteInt.h>


Servo PanServo;
int PanServoPos= (90);
int PanServoMovement = 15;  //how many degrees per move

int irReceiver = 2;
int IROutput = 10;

IRrecv irrecv(irReceiver);
decode_results results;

void setup() {
  pinMode (IROutput, OUTPUT);
  PanServo.attach(10);
  PanServo.write(90);
 
  irrecv.enableIRIn();
}
   
void loop() {
 

  if (irrecv.decode(&results))  {
    if (results.value == 0x20DFC03F){
  PanServoPos = PanServoMovement + PanServoPos;
  PanServo.write(PanServoMovement);
    }
     if (results.value == 0x20DF40BF) {
      PanServoPos = PanServoMovement - PanServoPos;
      PanServo.write(PanServoMovement);
   
    }     
  }
  irrecv.resume();
}
   

I also noticed that you changed PanServo.write(PanServoMovement);  to   PanServo.write(PanServoPos);
So, I have tried that as well and I still have no movement on the command of the button.
32  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 28, 2012, 12:53:05 pm
 
You've still got this going on:
Code:
  PanServo.write(PanServoMovement);
  PanServoPos = PanServoMovement + PanServoPos;

Which means, when you press the button, the servo will not move until you press it again. Unless that's what you're looking for, those lines should be in reverse order.

Okay, I had itas PanServoPos = PanServoPos + PanServoMovement, I thought you were saying to reverse the order of that, that's why I changed it to  PanServoPos = PanServoMovement+ PanServoPos;

Are you saying to reverse the order as in:

PanServo.write(PanServoMovement);
PanServoPos + PanServoMovement = PanServoPos
                                Or
PanServoPos = PanServoMovement +  PanServoPos
PanServo.write(OanServoMovement);

Sorry, I'm not to clear on what I'm supposed to be reversing, but honestly thank you. for your help and patients with me.
33  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 28, 2012, 12:28:33 pm
Okay, I think I have changed everything other than adding a print in there as of yet, I'm not too familiar with PrintIn, but I will give it a shot when I get home from work, so I will be back on here in about 8 or 9 hours, however I'm on this forum at work from my phone just minus my Arduino and computer. By the way, when I changed the position of the servo in the setup to 0, the servo did move.

Code:
#include <Servo.h>
#include <IRremote.h>
#include <IRremoteInt.h>


Servo PanServo;
int PanServoPos= (90);
int PanServoMovement = 15;  //how many degrees per move

int irReceiver = 2;
int IROutput = 10;

IRrecv irrecv(irReceiver);
decode_results results;

void setup() {
  pinMode (IROutput, OUTPUT);
  PanServo.attach(10);
  PanServo.write(0);
 
  irrecv.enableIRIn();
}
   
void loop() {
 

  if (irrecv.decode(&results))  {
    if (results.value == 0x20DFC03F){
  PanServo.write(PanServoMovement);
  PanServoPos = PanServoMovement + PanServoPos;
    }
     if (results.value == 0x20DF40BF) {
      PanServo.write(PanServoMovement);
      PanServoPos = PanServoMovement - PanServoPos;
    }     
  }
  irrecv.resume();
}
   
34  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 28, 2012, 11:58:14 am
There has to be something I'm missing on this.... It's still not working. The servo is not moving. I have tested the IR with the serial port print and I'm getting signal, for some reason it's not getting to the servo. Any ideas? 
35  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 28, 2012, 11:49:41 am
The Servo library knows that the pin you've attached the servo to needs to be an output, so there's no need for you to set it as one.

Okay, so off with it!!!! Also, found an issues and corrected that as well. Here is the sketch update:

Code:
#include <Servo.h>
#include <IRremote.h>
#include <IRremoteInt.h>


Servo PanServo;
int PanServoPos= 90;
int PanServoMovement = 15;  //how many degrees per move

int irReceiver = 2;
int IROutput = 10;

IRrecv irrecv(irReceiver);
decode_results results;

void setup() {
  pinMode (IROutput, OUTPUT);
  PanServo.attach(10);
  PanServo.write(90);
 
  irrecv.enableIRIn();
}
   
void loop() {
 

  if (irrecv.decode(&results))  {
    if (results.value == 0x20DFC03F){
  PanServo.write(PanServoMovement);
  PanServoPos = PanServoPos + PanServoMovement;
    }
  }
  if (irrecv.decode(&results)) {
    if (results.value == 0x20DF40BF) {
      PanServo.write(PanServoMovement);
      PanServoPos = PanServoPos - PanServoMovement;
    }     
  }
  irrecv.resume();
}
   
 
 

 /* PanServoMovement = PanServoMovement * (-1);*/
36  Using Arduino / Project Guidance / Re: android tank on: June 28, 2012, 11:45:38 am
Good luck! Just try to tackle one part at a time. Like the pan on the turret and then once you have the hardware and code together (and it's working properly). Save that and start a new sketch for the next part. Then combine them. Just take you're time with and know that it's not going to be done overnight, enjoy the project sounds fun!
37  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 28, 2012, 11:42:23 am
Well, I still don't have it right but now I at least feel that I'm on the way.... Let me know if you think I'm headed in the right direction with this, if you don't mind.

Code:
#include <Servo.h>
#include <IRremote.h>
#include <IRremoteInt.h>


Servo PanServo;
int PanServoPos= 90;
int PanServoMovement = 15;  //how many degrees per move

int irReceiver = 2;
int IROutput = 10;

IRrecv irrecv(irReceiver);
decode_results results;

void setup() {
  pinMode (IROutput, OUTPUT);
  PanServo.attach(10);
  PanServo.write(90);
 
  pinMode(10,OUTPUT);
  irrecv.enableIRIn();
}
   
void loop() {
 

  if (irrecv.decode(&results))  {
    if (results.value == 0x20DFC03F){
  PanServo.write(PanServoMovement);
  PanServoPos = PanServoPos + PanServoMovement;
    }
  }
  if (irrecv.decide(&results)) {
    if (results.value == 0x20DF40BF) {
      PanServo.write(PanServoMovement);
      PanServoPos = PanServoPos - PanServoMovement;
    }     
  }
  irrecv.resume();
}

38  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 28, 2012, 01:11:30 am
Thanks Jimbo! I'll use this for an outline and see what I can come up with. You have a lot of items in there that I'm not to sure about, so getting a firm grasp on how/why this sketch works will be a project in it's own but I'm sure I will learn plenty from it! I will post my findings in the morning some time! Again, THANK YOU VERY MUCH!!!!
39  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 27, 2012, 11:36:43 pm
Here is the code....

You are calling irrecv.decode() twice, once for each possible command. You should only need to call it once, and then test the result against your known values to see what command you received.

The point of int OUTPUT_PIN = 10; is that you only need to define the pin number in one place. It kind of defeats the point if you then put PanServo.attach(10);.

I don't know what you intend to do with last, but you aren't doing it. (I would guess this is to control the speed of movement if the button is pressed continuously?)

You don't seem to declare degrees and you don't seem to use val. Instead of digitalWrite(OUTPUT_PIN, val = 1023); you should be using PanServo.write(degrees);.



I threw this up as I was in the middle of working on it. I didn't define degrees as of yet because I didn't really know how to go about doing it with the values I needed. As I said earlier in this thread, I'm so confused on how to make this work. I think at this point I'm being my own worst enemy and making this be much harder than it needs to be. I'm just going to start over with a fresh sketch instead of taking parts from my main project sketch then just merge them together. Thanks for the help, I just need to figure out where to start with this one. I'm noticing that it's nothing like writing a sketch for just a button read, swing servo.

Maybe I should just skip the IR part for now and try to get it to work on just the servo and then put the IR in there. Just take one step at a time. I feel overwhelmed and the confusion is killing me!
40  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 27, 2012, 11:22:38 pm
I have in the past, but not in regards to this question. I will check it out now.

I'm writing this sketch to add to my original project. I have a servo currently on it that runs a simple motion using a single command from an IR signal. Hit the button it goes HIGH hit it again and it goes LOW. I did it off of a relay. It's just trying to get this to move in steps using 2 buttons (one for clockwise and the other for counter-clockwise). Anyways, I will check out the tutorial now and see what I can come up with. I have looked around for a sample sketch, found somethings similar but just doesn't seem to be the easiest way to do it.

Also, today I decided to go buy another Arduino Uno in the event I want to make my life a living hell and make my own remote, instead of using a regular TV remote... What can I say, a pot just feels right when controlling pan and tilt servos, wouldn't you agree?
41  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 27, 2012, 10:28:31 am
Okay, I will give her a shot!

Cool, but have a close look at the tutorial if you didn't already.

Matter of interest, I used ifs to do my IR buttons too, but am (even as we speak) re-writing that into switch case because it's much neater imo.

Are you talking about the tutorial on ifs?
42  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 27, 2012, 09:58:46 am
You should have something like this:

Code:
PanServo.write(degrees);



Okay, I will give her a shot!
43  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 27, 2012, 09:46:59 am
Here is the code....


Code:
#include <IRremote.h>
#include <IRremoteInt.h>
#include <Servo.h>

Servo PanServo;

int RECV_PIN = 2;
int OUTPUT_PIN = 10;
int val;


IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
  PanServo.attach(10);
  pinMode(OUTPUT_PIN, OUTPUT);
 
  irrecv.enableIRIn();
}

int on = 0;
unsigned long last = millis();

void loop() {
  if (irrecv.decode(&results)) {
    if (results.value == 0x20DFC03F) {
      degrees = degrees + 5;               
        digitalWrite(OUTPUT_PIN, val = 0);
      }
      last = millis();
    }   
      if (irrecv.decode(&results)) {
    if (results.value == 0xDF40BF) {
      degrees = degrees -5;
        digitalWrite(OUTPUT_PIN, val = 1023);
      }
      last = millis();
    }   
    irrecv.resume();
  }

  }
}




44  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 27, 2012, 08:50:45 am
I just tried adding degrees into the void loop and it's not doing the trick. What about changing the pulse? I do that by adding milli to the void loop section of the sketch right?
45  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 27, 2012, 01:01:33 am
I had a lot of questions in there due to the pure state of confusion I'm in. Well at least I'm on the right track because, I was leaning more twords if, even though I had it working with a pot and the map function. I'm going cross eyed right now from looking at this screen tonight, so I think I will pick up where I left off in the morning.

One more question though, if I have it going clockwise with the +5 degrees on one button. Than ishould be able to just change a different button to -5 for it to go counter Clockwise correct?
Pages: 1 2 [3] 4 5 6