Show Posts
Pages: 1 2 [3] 4 5 ... 7
31  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 28, 2012, 11:44:31 pm
Oh, okay! Thanks!
32  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 28, 2012, 11:40:54 pm
I had did that earlier with putting a different value in and it works with no problem. If you don't mind I'm going to put together the PrintIn, if you could please look it over for me. I have not done anything so far with that function. I'm going to look for a tutorial real quick and work off of that. 
33  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 28, 2012, 11:28:03 pm
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){
  PanServoPos = PanServoMovement + PanServoPos;
  PanServo.write(PanServoPos);
    }
     if (results.value == 0x20DF40BF) {
      PanServoPos = PanServoMovement - PanServoPos;
      PanServo.write(PanServoPos);
   
    }     
  }
  irrecv.resume();
}

This is what I have, this thing is still not working though.

AWOL, At this point I will take the static... As long as there is some kind of movement. I think I might have to look into putting a PrintIn on this sketch as WildBill has mentioned so I can see what's going on.
34  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 28, 2012, 11:17:42 pm
What you want to do is this (not proper code):

new = old + change
move to new


What you're doing is:

new = old + change
move to change


So it stays at the degree position of change, not moving to new.


Thanks Jimbo!!!! I see what you're saying now that you put it like that.
I don't know if you can tell due to the amount of changes I did to it, but I have stated this sketch off of the one you gave me, it really did help me piece together this sketch a lot! Thanks again! I will post the sketch with the changes on it soon.
35  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 28, 2012, 01:38:43 pm
Apart from the servo write in setup, you're always writing 15 to the servo.

I thought that's how I would be able to move the servo 15 degreesor millis every time I hit the button. I'm just tring to use 2 buttons on a remote to move the servo in either direction. I clearly do not have the knowladge to do this and there is nothing similar online that I have found to use for a clear referance.
36  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 28, 2012, 01:19:41 pm
AWOL, are you trying to confuse me even more than I am (if that's even possible at this point). You had to throw in a little shorthand!!! lol!!! Thanks buddy! hahaha!
37  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.
38  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.
39  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();
}
   
40  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? 
41  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);*/
42  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!
43  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();
}

44  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!!!!
45  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!
Pages: 1 2 [3] 4 5 ... 7