Pages: [1]   Go Down
Author Topic: FreeDuino (Arduino) BOOT to Turn Left & Right  (Read 1237 times)
0 Members and 1 Guest are viewing this topic.
Mumbai -INDIA
Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Hi
Few Days back I brought an FreeDuino (ARDUINO) board ATMEGA 328P
I manage to Move MY first Assembled CAR with the free codes online
but I would like to move it Forward then Right-Forward , Left-Forward , Reverse Then Right-Reverse , Left Reverse or any other direction but it should come back to its Original PLACE from where it STARTED.

Code:
//motor A connected between A01 and A02
//motor B connected between B01 and B02

int STBY = 10; //standby

//Motor A
int PWMA = 3; //Speed control
int AIN1 = 9; //Direction
int AIN2 = 8; //Direction

//Motor B
int PWMB = 5; //Speed control
int BIN1 = 11; //Direction
int BIN2 = 12; //Direction

void setup(){
  pinMode(STBY, OUTPUT);

  pinMode(PWMA, OUTPUT);
  pinMode(AIN1, OUTPUT);
  pinMode(AIN2, OUTPUT);

  pinMode(PWMB, OUTPUT);
  pinMode(BIN1, OUTPUT);
  pinMode(BIN2, OUTPUT);
}

void loop(){
  move(1, 255, 1); //motor 1, full speed, left
  move(2, 255, 1); //motor 2, full speed, left

  delay(1000); //go for 1 second
  stop(); //stop
  delay(250); //hold for 250ms until move again

  move(1, 128, 0); //motor 1, half speed, right
  move(2, 128, 0); //motor 2, half speed, right

  delay(1000);
  stop();
  delay(250);
}

void move(int motor, int speed, int direction){
//Move specific motor at speed and direction
//motor: 0 for B 1 for A
//speed: 0 is off, and 255 is full speed
//direction: 0 clockwise, 1 counter-clockwise

  digitalWrite(STBY, HIGH); //disable standby

  boolean inPin1 = LOW;
  boolean inPin2 = HIGH;

  if(direction == 1){
    inPin1 = HIGH;
    inPin2 = LOW;
  }

  if(motor == 1){
    digitalWrite(AIN1, inPin1);
    digitalWrite(AIN2, inPin2);
    analogWrite(PWMA, speed);
  }else{
    digitalWrite(BIN1, inPin1);
    digitalWrite(BIN2, inPin2);
    analogWrite(PWMB, speed);
  }
}

void stop(){
//enable standby 
  digitalWrite(STBY, LOW);
}


I have 2 DC Gears Motors on a cheese on pin 8,9 ,11 & 12
with FREEDUINO Board

But don't know what to do with pin no 3 & 5 ??? & pin no 10 ???
which is for Speed control & standby respectively ..


can any one guide me how to code for the above requirement
Thanks in advance


* 2012-10-28-0144.jpg (1973.39 KB, 3264x2448 - viewed 31 times.)
Logged

"THE LIFE IS VERY SMALL TO LEARN ELECTRONICS"
                           ε∫εζτ√°ηiζ≈
                           AND
                           yes
                           PROGRAMMING

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 553
Posts: 46283
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
but I would like to move it Forward then Right-Forward , Left-Forward , Reverse Then Right-Reverse , Left Reverse or any other direction but it should come back to its Original PLACE from where it STARTED.
That is nowhere near as easy a task as you think it is. You'll need to keep track of exactly how far the car moved, in which direction. Not how far you told it to move in some direction. How far it ACTUALLY moved and which direction it ACTUALLY moved in. How do you intend to determine those values?

Quote
I have 2 DC Gears Motors on a cheese on pin 8,9 ,11 & 12
with FREEDUINO Board
What kind of cheese? Cheddar? Swiss? If it's Swiss, do the holes help?

Quote
But don't know what to do with pin no 3 & 5 ??? & pin no 10 ???
which is for Speed control & standby respectively ..
We really need to know what kind of cheese you are using.
Logged

Mumbai -INDIA
Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
We really need to know what kind of cheese you are using
see the photo the CHEESE i means the Metal frame .
If you want to know the name of the Arduino board its FREEDUINO  ATMEGA 328P USB v1015 from BHASHA http://www.bhashatech.com/22-freeduino-usb.html

Thanks
Logged

"THE LIFE IS VERY SMALL TO LEARN ELECTRONICS"
                           ε∫εζτ√°ηiζ≈
                           AND
                           yes
                           PROGRAMMING

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 553
Posts: 46283
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
see the photo the CHEESE i means the Metal frame .
And the wheels, you'll be referring to those on the future as PIZZA, and the wires I'm guessing will be RAVIOLI.

When you use names that the rest of us conventionally use, we'll get somewhere.

The Freeduino can not directly power or control motors. You need a motor control shield, and you need to post a link to the one you are (going to be) using.
Logged

Mumbai -INDIA
Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok i got it
the  motor control shield is from BHASHA Technologies (http://www.bhashatech.com/shields/66-motor-shield.html)

it has 2 L 293 DNE and 1 M 74 HC 595 B1


* 2012-10-29-0157.jpg (2377.75 KB, 3264x2448 - viewed 20 times.)
Logged

"THE LIFE IS VERY SMALL TO LEARN ELECTRONICS"
                           ε∫εζτ√°ηiζ≈
                           AND
                           yes
                           PROGRAMMING

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 553
Posts: 46283
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://www.ladyada.net/make/mshield/
The designer of the board documents how to use the board that Bhasha tech is selling.
Logged

Pages: [1]   Go Up
Jump to: