Show Posts
Pages: 1 ... 3 4 [5] 6 7 ... 71
61  Topics / Robotics / Re: Kinect/Ardunio/Processing and 5 Motors on: April 23, 2013, 06:54:51 pm
Im having great difficulty getting this to work. I'm still stuck on trying to get the kinect to power 5 servo motors. I havent even gotten processing to communicate with the arduino. Any tips?
You need to do all of this:
  • Control 1 servo with arduino (sweep example) (Arduino -> Servo)
  • Control 5 servos with arduino (sweep example + arrays) (Arduino -> Servos)
  • Make kinect do something interesting on computer (In processing, println("servos should be moving right now"); This is probably the hardest step). (Kinect -> Processing)
  • Make processing talk with arduino (When it sends "hello" the arduino flashes an LED) (Processing -> Arduino)
  • Make kinect talk to arduino via processing (Kinect -> Processing -> Arduino)
  • Kinect -> Processing -> Arduino -> Servos

Which are you having trouble with? Give specific details so that we may help.
62  Using Arduino / Programming Questions / Re: Serial - Wait for Input on: April 21, 2013, 08:15:04 pm
while(Serial.available() == 0);
63  General Category / General Discussion / Re: Need help making my own Arduino without buying an Arduino board on: April 21, 2013, 05:31:13 pm
Firstly, I do not know how to use the development board with my pc, which runs Windows 8 64 bit.
Neither do we since you haven't said which one you have. I'm guessing a USB cable, though.
I also dont know what way to insert the microcontroller in the socket.
Notch in the uC to the notch in the socket
I want to turn the uC's into Arduinos.
What other equipment do I need?
You need an ISP. Some atmega chips, if they have the correct program on them, can be used as an ISP. You also need wire to connect the ISP to the chip. You may want a crystal and capacitors but they aren't necessary.
I would not be able to buy an arduino board, anything else I'm fine. Just give me the generic names, like what you call those, not the specific brands.
ISP, wire
Also, so I need to keep the uC plugged into the board at all times or is there something else I could do?
The chip needs power and can't do anything without connecting it to I/O. Depending on how you flashed it, you may need an oscillator, and you'll generally need a chip to program the atmega via USB. Presumably your development board has those hooked up, but you can theoretically do it all without the board (I do)
64  Using Arduino / Programming Questions / Re: Compiler Error "error: 'strlen' was not declared in this scope" on: April 19, 2013, 11:48:35 pm
You may want to re-read the article about how to create a library. Your member variables need to be declared within the class definition in the .h file
65  Using Arduino / Programming Questions / Re: Compiler Error "error: 'strlen' was not declared in this scope" on: April 19, 2013, 11:30:37 pm
If you wrote the STRING library it's possible there's an error in there. Post that one, too.
66  Using Arduino / Programming Questions / Re: Compiler Error "error: 'strlen' was not declared in this scope" on: April 19, 2013, 10:14:05 pm
there's also no such thing as a STRING, only a String. Also, please read "Read this before posting a programming question ..." so you can learn how to make your posts look right
67  Topics / Robotics / Re: Kinect/Ardunio/Processing and 5 Motors on: April 19, 2013, 12:08:35 am
ok thanks mate. I'll fiddle with that soon enough so. Is there anything I should be concerned about with running 5 motors off arduino though?
I would try to get an external 5V power source. Five should be okay but if you start seeing weird issues then it's likely not getting enough power.
68  Using Arduino / Programming Questions / Re: Millis Accuracy Again on: April 18, 2013, 01:44:20 am
2) Everything I read is that millis() shouldn't lose so much time.  But I see what I see.  My laptop clock could be wrong (even though its actively NTP-syncing).  But the telescope tracking is off, and this is detectable by watching a star (the ultimate reference).  So I know the Arduino is forcing the tracking off, which can only be explained by its losing time.
No, I'm saying that the SOFTWARE won't lose time. Everyone knows the resonator is only accurate to 0.5%, which could be up to be seven minutes over a day or 18 seconds per hour or 6 seconds per 1200 second period (twice what you measured)
69  Community / Website and Forum / Re: Advanced Searching? on: April 18, 2013, 01:40:11 am
Ah, so there it is.  Somewhere that nobody can find it. 
I don't see how being one of the six links at the top of every page on the forums that follows you around and being labeled "search" is hard to find.
70  Using Arduino / Programming Questions / Re: Millis Accuracy Again on: April 18, 2013, 12:42:57 am
ok someone just told me that the interrupt priority goes...

External interrupts, USB, WDT, Timer 1, Timer 0, SPI, USART...

So am I right in assuming that it's actually Serial.print() which is screwing with my timekeeping?

millis() / micros() uses Timer 0 right?

So if I hook up an external clock generator, I can get ticks that don't get masked by Serial.print() ?
They don't get lost, they just get delayed. So if an external interrupt and timer0 interrupt happen on exactly the same clock cycle, it will run the external interrupt and, when it's done, run 1 instruction from the main program and then run the timer0 interrupt (the arduino will NOT stop one interrupt to run another of a higher priority, the priority list only comes into play in the extremely rare circumstance that they both happen on the same mid-clock cycle or whatever it says in the datasheet) You only have a problem when the external interrupt takes so long that two timer0 interrupts happen while it's running. Otherwise, the one instruction preformed between the two interrupts could make the time off, but unless that instruction is cli (which is executed as the second instruction in millis()) the time will be correct.

