Hi Mark,
First, I do not know how to connect the logic power seperately. The Motor shield has two connections and when the 12 vold supply is connected there the system seems to work and the Arduino responds. If I unplug the USB to the Arduino it still works. I could connect a 5V supply to the Arduino (about to try that) ... tried that and no difference. Still don't know if there are some jumpers that need to be set on the Motor Shield. Still surprises me that either program works with the same wireing but when I add one to the other ZAP only fast speed works.
Are you suggesting that I should use more comments? You're so right. It is a bad habbit. You know I think I know what I'm doing!
Here is the PWM code that works+++++++++++++++++++++++++++++++++++
/*
* Crawler motor
*/
void setup() // run once, when the sketch starts
{
Serial.begin(9600); // set up Serial library at 9600 bps
//pinMode(0, INPUT);
pinMode(13, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(3, OUTPUT);
}
int get = 15;
int motorFoward() {
analogWrite(11, get);
analogWrite(3, get);
delay(1000);
digitalWrite(11, LOW);
digitalWrite(3, LOW);
delay(1000);
digitalWrite(13, HIGH);
digitalWrite(12, LOW);
Serial.println(get);
delay(1000);
}
int motorBackward() {
// get = 80;
analogWrite(11, get);
analogWrite(3, get);
delay(1000);
digitalWrite(11, LOW);
digitalWrite(3, LOW);
delay(1000);
digitalWrite(13, LOW);
digitalWrite(12, HIGH);
Serial.println(get);
delay(1000);
}
void loop() // run over and over again
{
motorFoward();
motorBackward();
get = get + 5;
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
And here is the IR code that works, My remote has 5 rows the first 4 of which have three buttons and the fifth has only two.''
/*
RemoteDecode sketch
Infrared remote control signals are decoded
*/
#include <IRremote.h> // IR remote control library
long irKeyCodes[14]; // holds the codes for each key
IRrecv irrecv(A2); // create the IR library
decode_results results; // IR data goes here
void setup()
{
Serial.begin(9600);
pinMode(A2, INPUT);
pinMode(9, OUTPUT);
irrecv.enableIRIn(); // Start the IR receiver
learnKeycodes(); // learn remote control key codes
// Serial.println("Press a remote key");
pinMode(13, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(3, OUTPUT);
}
void loop()
{
long prevValue = -1;
}
/*
* get remote control codes
*/
void learnKeycodes()
{
while(irrecv.decode(&results)) // empty the buffer
irrecv.resume();
Serial.println("Ready to Start ");
long prevValue = -1;
int i=0;
while( i <22)
{
while(true)
{
if( irrecv.decode(&results) )
{
if(results.value != -1 && results.value != prevValue)
{
showReceivedData();
irKeyCodes[i] = results.value;
i = i + 1;
prevValue = results.value;
irrecv.resume(); // Receive the next value
break;
}
irrecv.resume(); // Receive the next value
}
}
}
Serial.println("Learning complete");
}
/*
* converts a remote protocol code to a logical key code
* (or -1 if no digit received)
*/
int convertCodeToKey(long code)
{
for( int i=0; i <22; i++)
{
if( code == irKeyCodes[i])
{
return i; // found the key so return it
}
}
return -1;
}
/*
* display the protocol type and value
*/
void showReceivedData()
{
long myValue = -1;
long r1c1 = 16738455;
long r1c2 = 16754775;
long r1c3 = 16722135;
long r2c1 = 16740495;
long r2c2 = 16756815;
long r2c3 = 16724175;
long r3c1 = 16732335;
long r3c2 = 16748655;
long r3c3 = 16716015;
long r4c1 = 16736415;
long r4c2 = 16752735;
long r4c3 = 16720095;
long r5c1 = 16744575;
long r5c3 = 16711935;
myValue = results.value;
Serial.println( myValue);
if (myValue == r1c1)
{
Serial.println(" r1 c1");
}
if (myValue == r1c2)
{
Serial.println(" r1 c2");
delay(1000);
Serial.println(" got to this place");
}
if (myValue == r1c3)
{
Serial.println(" r1 c3");
}
if (myValue == r2c1)
{
Serial.println(" r2 c1");
}
if (myValue == r2c2)
{
Serial.println(" r2 c2");
}
if (myValue == r2c3)
{
Serial.println(" r2 c3");
}
if (myValue == r3c1)
{
Serial.println(" r3 c1");
}
if (myValue == r3c2)
{
Serial.println(" r3 c2");
}
if (myValue == r3c3)
{
Serial.println(" r3 c3");
}
if (myValue == r4c1)
{
Serial.println(" r4 c1");
}
if (myValue == r4c2)
{
Serial.println(" r4 c2");
}
if (myValue == r4c3)
{
Serial.println(" r4 c3");
}
if (myValue == r5c1)
{
Serial.println(" r5c1");
}
if (myValue == r5c3)
{
Serial.println(" r5 c3 ");
}
}
========================================
Thanks for all of your time.
Mike