Show Posts
Pages: [1]
1  Using Arduino / Motors, Mechanics, and Power / Re: Useing the SaberTooth Dual 5A Controller with an Arduino on: December 07, 2012, 11:31:37 am
Hi
Thanks for the Reply.

I don't think i can use Delay as my aim is to make this a reactive program using a switch statement.

I tried with a delay to just test and it ignored the delay and just spazzed out haha.

The problem i have now is entirely separate than this thread was started with so i will make a new post in a separate part of the forum.

thanks smiley-grin

2  Using Arduino / Motors, Mechanics, and Power / Re: Useing the SaberTooth Dual 5A Controller with an Arduino on: December 06, 2012, 02:48:04 pm
Hiya

So i managed to get the robot built, and the servo functions working.

Unfortunately i cannot seem to find a way to code it to do the following:

Drive at a speed of 120 for 2 seconds
Stop
Wait for 2 seconds
Reverse at a speed of 60 for 1 second

I can get it to go forward and back but i cannot get it to drive for a set period of time.

is this an issue with using PWM? I did try using serial packets but it failed smiley-sad

anyone got any idea?

Here is my code

Code:
#include <Servo.h>


Servo motorR;
Servo motorL;
int speedo;


void setup()
{

  motorR.attach(9);
  motorL.attach(10);
}

void drive(int speedo)
{
  motorR.write(speedo);
  motorL.write(speedo);
  return;
}
void left()
{
  motorR.write(120);
  motorL.write(60);
}
void right()
{
  motorR.write(60);
  motorL.write(120);
}

void STOP()
{
  motorR.write(90);
  motorL.write(90);
  return;
}

void loop()
{
drive(1200);
delay(2000);
drive(1800);
//right();
//drive(105);
//left();

}

3  Using Arduino / Motors, Mechanics, and Power / Re: Useing the SaberTooth Dual 5A Controller with an Arduino on: November 29, 2012, 01:47:10 pm
You can use the R/C input option, and drive it using the servo library.

Hi
Ah i see, that seems very interesting.

What do most people use to write and upload there code to Arduino's?

I'm using the Arduino Software that is downloadable from Arduino's site.

To add the Library what exactly do i need to do?

many thanks
james

4  Using Arduino / Motors, Mechanics, and Power / Useing the SaberTooth Dual 5A Controller with an Arduino on: November 29, 2012, 09:03:33 am
Hi there

I was useing some small moters with a Robots Bits shield but the power was to little for the application.

So i have upgraded to 2 x 12V Motors that have a stall amperage of 5A, hence the Saber-tooth dual 5A Controller seemed perfect.
You can see what i have here: http://robotbits.co.uk/motor-drivers/sabertooth-2x-5amp-motor-driver/prod_58.html

I have an issue though, I have read (after paying for it and having it arrive) that i cannot simple use the Outputs on the Arduino to control it as it requires a Voltage input from 0-5V, and the Arduino that i have only does PWM and does not output the Analog voltage i require.

Can anyone help me with how to get my Arduino to talk to the Saber-tooth so i will be able to move my nice new motors.

If its a hassle and not worth it, is there any other Driver's that will power my 2 motors (2 x 5A) using PWM Input?

Many thanks
james

5  Using Arduino / Programming Questions / Re: Problem with my code. on: February 15, 2011, 05:43:56 pm
Hey again.

I decided in the end to start again, So far i have got this:

Code:
#define BUTTON1 10
#define BUTTON2 11
#define POT1 0
#define BUZZER 3
#define LATCH 7
#define CLOCK 8
#define DATA 4
#define LED1 6

const byte numbers[10] = {B10111101, B10101101, B10000101, B10110000, B10011001, B10010010, B10000010, B11111000, B10000000, B10010000 };

int i;
int DispNum;

void setup()
{
pinMode(BUTTON1, INPUT);
pinMode(BUTTON2, INPUT);
pinMode(LATCH, OUTPUT);
pinMode(CLOCK, OUTPUT);
pinMode(DATA,OUTPUT);
pinMode(LED1, OUTPUT);
Serial.begin(9600);

}

void loop()
{
Serial.println(DispNum);
//------ FUNCTIONS CALLED BELOW --------  
numberSeg();
}
//--------------- FUNCTIONS ONLY BELOW PLEASE ---------------------------
int numberSeg()
{
i = analogRead(POT1)/102;
if (i >= 3 && i <= 9)
{
digitalWrite(LATCH, LOW);
shiftOut(DATA, CLOCK, MSBFIRST, numbers[i]);
digitalWrite(LATCH, HIGH);  
}
confirm();
}

