Skip to content

Instantly share code, notes, and snippets.

void brushMotorCurrentTest_00(){
byte response[16];
int incomingByte = 0; // for incoming serial data
int timeOut = 40;
int bufferPos = 0;
byte howManyBytes = 2;
cleaningMotors(primary, 30); // spin the primary motor
int checkSensor(byte whichSensor, byte* response, byte howManyBytes) {
// This function will return the value of a sensor
// The first perameter inidcates the sensor code to querry
// The function takes a pointer as a parameter so it can copy the data into the buffer pointed to by that pointer
// The third paremeter is for keeping track of the number of bytes that the querry will return
int timeOut = 40;
int bufferPos = 0;
if(!response) return 0;
byte response[16];
int checkSensor(byte whichSensor, byte howManyBytes) {
int timeOut = 40;
int bufferPos = 0;
roombaSerial.write(142);
roombaSerial.write((byte)whichSensor);
int checkSensors(byte whichSensor, byte howManyBytes){
int timeOut = 40;
roombaSerial.write(149);
roombaSerial.write((byte)howManyBytes);
for (int x = 0; x < howManyBytes ; x++) {
roombaSerial.write((byte)whichSensor++);
Main Brush Motor Current
Packet ID: 56
Data Bytes: 2, signed
This returns the current being drawn by the main brush motor as an unsigned 16 bit value, high byte
first.
Range: -32768 – 32767 mA
http://www.irobot.com/~/media/MainSite/PDFs/About/STEM/Create/create_2_Open_Interface_Spec.pdf
PWM Motors Opcode: 144 Data Bytes: 3
This command lets you control the speed of Roomba’s main brush, side brush, and vacuum
independently. With each data byte, you specify the duty cycle for the low side driver (max 128). For
example, if you want to control a motor with 25% of battery voltage, choose a duty cycle of 128 * 25%
= 32. The main brush and side brush can be run in either direction. The vacuum only runs forward.
Positive speeds turn the motor in its default (cleaning) direction. Default direction for the side brush is
counterclockwise. Default direction for the main brush/flapper is inward
void motorsTest_01() {
/*
pwmMotors(primary, 0xFF32);
pwmMotors(primary, 0);
pwmMotors(primary, 0x1E);
pwmMotors(primary, 0);*/
roombaSerial.write(144); // OI opcode for PWM Motors
roombaSerial.write(0x1E);
roombaSerial.write((byte)0);
// TBHS 2015 Episode 200 - 202 - 205 Roomba Nerf
// This code is intended for an arduino connected to a pixy and a roomba
// pixy will search for a green nerf dart, then relay the x coordinate to the arduino,
// the arduino will send instructios to the roomba for driving the motors to turn towards the nerf dart.
//
// Currently working on code to turn on and of brush and vacuum motors.
#include <SoftwareSerial.h>
#include <SPI.h>
#include <Pixy.h>
On local machine make a working directory.
In the working directory create a temporary project directory.
Copy project files from server to local machine working/project directory.
Navigate to working/project directory.
Follow this instruction set:
git init
git remote add origin <repo address>
First you need to set up the remote and local repo and link them together.
This is assuming you've already installed git.
Make a repo on github or bitbucket, I prefer github, but bitbucket offers private repos for free.
This will give you a repo address, looks a lot like a web address.
Initialize the local repo: go to your project folder in a terminal and
type
git init
Then run