Go Down

Topic: getting arduino to work WITHOUT PROTO SHIELD (Read 1 time) previous topic - next topic


Oct 02, 2012, 12:41 am Last Edit: Oct 02, 2012, 02:38 am by andromeda_boy Reason: 1
hello people,  i am building this project, it has full source code
in the site:

( only the arduino_control code is needed to be

and the full detailed schematic USING


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


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
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
// register callback functions, which will be
called when an associated event occurs.
(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
switchState = HIGH;
switchTime = millis();
//Switch state changed... update Android
switchPrev = switchReading;
// Reverse
if (dir == 1)
digitalWrite(motor1PIN1A, HIGH);
digitalWrite(motor1PIN2A, LOW);
digitalWrite(motor2PIN3A, HIGH);
digitalWrite(motor2PIN4A, LOW);
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
  if (!switchState) return;
int data[numOfValues];
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
  // if more than cmdTimeout milliseconds have
passed with no input, stop motors
if (millis()-lastcmd > cmdTimeout) {

all kind of help will be apreciated :)


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.


Oct 02, 2012, 01:29 am Last Edit: Oct 02, 2012, 02:39 am by andromeda_boy Reason: 1
I have just made a correction above, man, thanks for noticing that, man


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?


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

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.

The art of getting good answers lies in asking good questions.

Go Up