// Confirm Selection Code

int confirm()
{
if (!digitalRead(BUTTON1))
{
DispNum = i; // Number of tries
}

delay(400);

}


What this does it use the POT and create 10 segments, i only want 3-9 so i set it to that in the NumberSeg.

Once i have picked my number i want to confirm the selection, So made the confirm function.

At the moment it works so when i press BUTTON1 it put out 4 in the serial display, There was no need to return any thing as when i di it broke the code.

is there anyway to stop this looping once i have the number i want?

I simply want it to record the number i have just created and use it to set the test running said ammount of times.


if i dont make sence please shoot me! lol

Thanks people!
6  Using Arduino / Programming Questions / Re: Problem with my code. on: February 15, 2011, 12:58:53 pm
Well, for a start, when posting code, please use the # icon on the editor's toolbar.

Another useful tip is to use the auto format tool in the IDE before posting; this will sort out your eccentric indentation.

The function "confirm" has the return type "int", but doesn't return anything.
The function "reaction" has the return type "int", but doesn't return anything.
The function "numberSeg" has the return type "int", but doesn't return anything.
The function "counter" has the return type "int", but doesn't return anything.
And the function "flash".

hey

What do you meen it doesnt return anything?

a quick example would help wonders!
7  Using Arduino / Programming Questions / Re: Problem with my code. on: February 15, 2011, 12:57:34 pm
is that better?

8  Using Arduino / Programming Questions / Problem with my code. on: February 15, 2011, 10:10:31 am
Hi there

I'm new here, I didnt want to come asking questions and intended to look about and try to figure it out.

But i cant find my issue smiley-sad

I havent been useing C for very long and am in no way "good" at it, but i know the basics.

What i was trying to d

Create a Reaction time test

Steps:
1. use a potinmeter (dial thing) to select from 3-9 and display on a 7 Seg display
2. Confirm number selected by pressing button1
3. Beep Buzzer to confirm selection
4. Run the number of tests according to selected number


Problem i havem is that It selects the number correctly and confirms it (without buzzer at this moment in time)
It then counts down to a LED light and i have to press button 2 to stop it.

BUT Its all looping without stopping, Buttons dont help and i have no idea where i have gone wrong.

If its entirely screwed up please say so i can just start again from scratch.

here is my code

Code:
#define BUTTON1 10
#define BUTTON2 11
#define POT1 0
#define BUZZER 3
#define LATCH 7
#define CLOCK 8
#define DATA 4
#define LED1 6

const byte numbers[10] = {B10111101, B10101101, B10000101, B10110000, B10011001, B10010010, B10000010, B11111000, B10000000, B10010000 };

int DispNum = 0;
int potVar = 0;
int i = 0;
int times[9]; // Reaction time array
int count;
int start;
int j = 0; // Value for the reaction Time.

void setup()
{
pinMode(BUTTON1, INPUT);
        pinMode(BUTTON2, INPUT);
pinMode(LATCH, OUTPUT);
pinMode(CLOCK, OUTPUT);
pinMode(DATA,OUTPUT);
        pinMode(LED1, OUTPUT);
Serial.begin(9600);

}

void loop()
{
numberSeg(); // Function call for the segment display, Note the () after the function name. This MUST be included.
        
        reaction();
//-=---------------- Print
        Serial.println(DispNum, DEC);
        Serial.println(count, DEC);
        Serial.println(j, DEC);

}

// Below cose is a function for the Segemnt display.

  
int numberSeg()
{
i = analogRead(POT1)/102;
if (i >= 3 && i <= 9)
{
digitalWrite(LATCH, LOW);
shiftOut(DATA, CLOCK, MSBFIRST, numbers [i]);
digitalWrite(LATCH, HIGH);  
}
confirm(); // Function Call for confirm choice.
}


int confirm()
{
if (!digitalRead(BUTTON1))
{
            DispNum = analogRead(POT1)/102, numbers [i]; // Number of tries
}
            counter();
        }
          
        int counter()
        {
            count = random(3000, 7000);
  
            for (start = count; start > 0; start--) //
        {
            delay(1);
        }        
            flash(); // LED FLASH CALLED
          
        }

            int flash() // LED flash
        {
            digitalWrite(LED1, HIGH);
            delay(1000);
        }
                
  
int reaction() // Reaction press
{
  while (digitalRead(BUTTON2))
  {
    digitalWrite(LED1, LOW);
    j++;
    delay(1);
  }
  times[DispNum] = j;
  
}
   
  
I'm only after some advice from some of you more experianced programmers smiley[/pre]
Pages: [1]