This sketch won't do ANYTHING on a Discovery (4210 0504 07) when connected to an Uno R3 thru an appropriate cable. The Discovery works as expected on its own and with the Roomba Remote.
I'm working with the LEDs for now. I'll work with the drive motors once I get the lights figgered out.
What is the purpose of toggling DD when setting up the Roomba?
Thanks, in advance, for any assistance
/*
* Turn lights on & off
* --------------
* The following code came from "Bump-&-Turn" so it should(?) work
* Arduino pin 3 is connected to Roomba RXD
* Arduino pin 4 is connected to Roomba TXD
* Arduino pin 5 is connected to Roomba DD
*
*/
#include <SoftwareSerial.h>
SoftwareSerial Roomba(3,4);
int ddPin = 5;
int ledPin = 13;
void setup() {
pinMode(ddPin, OUTPUT); // sets the pins as output
pinMode(ledPin, OUTPUT); // sets the pins as output
digitalWrite(ledPin, HIGH); // Start Setup
// wake up the robot
digitalWrite(ddPin, HIGH);
delay(100);
digitalWrite(ddPin, LOW);
delay(500);
digitalWrite(ddPin, HIGH);
delay(2000);
// set up ROI to receive commands
Roomba.write(128); // START Roomba in PASSIVE mode
delay(50);
// Set baud rate
Roomba.write(129); // Baud command
Roomba.write(10); // 10 = 57600
Roomba.write(130); // CONTROL Roomba in SAFE mode
delay(50);
digitalWrite(ledPin, LOW); // finished setup
delay(2000);
}
void loop()
{
// This code came directly from "
Hacking Roomba" page 32
digitalWrite(ledPin, HIGH);
Roomba.write(139); // LEDS command
Roomba.write(40); // Status & Spot green
Roomba.write(128); // Power medium amber
Roomba.write(128); // 50% bright
delay(4000);
Roomba.write(139); // LEDS command
Roomba.write(15); //Dirt Detect, MAX, Clean, Spot ON
Roomba.write(128); // Green Power
Roomba.write(255); // 100% on
delay(4000);
Roomba.write(139); // LEDS command
Roomba.write(16); // Red Status
Roomba.print(0); // Power color
Roomba.write(100); // Dim
delay(4000);
Roomba.print(139); // LEDS command
Roomba.print(48); // Amber Status
Roomba.print(0); // Power Green
Roomba.print(128); // 50%
delay(4500);
Roomba.print(139); // All off
Roomba.print(0);
Roomba.print(0);
Roomba.print(0);
digitalWrite(ledPin, LOW); // we've finished 1 loop
delay(3000);
}