Pages: [1]   Go Down
Author Topic: getting arduino to work WITHOUT PROTO SHIELD  (Read 824 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hello people,  i am building this project, it has full source code
in the site:

http://www.scs.ryerson.ca/mfiala/
robotics_club/robot_projects/
Radu_android_robot/android_linefollowing.html
( only the arduino_control code is needed to be
modified)

and the full detailed schematic USING
EXPENSIVE  SPARKFUN PROTOSHIELD:

http://imgur.com/a/rtaBA

and just for the info, about the exspensive
protoshield is here:

https://www.sparkfun.com/products/7914?


I am now stuck becoz I dont have a protoshield,
and buying it means 3 weeks waiting and 30$
for item+shipping. I think modifying the code is
the best way since it doesn't seem complicated,
but alas, I am so newbie I dont know how to do
that.
The protoshield uses pin 12 for power switching
the arduino and pin 13 for led. those 2 pins are
redundant if u r not using a protoshield. now,
could someone please give me a direction where
are the part I have to modify the
arduino_control.pde code which is below to get
the pin12 and 13 out of job, as the real programming functions lying at android codings and arduino_control.pde is just to run motors, so I want the arduino is in the state of "has been turned on from the start" and doesnt meed pin 12 to turn arduino on



#include <MeetAndroid.h>
// declare MeetAndroid so that you can call
functions with it
MeetAndroid meetAndroid;
const int motor1enablePin = 9;    // H-bridge
enable pin
const int motor1PIN1A = 3; // H-bridge leg 1
(pin 2, 1A)
const int motor1PIN2A = 4; // H-bridge leg 2
(pin 7, 2A)
const int motor2enablePin = 10;    // H-bridge
enable pin
const int motor2PIN3A = 5; // H-bridge leg 3
(pin 10, 3A)
const int motor2PIN4A = 6; // H-bridge leg 4
(pin 15, 4A)
const int switchPin = 12; // On/off Switch
const int ledPin = 13;      // LED
//Motor Speed/Direction vars
int direction = 0; // 0=Forward, 1=Reverse
int motor1speed = 0; // Right motor
int motor2speed = 0; // Left motor
unsigned long lastcmd;
int cmdTimeout = 200; // timeout
int switchState = 0;
int switchReading;
int switchPrev = LOW;
long switchTime = 0;
long switchDebounce = 200;
void setup() {
// use the baud rate your bluetooth module is
configured to
  // not all baud rates are working well, i.e.
ATMEGA168 works best with 57600
Serial.begin(57600);
// register callback functions, which will be
called when an associated event occurs.
meetAndroid.registerFunction
(set_motor_speed, 's');
  // set all output pins
pinMode(motor1PIN1A, OUTPUT);
pinMode(motor1PIN2A, OUTPUT);
pinMode(motor1enablePin, OUTPUT);
pinMode(motor2PIN3A, OUTPUT);
pinMode(motor2PIN4A, OUTPUT);
pinMode(motor2enablePin, OUTPUT);
pinMode(ledPin, OUTPUT);
pinMode(switchPin, INPUT);
}
void motor_drive(int dir, int rspeed, int lspeed)
{
  switchReading = digitalRead(switchPin);
// if the input just went from LOW and HIGH
and we've waited long enough
// to ignore any noise on the circuit, toggle the
output pin and remember
// the time
if (switchReading == HIGH && switchPrev ==
LOW && millis() - switchTime >
switchDebounce) {
if (switchState == HIGH) {
switchState = LOW;
lastcmd = 0; //immediate stop
}
else
switchState = HIGH;
switchTime = millis();
//Switch state changed... update Android
meetAndroid.send(switchState);
}
digitalWrite(ledPin,switchState);
switchPrev = switchReading;
// Reverse
if (dir == 1)
{
digitalWrite(motor1PIN1A, HIGH);
digitalWrite(motor1PIN2A, LOW);
digitalWrite(motor2PIN3A, HIGH);
digitalWrite(motor2PIN4A, LOW);
}
//Forward
else
{
digitalWrite(motor1PIN1A, LOW);
digitalWrite(motor1PIN2A, HIGH);
digitalWrite(motor2PIN3A, LOW);
digitalWrite(motor2PIN4A, HIGH);
}
analogWrite(motor1enablePin, rspeed);
analogWrite(motor2enablePin, lspeed);
}
void set_motor_speed(byte flag, byte
numOfValues)
{
  if (!switchState) return;
int data[numOfValues];
meetAndroid.getIntValues(data);
direction = data[0];
motor1speed = data[1];
motor2speed = data[2];
lastcmd = millis();
}
void loop() {
meetAndroid.receive(); // you need to keep this
in your loop() to receive events
motor_drive
(direction,motor1speed,motor2speed);
  // if more than cmdTimeout milliseconds have
passed with no input, stop motors
if (millis()-lastcmd > cmdTimeout) {
motor1speed=0;
motor2speed=0;
}
}


all kind of help will be apreciated smiley
« Last Edit: October 01, 2012, 07:38:27 pm by andromeda_boy » Logged

Saskatchewan
Offline Offline
Sr. Member
****
Karma: 15
Posts: 345
When the going gets weird, the weird turn pro. - Hunter S. Thompson
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think people may be having a hard time figuring out what you want to do.

If you eliminate the use of pins 12 and 13 from the sketch, then what? Are you going to use a different two pins for switch and led? Do you just want to test the sketch? Do you have some hardware hooked up already? How do you see modifying the Sketch as a solution to your lack of a protoshield problem?

Non-existing hardware is not usually a problem looking for a software solution.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have just made a correction above, man, thanks for noticing that, man
« Last Edit: October 01, 2012, 07:39:40 pm by andromeda_boy » Logged

UK
Offline Offline
Shannon Member
****
Karma: 183
Posts: 11138
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

As far as I can see, the protoshield was being used to make an H bridge driver circuit to drive the motors.

If you eliminate that, how do you propose to drive the motors?
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 547
Posts: 45982
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I think modifying the code is
the best way since it doesn't seem complicated,
but alas, I am so newbie I dont know how to do
that.
The protoshield provides an are where you build a small circuit and connect it to the Arduino. If you elect to use a breadboard instead, the code won't know that. ABSOLUTELY NO CODE CHANGES ARE NEEDED.

But, as PeterH points out, you can't just skip the stuff that the tutorial says should be on the protoshield/breadboard.

Logged

Pages: [1]   Go Up
Jump to: