   lights(TAILLIGHTS, on);
 }
 
+/*
+ * Speed is a number between 0 and 255.
+ */
+void forward(int speed) {
+  // this function will run the motors in both directions at a fixed speed
+  // turn on motor A
+  digitalWrite(in1, HIGH);
+  digitalWrite(in2, LOW);
+  analogWrite(enA, speed);  
+  headlights(true);
+  taillights(false);
+}
 
+/*
+ * Speed is a number between 0 and 255.
+ */
+void backward(int speed) {
+  digitalWrite(in1, LOW);
+  digitalWrite(in2, HIGH);  
+  analogWrite(enA, speed);
+  headlights(false);
+  taillights(true);
+}
+
+void stop() {
+  digitalWrite(in1, LOW);
+  digitalWrite(in2, LOW);
+  headlights(false);
+  taillights(false);
+}
+
+void left() {
+  digitalWrite(in3, HIGH);
+  digitalWrite(in4, LOW);
+  analogWrite(enB, 255);  
+}
+
+void right() {
+  digitalWrite(in3, LOW);
+  digitalWrite(in4, HIGH);
+  analogWrite(enB, 255);  
+}
+
+void center() {
+  digitalWrite(in3, LOW);
+  digitalWrite(in4, LOW);  
+}
+
+void demoOne()
+{
+  // this function will run the motors in both directions at a fixed speed
+  // turn on motor A
+  digitalWrite(in1, HIGH);
+  digitalWrite(in2, LOW);
+  // set speed to 200 out of possible range 0~255
+  analogWrite(enA, 200);
+  // turn on motor B
+  digitalWrite(in3, HIGH);
+  digitalWrite(in4, LOW);
+  // set speed to 200 out of possible range 0~255
+  analogWrite(enB, 200);
+  delay(2000);
+  // now change motor directions
+  digitalWrite(in1, LOW);
+  digitalWrite(in2, HIGH);  
+  digitalWrite(in3, LOW);
+  digitalWrite(in4, HIGH); 
+  delay(2000);
+  // now turn off motors
+  digitalWrite(in1, LOW);
+  digitalWrite(in2, LOW);  
+  digitalWrite(in3, LOW);
+  digitalWrite(in4, LOW);
+}
+
+

#define HEADLIGHTS 2
#define TAILLIGHTS 3

void setup() {
  Serial.print("starting up...\n");
  Serial.begin(9600);      // open the serial port at 9600 bps
  // put your setup code here, to run once:
  pinMode(HEADLIGHTS, OUTPUT);
  pinMode(TAILLIGHTS, OUTPUT);

  NaiveBayes nb;
  nb.addModel(1, 0.01, 0.001);

  observations[0] = -0.01;
  observations[1] = 0.15;
  nb.classify(categories, 2, observations, 2);  

  forward(255);
  delay(1000);
  stop();
  delay(500);
  backward(255);
  delay(1000);
  stop();

  left();
  delay(1000);
  right();
  delay(1000);
  center();
}

void loop() {
  forward(255);
  delay(2000);
  stop();
  delay(2000);
  backward(255);
  delay(2000);
  stop();
  delay(2000);
}

void lights(int pin, boolean on) {
