Mark Easley
Published

TI-RSLK Assembly Tips

Some tips to speed up the assembly process.

IntermediateProtip2 hours3,012
TI-RSLK Assembly Tips

Things used in this project

Story

Read more

Schematics

Modified Basic Assembly Guide PDF

Code

RSLKsystemtest.ino

Arduino
#include "Energia.h"

//Basic Kit
#include <Bump_Switch.h>
#include <QTRSensors.h>
#include "Romi_Motor_Power.h"

//Advanced or custom includes
#include "GP2Y0A21_Sensor.h"

/* Wi-Fi */
#include <WiFi.h>

/* BLE */
//#include <BLE.h>

//defines
#define NUM_SENSORS   8     // number of sensors used
#define TIMEOUT       2500  // waits for 2500 microseconds for sensor outputs to go low
#define EMITTER_PIN   61     // emitter is controlled by digital pin P5_3

//objects
Bump_Switch      bump_sw[6];
QTRSensorsRC qtrrc((unsigned char[]) {65, 48, 64, 47, 52, 68, 53, 69},
  NUM_SENSORS, TIMEOUT, EMITTER_PIN);
unsigned int sensorValues[NUM_SENSORS];
GP2Y0A21_Sensor dst_sensor[3];
Romi_Motor_Power motor[2];

/* Wi-Fi */
char wifi_name[] = "RSLK WiFi";
char wifi_password[] = "rslkwifi";
WiFiServer myServer(80);

void setup() {
  Serial.begin(9600);
  
  pinMode(PUSH1, INPUT_PULLUP); //pin 73 LP left button
  pinMode(PUSH2, INPUT_PULLUP); //pin 74 LP right button
  pinMode(RED_LED, OUTPUT);
  pinMode(GREEN_LED, OUTPUT);
  pinMode(BLUE_LED, OUTPUT);
  
  bump_sw[0].begin(58, INPUT_PULLUP);
  bump_sw[1].begin(57, INPUT_PULLUP);
  bump_sw[2].begin(41, INPUT_PULLUP);
  bump_sw[3].begin(43, INPUT_PULLUP);
  bump_sw[4].begin(60, INPUT_PULLUP);
  bump_sw[5].begin(51, INPUT_PULLUP);

  dst_sensor[0].begin(59,INPUT_PULLDOWN);
  dst_sensor[1].begin(33,INPUT_PULLDOWN);
  dst_sensor[2].begin(42,INPUT_PULLDOWN);  

  motor[0].begin(24,25,11);
  motor[1].begin(26,27,35);
  
  motor[0].enableMotor();
  motor[1].enableMotor();

  Serial.println("RSLK System Test Program 1.0");
  delay(500);
}

void wifi_setup() {
    
    Serial.println("*** LaunchPad CC3100 WiFi Web-Server in AP Mode");
    
    // Start WiFi and create a network with wifi_name as the network name
    // with wifi_password as the password.
    Serial.print("Starting AP... ");
    WiFi.beginNetwork(wifi_name, wifi_password);
    while (WiFi.localIP() == INADDR_NONE)
    {
        // print dots while we wait for the AP config to complete
        Serial.print('.');
        delay(300);
    }

    Serial.println("DONE");
    
    Serial.print("LAN name = ");
    Serial.println(wifi_name);
    Serial.print("WPA password = ");
    Serial.println(wifi_password);
    
    IPAddress ip = WiFi.localIP();
    Serial.print("Webserver IP address = ");
    Serial.println(ip);
    
    Serial.print("Web-server port = ");
    myServer.begin();                           // start the web server on port 80
    Serial.println("80");
    Serial.println();
}

