Show Posts
Pages: 1 [2] 3 4 ... 6
16  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 29, 2012, 09:57:05 am
NICE! You know they don't make anything like they used to! lol! Good luck with that!!! I'm still plugging away over here, I think I might have figured this out... I'll post on it once I finish up what I'm doing to see if it will work. I'm crossing my fingers, praying to god, Buddha and Tom Cruse that this will work!

So, I got the Serial.print to read the "Are you here yet" and the directional IR signals!!!!! The servo however is not moving yet, but I'm getting there!

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


Servo triggerservo;
Servo PanServo;

                
 int pos = 0;    
 int button = 7;   //<---- Nothing in pin (DO NOT USE PIN 7)
  
 const int irReceiverPin = 2;
 int Saftey =5;
 int RelayTrig = 4;
 int RelayLaser = 3;

 int PanServoVal;
 int PanServoMovement = (15);
 int PanServoPos = (0);
 
 IRrecv irrecv(irReceiverPin);
 decode_results results;

 
 void setup()
{
  triggerservo.attach(9);  
  PanServo.attach(10);
  
 pinMode(pos, OUTPUT);
 pinMode(button, INPUT);
 digitalWrite (button, LOW);
 
pinMode (Saftey, OUTPUT);
pinMode(RelayTrig, OUTPUT);
pinMode(RelayLaser, OUTPUT);
irrecv.enableIRIn();

Serial.begin(9600);
Serial.print("!!STARTED!!");

PanServo.write(PanServoVal);
}
 
 int on = 0;
 unsigned long last = millis();
 
 
 void loop()
{
  
    if (digitalRead(button) == LOW)

  for(pos = 0; pos < 90; pos += 90)   //
  {                                  
    triggerservo.write(pos);              
                
  }
  if (digitalRead(button) == HIGH)
  
  for(pos=90; pos>=0; pos-=90)    
  {                                
     triggerservo.write(pos);              
                                
                          
  }
{
  if (irrecv.decode(&results)) {    
    if (results.value == 0x20DFC23D) { //Menu Button: pulls/releases trigger only if saftey is off (LED on when released).
      if (millis() - last > 250) {
        on = !on;
        digitalWrite(RelayTrig, on ? HIGH : LOW);
                Serial.print(" TRIGGER ACTION ");
        
      }
      last = millis();
    }    
  }
  
  if (irrecv.decode(&results)) {    
    if (results.value == 0x20DF10EF) { //Power Button: Turns on/off the saftey on the trigger
      if (millis() - last > 250) {
        on = !on;
        digitalWrite(Saftey, on ? HIGH : LOW);
        Serial.print(" SAFTEY ACTION ");
      }
      last = millis();
    }    
  
  }
{
  if (irrecv.decode(&results)) {
    if (results.value == 0x20DF906F) { //Mute Button: Turns on/off the targeting laser.
    if (millis() - last > 250) {
        on = !on;
        digitalWrite(RelayLaser, on ? HIGH : LOW);
        Serial.print(" LASER ACTION ");
     }
      last = millis();
    }    
     if (irrecv.decode(&results))  {
  Serial.print("Are you here yet");
  
    if (results.value == 0x20DFC03F){
     PanServoVal = PanServoMovement + PanServoPos;
     PanServo.write(PanServoVal);
  Serial.print("20DFC03F WORKING (LEFT)");
 
    }
     if (results.value == 0x20DF40BF) {
      PanServoVal = PanServoMovement - PanServoPos;
      PanServo.write(PanServoVal);
  Serial.print("20DF40BF WORKING (RIGHT)");

  
    }    
    irrecv.resume();
}
}
  }
}
}

In the sketch above the "Are you here yet" is in there but I have taken that out because it is working and that line is coming up every time I hit a button. I found it to be annoying so I took it out...
17  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 29, 2012, 09:25:40 am
I think I'm making some headway.... Still working on it though. I'll update later.
18  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 29, 2012, 01:18:09 am
Yea, something is really screwed up with this. My other sketch isn't working at all once I add this to it I will continue my struggle and see what I can come up with on it. I really believe the problem lies within the if statements and the way it was set up. I have my other servo sketch running off of millis and I don't think you can add degrees in there once you use millis, it's either one or the other.

