ROBOTC.net Blog  

ROBOTC News

Archive for the ‘mindsensors’ tag

LEGO NXTShot 2.0 – Cannon controlled by Mindsensors remote

without comments

[Correction: updated description]

Here’s another neat video that Tim found. It features a joystick that you can use to point its “missile shooter” towards a target. Here’s the description:

NXTShot 2.0 is lego NXT model cannon. Its targeting is driven in realtime by a Mindsensors Acceleration Sensor mounted on a remote. Its firing mechanism is powered by springs from old BIC pens. It has an innovative homing system that sets the limits for turning and inclining using a single light sensor. It has an onscreen menu system that uses a voice to give feedback on selections. It is programmed in ROBOTCC.
I have made plans of NXTShot using Google SketchUp and the fantastic NXT components provided by Payton White (see tinyurl.com/yw7tnw). More pictures of NxtShot can be found at tinyurl.com/2l7m2m.


YouTube Direct Link 

Written by Vu Nguyen

December 14th, 2009 at 10:55 am

Posted in Cool projects,NXT

Tagged with , ,

ROBOTC with the Mindsensors NXTCam

with 4 comments

The Mindsensors NXTCam can be configured to track up to 8 colored objects.  It connects to an NXT sensor port, and reports the coordinates of each object to the NXT, enabling fast line tracking, color recognition, and object tracking. Watch this cool video showing ROBOTC and the NXTCam: http://www.education.rec.ri.cmu.edu/downloads/lego/resources/NXTCam/NXTCam.html

Sample code for Color Recognition:

#pragma config(Sensor, S1,     camera1,             sensorI2CCustomFast)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//
 
/*
Color Recognition - ROBOTC for the NXT
 
Description: The NXT displays the name of the color returned by the Mindsensors NXTCam v2
 
NXT Configuration:
- Mindsensors NXTCam v2 plugged into NXT Sensor Port 1
 
Camera Configuration:
- Color Index 0: Red
- Color Index 1: Orange
- Color Index 2: Yellow
- Color Index 3: Green
- Color Index 4: Blue
- Color Index 5: Purple
- Color Index 6: Black
- Color Index 7: Brown
 
Notes:
- As of October 2008, NXTCam color index must be configured through
NXTCamView, found at: http://nxtcamview.sourceforge.net/
- More information can be found at: http://mindsensors.com/index.php?module=pagemaster&PAGE_user_op=view_page&PAGE_id=78
*/
 
//Include NXTCam Library
#include "RAnxtCamLib.c"
 
//Define global variables
string colorName;
int numBlobs;
int_array blobColor;
int_array blobX1;
int_array blobTop;
int_array blobX2;
int_array blobBottom;
 
void printColorName();
 
task main ()
{
  //Initialize the NXTCam
  enableTracking(camera1);
  wait1Msec(500);
  sortBySize(camera1);
  wait1Msec(500);
  useObjectTracking(camera1);
  wait1Msec(500);
 
  //Recognize Colors Forever
  while(true)
  {
    printColorName();
    wait1Msec(100);
  }
}
 
//void printColorName() - Writes the color returned from the camera to the NXT screen
void printColorName()
{
  nxtDisplayString(1, "The color is:");
  //Retrieves Camera Data
  getCameraData(camera1, numBlobs, blobColor, blobX1, blobTop, blobX2, blobBottom);
 
  if(numBlobs > 0)  //If at least 1 "blob" or color is seen...
  {
    switch(blobColor) //...check the blobColor index.
    {
    case 0:
      colorName = "RED     ";
      break;
    case 1:
      colorName = "ORANGE  ";
      break;
    case 2:
      colorName = "YELLOW  ";
      break;
    case 3:
      colorName = "GREEN   ";
      break;
    case 4:
      colorName = "BLUE    ";
      break;
    case 5:
      colorName = "PURPLE  ";
      break;
    case 6:
      colorName = "BLACK   ";
      break;
    case 7:
      colorName = "BROWN   ";
      break;
    default:
      colorName = "UNKNONWN";
      break;
    }
  }
  nxtDisplayString(3, colorName);
}

Written by Jesse Flot

November 24th, 2009 at 12:32 pm