Show Posts
Pages: 1 ... 104 105 [106] 107 108 ... 225
1576  Using Arduino / Project Guidance / Re: please some one help me to program this one on: September 14, 2013, 07:23:07 am
Well I guess to start you need to get an Arduino and probably a starter kit to do some simple stuff first.

Then you'll need to get hold of some sensors like the LDR/ LED they have in one of those links, or a strip of sensors like Pololu have here. I think Pololu provide code for those, so then you'll be able to run a line-following robot.

Once you have that sorted, you'll need to think about what the competition requires. It seems you need to register when the black line turns to white at a crossing so you will have to have some kind of means of keeping track of where you are. Count the number of intersections you cross maybe?- have sensors outside the line and if they go black on both sides you cross a street, if the one over the line goes white at the same time, then you found a "white spot".

My advice is to get your mind round simple Arduino code first, then progress. When you start the actual programming, don't go straight to coding: rather flowchart the logic and make sure you have a working plan.

You'll also need to investigate LEDs... seems they want you to display numbers, so you might need 7-segment displays etc. Ah I read again and I see the number is just displayed by a bunch of 6 normal LEDs
1577  Using Arduino / Programming Questions / Re: Increment PWM! on: September 14, 2013, 07:12:40 am
I just realised why you have problems: as far as I could deduce, when you use the IR library, PWM on pin 3 is disabled.... I used 5 and 6
1578  Using Arduino / Programming Questions / Re: Increment PWM! on: September 14, 2013, 07:10:50 am
Ok here it is. It works but it's untidy; I promised myself to redo it with functions and case but never got round to it, so it's a bit ugly.

HTH, YMMV

Code:
/*
 * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
 * An IR detector/demodulator must be connected to the input RECV_PIN.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 */
 
/* well now it controls 2x motors on MotoMama (298) board
   
   Jim Brown June 2012
   jim.brownza at gmail dot com
   
   *******   PWM on pin3 seems disabled when using IR?
   
   Uses a Philips remote (with RC5 coding)
   under rc5, the keys have two toggled values
    speed:
    vol down:    411 or c11 hex; 1041 or 3089 dec
    vol up:      410 or c10 hex; 1040 or 3088 dec
    stop:
    standby:     3148 or 1100
    direction:
    cd (fwd):    3391 or 1343
    tuner (rev): 3199 or 1141
*/
               

#include <IRremote.h>

int RECV_PIN = 11;

//get the motors sorted
int motorA_speed_pin = 5;   // seems PWM not work on 3 with IR library This is the MM EnA
int motorA_speed = 0;  //always start at rest
//int motorA_speed_temp;  //for dir change
int motorA_dir_pin1 = 2; // MM ln1
int motorA_dir_pin2 = 4; // MM ln2
int motorB_dir_pin1 = 7; // MM ln3
int motorB_dir_pin2 = 8; // MM ln4
int motorB_speed_pin = 6;   // seems PWM not work on 3 with IR library This is the MM EnB
int motorB_speed = 0;  //always start at rest
//int motorB_speed_temp;  //for dir change
int motor_speed_step = 10;     // and change in pwm steps of 10 same for both motors
float turn_diff_factor = 0.8;
int turn_time = 1000; //milliseconds

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  pinMode(motorA_speed_pin, OUTPUT);
  analogWrite(motorA_speed_pin, motorA_speed);
  pinMode(motorA_dir_pin1, OUTPUT);
  pinMode(motorA_dir_pin2, OUTPUT);
  digitalWrite(motorA_dir_pin1, 1); //start forward
  digitalWrite(motorA_dir_pin2, 0); //start forward
 
  pinMode(motorB_speed_pin, OUTPUT);
  analogWrite(motorB_speed_pin, motorB_speed);
  pinMode(motorB_dir_pin1, OUTPUT);
  pinMode(motorB_dir_pin2, OUTPUT);
  digitalWrite(motorB_dir_pin1, 1); //start forward
  digitalWrite(motorB_dir_pin2, 0); //start forward
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, DEC);
    irrecv.resume(); // Receive the next value
   
    //now act on various key presses
   
    // *********************** STOP
    if (results.value == 3148 || results.value == 1100) {   
      motorA_speed = 0;
      motorB_speed = 0;
      Serial.print("Stopping ");
      Serial.print(motorA_speed);
      Serial.print("\t");
      Serial.println(motorB_speed);
     
      analogWrite(motorA_speed_pin, motorA_speed);
      analogWrite(motorB_speed_pin, motorB_speed);
    } //end of stopping
    // *********************** END OF STOP
     
    // *********************** SET STRAIGHT LINE SPEED
    //straight line speed.... both motors the same
    //    only time they differ is during a turn and it restores the changed one
    //          after a turn anyway
    //
    if (results.value == 1041 || results.value == 3089) {
      //slowing
      //slow motorA
      motorA_speed = motorA_speed - motor_speed_step;
      if (motorA_speed < 0) {
        motorA_speed = 0;
        }
      //slow motorB
      motorB_speed = motorB_speed - motor_speed_step;
      if (motorB_speed < 0) {
        motorB_speed = 0;
        }
       
      Serial.print("Going down to ");
      Serial.print(motorA_speed);
      Serial.print("\t");
      Serial.println(motorB_speed);
     
      analogWrite(motorA_speed_pin, motorA_speed);
      analogWrite(motorB_speed_pin, motorB_speed);
    } //end of slowing
   
    //
    if (results.value == 1040 || results.value == 3088) {
      //speeding
      //speed motorA
       motorA_speed = motorA_speed + motor_speed_step;
        if (motorA_speed > 255) {
        motorA_speed = 255;
        }
       //speed motor2
       motorB_speed = motorB_speed + motor_speed_step;
        if (motorB_speed > 255) {
        motorB_speed = 255;
        }
       
      Serial.print("Going up to ");
      Serial.print(motorA_speed);
      Serial.print("\t");
      Serial.println(motorB_speed);
     
      analogWrite(motorA_speed_pin, motorA_speed);
      analogWrite(motorB_speed_pin, motorB_speed);
    }  //end of speeding
    // *********************** END OF SET STRAIGHT LINE SPEED
   
    // *************************** SET DIRECTION
    // for the hell of it, gna stop and continue at same after setting speed
    if (results.value == 3391 || results.value == 1343) { 
      // forward
        Serial.print("Setting direction Forward");
       //stop
        analogWrite(motorA_speed_pin, 0);
        analogWrite(motorB_speed_pin, 0);
       // set dir forward
        digitalWrite(motorA_dir_pin1, 1);
        digitalWrite(motorA_dir_pin2, 0);
        digitalWrite(motorB_dir_pin1, 1);
        digitalWrite(motorB_dir_pin2, 0);
       // back to speed
        analogWrite(motorA_speed_pin, motorA_speed);
        analogWrite(motorB_speed_pin, motorB_speed);
    }  // end of forward
   
        if (results.value == 3199 || results.value == 1141) { 
      // reverese
       Serial.print("Setting direction Reverse");
       //stop
        analogWrite(motorA_speed_pin, 0);
        analogWrite(motorB_speed_pin, 0);
       // set dir forward
        digitalWrite(motorA_dir_pin1, 0);
        digitalWrite(motorA_dir_pin2, 1);
        digitalWrite(motorB_dir_pin1, 0);
        digitalWrite(motorB_dir_pin2, 1);
       // back to speed
        analogWrite(motorA_speed_pin, motorA_speed);
        analogWrite(motorB_speed_pin, motorB_speed);
    }  // end of reverse
    // *********************** END OF SET DIRECTION
   
   // ************************* TURNING
   if (results.value == 3169 || results.value == 1121) { 
      // turn left... slow motorA
        Serial.println("Turning LEFT");
        analogWrite(motorA_speed_pin, turn_diff_factor * motorA_speed);
        delay(turn_time);
        analogWrite(motorA_speed_pin, motorA_speed);       
     } //end of left
   
     if (results.value == 3168 || results.value == 1120) {   
       // turn right... slow motorB
        Serial.println("Turning RIGHT");
        analogWrite(motorB_speed_pin, turn_diff_factor * motorB_speed);
        delay(turn_time);
        analogWrite(motorB_speed_pin, motorB_speed);
       } //end of right
  } //end of ir stuff
} //end of void loop
1579  Using Arduino / Programming Questions / Re: Increment PWM! on: September 14, 2013, 07:02:02 am
I will do that.... stand by a few minutes. I need to email it to myself to pick up on this other laptop grrrrrr.
1580  Using Arduino / Programming Questions / Re: What wrong here? for, if loop code. on: September 14, 2013, 06:38:15 am
Quote
As you can guess i try run 4 BPM085 sensors on arduino uno

Well I can't speak for other members, but no, I would not have guessed that in a zillion years  smiley-confuse
1581  Using Arduino / Project Guidance / Re: please some one help me to program this one on: September 14, 2013, 06:24:45 am
Are you seriously thinking of building, programming and testing a robot for that competition in a week, when you are, by your own admission, new to this?

That's not a trivial task by any means....
1582  Using Arduino / Programming Questions / Re: Increment PWM! on: September 14, 2013, 05:59:04 am
Here's my code for when I slow down the robot with a button push from the tv remote. Essentially the same idea as yours' but it's a but difficult to understand yours with parts //'d out.

I defined a speed step variable, and then keep a speed variable going all the time. So each button push cuts the speed by whatever my step is, and the variable is updated. It checks if the push would try to set speed below 0, and if so, just sets it to 0. So if I push the button again, it goes down again from the current value, or of course it increases if I push the up arrow. Mines a 298 chip...

Code:
// *********************** SET STRAIGHT LINE SPEED
    //straight line speed.... decrease both motors the same
    //
    //
    if (results.value == 1041 || results.value == 3089) {
      //slowing
      //slow motorA
      motorA_speed = motorA_speed - motor_speed_step;
      if (motorA_speed < 0) {
        motorA_speed = 0;
        }
      //slow motorB
      motorB_speed = motorB_speed - motor_speed_step;
      if (motorB_speed < 0) {
        motorB_speed = 0;
        }
       
      Serial.print("Going down to ");
      Serial.print(motorA_speed);
      Serial.print("\t");
      Serial.println(motorB_speed);
     
      analogWrite(motorA_speed_pin, motorA_speed);
      analogWrite(motorB_speed_pin, motorB_speed);
    } //end of slowing
1583  Using Arduino / Programming Questions / Re: Increment PWM! on: September 14, 2013, 05:36:15 am
I'm digging out some code on my other laptop.... hangon
1584  Using Arduino / Programming Questions / Re: Increment PWM! on: September 14, 2013, 05:19:42 am
Quote
Everything works fine except the PWM-part

Yeah but what does that mean?- what's it not doing that it should do, and / or what's it doing that it's not supposed to do?
1585  Using Arduino / Programming Questions / Re: Increment PWM! on: September 14, 2013, 05:10:49 am
Quote
currently using this code but it don't work as I want it to do

You should describe what you want it to do, and then what it is doing...
1586  Community / Bar Sport / Re: Your latest purchase on: September 14, 2013, 05:06:16 am
Also, my own personal AED

Too many people in my circles have been dropping dead, and since an acquaintance pointed out that anyone can buy these now, it became untenable to perhaps not have one when it was needed.  Sigh.


Fantastic idea.... my son learned to use one a couple of years back on his BLS medic training, and now he's an ILS he can use a manual one too. Every home should have one.

But, did you rather not consider that you move in the wrong circles?   smiley-grin
1587  Using Arduino / Installation & Troubleshooting / Re: Polarity of jack on the board on: September 14, 2013, 04:47:43 am
Details here: center [sic] positive, 6-20VDC, 7-12 recommended
1588  Using Arduino / General Electronics / Re: Voltage regulator help on: September 14, 2013, 04:23:03 am
When it comes to electronics, everyone should be pedantic.

And not say things like this:

Quote
I have a circuit ... pulling around 600mAh.

He presumably means mA...
1589  Topics / Robotics / Re: Control of 3 servo motors using emg signal. on: September 14, 2013, 03:11:31 am
revestroke, I'm not sure what you're trying to do. What do you mean when you say that the elbow and wrist are activated using the base motor movement? Sounds like the incoming emg signal positions the base, then the base movement dictates what the elbow and wrist do?

I'm not getting a clear picture of what you're trying to do.....
1590  Community / Bar Sport / Re: It's 1982 and you need a MicroController :D on: September 14, 2013, 12:46:48 am
In 1974 I had a 370 and then in 1982 when I worked on CP/M systems I got myself a Micro-professor. I left it in the office when I went on annual leave and it got stolen: I'm still pissed off about that, 30 years later.
Pages: 1 ... 104 105 [106] 107 108 ... 225