So: the time could be off by up to 2ms+time of an interrupt at a time, but only in extremely rare circumstances, and it will resync (ie no drift). However, if you have an interrupt that takes longer than 1ms to execute, you will start losing time and getting drift. Also, if the resonator is off your time will, obviously, be off.

Using an RTC with an external interrupt will have the same potential problems except there's no 1.024 thing which could make your time off by 2ms. And their crystals are often better.
71  Community / Website and Forum / Re: Advanced Searching? on: April 17, 2013, 11:41:03 pm
Like this
72  Topics / Robotics / Re: Kinect/Ardunio/Processing and 5 Motors on: April 17, 2013, 11:23:06 pm
Here's some processing code I used at one point to get the kinect to talk to the arduino (I think it was mostly stolen from a book called Making Things See)
import processing.serial.*;
import SimpleOpenNI.*;

SimpleOpenNI kinect;
Serial arduinoport;

void setup() {
  size(1024, 480);
  if (Serial.list().length < 1) {
    println("No serial port seen. Quitting.");
  if (Serial.list().length > 1) {
    print("There are multiple serial ports. Using the first one: ");
  arduinoport = new Serial(this, Serial.list()[0], 115200);
  //delay(2000); // Wait for arduino to reboot
  kinect = new SimpleOpenNI(this);

void draw() {
  PImage depth = kinect.depthImage();
  image(depth, 0, 0);
  IntVector userList = new IntVector();
  while (arduinoport.available() > 0) {
    char inByte = (char);
  boolean stopRobot = true; // Only move robot if someone is there
  for (int i=0; i < userList.size(); i++) {
    int userId = userList.get(i);
    if (kinect.isTrackingSkeleton(userId)) {
      float x = 0;
      float y = 0;     
      float rotation = 0;

      // Get the position of the torso
      PVector torsopos = new PVector();
      float torsoconfidence = kinect.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_TORSO, torsopos);
      if (torsoconfidence > 0.5) {
        float userPos = torsopos.x;
        userPos = map(userPos, -600, 600, 1000, -1000);
        userPos = constrain(userPos, -1000, 1000);
      PVector rightpos = new PVector();
      float rightconfidence = kinect.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_RIGHT_HAND, rightpos);
      PVector leftpos = new PVector();
      float leftconfidence = kinect.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_LEFT_HAND, leftpos);
      if (rightconfidence > 0.5 && leftconfidence > 0.5) {
        PVector differenceVector = PVector.sub(rightpos, leftpos);
        x = constrain(map(differenceVector.x, -600, 600, -1000, 1000), -1000, 1000);
        y = constrain(map(differenceVector.z, -200, 200, -1000, 1000), -1000, 1000);

        if (differenceVector.y > 0) { // If left hand is higher
          x = -x;
          y = -y;
        //print(x); print("\t"); print (y); print("\t");
      String arduinocmd = String.format("<r,%.0f,%.0f,%.0f>", x, y, rotation);//"<r,"+x+","+y+"," + rotation + ">";
      rect(725, 175, 250, 250);
      ellipse(map(x, -1000, 1000, -100, 100) + 850, map(y, -1000, 1000, -100, 100) + 300, 20, 20);
      //println (arduinocmd);
      stopRobot = false;
  if (stopRobot) {

void onNewUser(int userId) {
  text("Start pose detection", 700, 30);
  kinect.startPoseDetection("Psi", userId);

void onEndCalibration(int userId, boolean successful) {
  if (successful) {
    text("    User Calibrated!", 700, 30);
  else {
    text("    Failed to calibrate user", 700, 30);
    kinect.startPoseDetection("Psi", userId);

void onStartPose(String pose, int userId) {
  text("Started pose for user " + userId, 700, 30);
  kinect.requestCalibrationSkeleton(userId, true);

void displayJoint(PVector joint) {
  PVector converted = new PVector();
  kinect.convertRealWorldToProjective(joint, converted);
    ellipse(converted.x, converted.y, 20, 20);
And here's corresponding arduino code to control a robot with a library I wrote myself (just replace bot.RunMotors with whatever you want to move):
73  Community / Website and Forum / Re: Advanced Searching? on: April 17, 2013, 11:17:24 pm

Well, I'll be a monkeys uncle.  Never knew that search page was here.  Thanks, bookmarked!
It's also at the top of every page, even when you scroll down, right between "logged in as ..." and "My messages"
74  Using Arduino / Programming Questions / Re: use of main() in arduino IDE on: April 17, 2013, 11:14:39 pm
TCCR1B |= (1 << WGM12 ) | (1 << CS10 ) ; // Configure timer 1 for CTC mode

Don't do this. You don't want to mask TCCR1B, you want to set it. Just do
TCCR1B = (1 << WGM12 ) | (1 << CS10 ) ; // Configure timer 1 for CTC mode

Using |= is a good idea when you want to take what you have but turn on more bits. However, here you're trying to set every bit so you should just use = rather than |= or &=
75  Community / Website and Forum / Re: Advanced Searching? on: April 17, 2013, 09:56:08 pm
By advanced searching, i mean options like what fields to search (subject, author) or maybe date ranges. 
There is:
Pages: 1 ... 3 4 [5] 6 7 ... 71