Well, now that I know the trick with the Serial.Print this should make life a little easier and not so much of a guess. Again, thank you everyone for your help thus far, have a goodnight or good morning, or good day depending on where you are! Jimbo, thanks a lot for the help brother, I would still be here pulling my hair out without man! Enjoy work, I'm going to get some sleep. I'll check back in the AM!
19  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 29, 2012, 12:57:46 am
My bright idea of putting it on the other sketch didn't work either. I will have to look this over in some detail in the morning and see if I can find where I went wrong. I don't think the if statements are correct. This is the entire sketch with all the other working things on there along with what I have added in this sketch. It's a giant mess, but it does work... Well other than this.

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


Servo triggerservo;
Servo PanServo;
             
 int pos = 0;     
 int button = 7;   //<---- Nothing in pin (DO NOT USE PIN 7)
 
 const int laserButton = 8; 
 const int irReceiverPin = 2;
 int Saftey =5;
 int RelayTrig = 4;
 int RelayLaser = 3;
 
 int PanServoPos = (90);
 int PanServoMovement = (15);
 
 IRrecv irrecv(irReceiverPin);
 decode_results results;

 
 void setup()
{
  triggerservo.attach(9); 
 pinMode(pos, OUTPUT);
 pinMode(button, INPUT);
 digitalWrite (button, LOW);
 
  PanServo.attach(10);
 PanServo.write(0);
 Serial.begin(9600);
 Serial.print("STARTED");
 
 pinMode (Saftey, OUTPUT);
 pinMode(RelayTrig, OUTPUT);
 pinMode(RelayLaser, OUTPUT);
 irrecv.enableIRIn();
}
 
 int on = 0;
 unsigned long last = millis();
 
 
 void loop()
{
 
    if (digitalRead(button) == LOW)

  for(pos = 0; pos < 90; pos += 90)   //
  {                                   
    triggerservo.write(pos);               
                 
  }
  if (digitalRead(button) == HIGH)
 
  for(pos=90; pos>=0; pos-=90)      //-----> Original
  {                               
     triggerservo.write(pos);               
                               
                           
  }
{
  if (irrecv.decode(&results)) {   
    if (results.value == 0x20DFC23D) { //Menu Button: pulls/releases trigger only if saftey is off (LED on when released).
      if (millis() - last > 250) {
        on = !on;
        digitalWrite(RelayTrig, on ? HIGH : LOW);
      }
      last = millis();
    }   
  }
 
  if (irrecv.decode(&results)) {   
    if (results.value == 0x20DF10EF) { //Power Button: Turns on/off the saftey on the trigger
      if (millis() - last > 250) {
        on = !on;
        digitalWrite(Saftey, on ? HIGH : LOW);
      }
      last = millis();
    }   
   
  }
{
  if (irrecv.decode(&results)) {
    if (results.value == 0x20DF906F) { //Mute Button: Turns on/off the targeting laser.
    if (millis() - last > 250) {
        on = !on;
        digitalWrite(RelayLaser, on ? HIGH : LOW);
     }
      last = millis();
     
     
    }   
   
}
}
  }
   if (irrecv.decode(&results))  {
  Serial.print("Are you here yet");
    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();
}


20  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 29, 2012, 12:47:31 am
Opps... Sorry about that. However, I'm getting the same results, nothing.

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))  {
  Serial.print("Are you here yet");
    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();
}
21  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 29, 2012, 12:36:25 am
On my other sketch it works fine so this is what I think I'm going to do, I will take the setups and all the if statements and put that into my sketch that this belongs to anyways (that the IR is working with no problems) and see if I can get it working in there.
22  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();
}
23  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();
}
24  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.
25  Using Arduino / Project Guidance / Re: PWM Servo via IR on: June 28, 2012, 11:44:31 pm
Oh, okay! Thanks!
26  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. 
27  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.
28  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.
29  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.
30  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!
Pages: 1 [2] 3 4 ... 6