void loop() {
  digitalWrite(GREEN_LED, HIGH);
  delay(200);
  digitalWrite(GREEN_LED, LOW);
  delay(200);
  digitalWrite(GREEN_LED, HIGH);
  delay(200);
  digitalWrite(GREEN_LED, LOW);
  
  Serial.println("Stage 1: Testing Bump Switches"); 
  Serial.println("Press LP right button to exit"); 
  while(digitalRead(PUSH2) == 1) {
    for(int x = 0;x<6;x++)
    {
      // Push one or more bump switch to see an output.
  
      // When switch is closed the switch goes to ground.
      // By default the pins are se
      if(bump_sw[x].read() == 0) {
        Serial.print("Bump switch ");
        Serial.print(x);
        Serial.println(" was pressed");
      }
    }
  }

  digitalWrite(RED_LED, HIGH);
  delay(200);
  digitalWrite(RED_LED, LOW);
  digitalWrite(BLUE_LED, HIGH);
  delay(200);
  digitalWrite(RED_LED, HIGH);
  digitalWrite(BLUE_LED, LOW);
  delay(200);
  digitalWrite(RED_LED, LOW);
  
  Serial.println("Stage 2: Testing QTR Line Sensor"); 
  Serial.println("Press LP left button to exit"); 

// This example is designed for use with eight QTR-1RC sensors or the eight sensors of a
// QTR-8RC module.  These reflectance sensors should be connected to digital inputs 3 to 10.
// The QTR-8RC's emitter control pin (LEDON) can optionally be connected to digital pin 2,
// or you can leave it disconnected and change the EMITTER_PIN #define below from 2 to
// QTR_NO_EMITTER_PIN.

// The main loop of the example reads the raw sensor values (uncalibrated).
// You can test this by taping a piece of 3/4" black electrical tape to a piece of white
// paper and sliding the sensor across it.  It prints the sensor values to the serial
// monitor as numbers from 0 (maximum reflectance) to 2500 (minimum reflectance).

// This example originally came from Pololu's Library:
// https://github.com/pololu/qtr-sensors-arduino/blob/master/examples/QTRAExample/QTRAExample.ino
// Minor changes were made to work with TI's RSLK and Energia software

  while(digitalRead(PUSH1) == 1) {
    // read raw sensor values
    qtrrc.read(sensorValues);
  
    // print the sensor values as numbers from 0 to 2500, where 0 means maximum reflectance and
    // 2500 means minimum reflectance
    for (unsigned char i = 0; i < NUM_SENSORS; i++)
    {
      Serial.print(sensorValues[i]);
      Serial.print('\t'); // tab to format the raw data into columns in the Serial monitor
    }
    Serial.println();
  
    delay(250);
  }

  digitalWrite(RED_LED, HIGH);
  delay(200);
  digitalWrite(RED_LED, LOW);
  digitalWrite(BLUE_LED, HIGH);
  delay(200);
  digitalWrite(RED_LED, HIGH);
  digitalWrite(BLUE_LED, LOW);
  delay(200);
  digitalWrite(RED_LED, LOW);
  
  Serial.println("Stage 3: Testing Distance Sensor");  
  Serial.println("Press LP right button to exit"); 

  while(digitalRead(PUSH2) == 1) {
    Serial.print("Left Distance Sensor Value: ");
    Serial.println(dst_sensor[0].read());
    Serial.print("Center Distance Sensor Value: ");
    Serial.println(dst_sensor[1].read());
    Serial.print("Right Distance Sensor Value: ");
    Serial.println(dst_sensor[2].read());
  }

  digitalWrite(RED_LED, HIGH);
  delay(200);
  digitalWrite(RED_LED, LOW);
  digitalWrite(BLUE_LED, HIGH);
  delay(200);
  digitalWrite(RED_LED, HIGH);
  digitalWrite(BLUE_LED, LOW);
  delay(200);
  digitalWrite(RED_LED, LOW);
  
  Serial.println("Stage 4: Testing Motors");  
  Serial.println("Press LP left button to exit"); 

  while(digitalRead(PUSH1) == 1) {
    Serial.println("Turn both wheels forward");
    motor[0].directionForward();
    motor[1].directionForward();
    motor[0].setSpeed(30);
    motor[1].setSpeed(30);
    delay(3000);
  
    Serial.println("Turn both wheels backwards");  
    motor[0].directionBackward();
    motor[1].directionBackward();  
    delay(3000);
  
    Serial.println("Set left wheel faster");    
    motor[0].setSpeed(50);
    delay(3000);
  
    Serial.println("Set right wheel faster");   
    motor[0].setSpeed(30);  
    motor[1].setSpeed(50);  
    delay(3000);
  
    motor[1].setSpeed(30); 
    Serial.println("Pause motors");     
    motor[0].pauseMotor();
    motor[1].pauseMotor();
    delay(3000);
  
    Serial.println("Resume motors");  
    motor[0].resumeMotor();
    motor[1].resumeMotor();
    delay(3000);

  }

  
  Serial.println("Stage 5: Testing Encoders");  
  Serial.println("Press LP right button to exit"); 

  while(digitalRead(PUSH2) == 1) { 
    
  }

  digitalWrite(RED_LED, HIGH);
  delay(200);
  digitalWrite(RED_LED, LOW);
  digitalWrite(BLUE_LED, HIGH);
  delay(200);
  digitalWrite(RED_LED, HIGH);
  digitalWrite(BLUE_LED, LOW);
  delay(200);
  digitalWrite(RED_LED, LOW);
  
  Serial.println("Stage 6: Testing BLE Module");  
  Serial.println("Press LP right button to exit"); 

  while(digitalRead(PUSH1) == 1) { 
    
  }

  digitalWrite(RED_LED, HIGH);
  delay(200);
  digitalWrite(RED_LED, LOW);
  digitalWrite(BLUE_LED, HIGH);
  delay(200);
  digitalWrite(RED_LED, HIGH);
  digitalWrite(BLUE_LED, LOW);
  delay(200);
  digitalWrite(RED_LED, LOW);
  
  Serial.println("Stage 7: Testing Wi-Fi Module");  
  Serial.println("Press LP left button to exit"); 

  wifi_setup();
  while(digitalRead(PUSH2) == 1) { 
    
  }
}

Credits

Mark Easley

Mark Easley

65 projects • 137 followers
Texas Instruments LaunchPad SW Engineer

Comments