Show Posts
Pages: 1 2 [3] 4 5 ... 7
31  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 29, 2012, 12:34:37 am
It's not working at all....

Code:
/*Help from JimboZA, AWOL, WildBill & PeterH from Arduino Fourm. Sample sketch provided by JimboZA  */
#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);
  Serial.begin(9600);
  Serial.print("STARTED");

  irrecv.enableIRIn();
}
   
void loop() {
 

  if (irrecv.decode(&results))  {
    if (results.value == 0x20DFC03F){
      Serial.print("Are you here yet");
     PanServoPos = PanServoMovement + PanServoPos;
     PanServo.write(PanServoPos);
  Serial.print(PanServoMovement);
  Serial.print("20DFC03F WORKING (LEFT)");
  Serial.println(PanServoPos);
    }
     if (results.value == 0x20DF40BF) {
      PanServoPos = PanServoMovement - PanServoPos;
      PanServo.write(PanServoPos);
  Serial.print(PanServoMovement);
  Serial.print("20DF40BF WORKING (RIGHT)");
  Serial.println(PanServoPos);
   
    }     
  }
  irrecv.resume();
}
32  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 29, 2012, 12:13:46 am
Well, I have a different sketch that decodes the IR signals, I think I got that from the "Arduino Cookbook". I use this remote on a different sketch that I have and it works fine with that set up. I just use it to turn on and off relays, much simpler things than this clearly is. Oh and yes, I know how to get into the Serial Monitor, I have the baud set at 9600 as well.

okay, with this sketch the serial monitor is coming up with "STARTED" at least but not responding to the buttons still. So, I would say I have an issue with the IR part of the sketch somewhere.

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);
  Serial.begin(9600);
  Serial.print("STARTED");

  irrecv.enableIRIn();
}
   
void loop() {
 

  if (irrecv.decode(&results))  {
    if (results.value == 0x20DFC03F){
     PanServoPos = PanServoMovement + PanServoPos;
     PanServo.write(PanServoPos);
  Serial.print(PanServoMovement);
  Serial.print("20DFC03F WORKING (LEFT)");
  Serial.println(PanServoPos);
    }
     if (results.value == 0x20DF40BF) {
      PanServoPos = PanServoMovement - PanServoPos;
      PanServo.write(PanServoPos);
  Serial.print(PanServoMovement);
  Serial.print("20DF40BF WORKING (RIGHT)");
  Serial.println(PanServoPos);
   
    }     
  }
  irrecv.resume();
}
33  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 28, 2012, 11:52:43 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);
  Serial.begin(9600);
 
  irrecv.enableIRIn();
}
   
void loop() {
 

  if (irrecv.decode(&results))  {
    if (results.value == 0x20DFC03F){
     PanServoPos = PanServoMovement + PanServoPos;
     PanServo.write(PanServoPos);
  Serial.print(PanServoMovement);
  Serial.print("20DFC03F WORKING (LEFT)");
  Serial.println(PanServoPos);
    }
     if (results.value == 0x20DF40BF) {
      PanServoPos = PanServoMovement - PanServoPos;
      PanServo.write(PanServoPos);
  Serial.print(PanServoMovement);
  Serial.print("20DF40BF WORKING (RIGHT)");
  Serial.println(PanServoPos);
   
    }     
  }
  irrecv.resume();
}

I'm not getting anything on the Serial Monitor. Not sure if I set up the Serial.print wrong, or if this is why it's not working.
34  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 28, 2012, 11:44:31 pm
Oh, okay! Thanks!
35  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. 
36  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.
37  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.
38  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.
39  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!
40  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.
41  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.
42  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();
}
   
43  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? 
44  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);*/
45  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!
Pages: 1 2 [3] 4 5 ... 7