Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Roomba Blink - Challenge 2
- by Justin Modra, follow my on Twitter @JustinModra
- May 30, 2015
- Sends an active low pulse to the DD (Device Detect) Pin of the Roomba 4000
- for 500msec to wake the Roomba up from the default power on sleep state
- Puts the Roomba in Full Command Mode, turn off safety features
- ignore wheel drops, cliff detectors and connected charger
- Initializes a software defined serial port
- on pins 5 and 6 of the Arduino Uno
- Illuminates the Roomba Power LED
- Color fades through the possible color values from 0 to 255
- Roomba Serial Command Interface Specification at the following location:
- http://www.ecsl.cs.sunysb.edu/mint/Roomba_SCI_Spec_Manual.pdf
- ArduinoUno Digital IO 5 RX to Roomba pin 4 TXD (yellow wire)
- ArduinoUno Digital IO 6 TX to Roomba pin 3 RXD (orange wire)
- ArduinoUno Digital IO 7 DD to Roomba pin 5 DD (black wire)
- See the project description at the following website:
- https://nightskylife.wordpress.com/2015/05/26/interfacing-roomba-model-4000-with-arduino-uno/
- */
- #include <SoftwareSerial.h>
- SoftwareSerial mySerial(5, 6); //rx,tx
- int ddPin = 7;
- // the setup function runs once when you press reset or power the board
- void setup() {
- pinMode(ddPin, OUTPUT);
- pinMode(13, OUTPUT);
- mySerial.begin(57600);
- //Use Device Detect to wake Roomba
- digitalWrite(ddPin, HIGH);
- delay(100);
- digitalWrite(ddPin, LOW);
- delay(500);
- digitalWrite(ddPin, HIGH);
- delay(2000);
- //Initialize Roomba SCI
- // Start SCI
- mySerial.write(128);
- delay(100);
- // Enable control
- mySerial.write(130);
- delay(100);
- // Enable full control, no safety, all commands
- mySerial.write(132);
- delay(100);
- }
- // the loop function runs over and over again forever
- void loop() {
- for (int fadecount=0; fadecount < 256; fadecount++) {
- mySerial.write(139); // control LEDs opcode
- mySerial.write((byte)0); // Status LED off
- mySerial.write((byte)fadecount); // Power Color
- mySerial.write(255); // Intensity set to full
- delay(100);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement