Shop OBEX P1 Docs P2 Docs Learn Events
Scribbler 2 barcode sensor — Parallax Forums

Scribbler 2 barcode sensor

neerdowellneerdowell Posts: 25
edited 2011-10-26 03:11 in Robotics
I'm not having much luck having the robot sense barcode #1. I'm moving at 50% power directly over the barcode turning on the LEDs if it senses barcode 1, but it never does. I put the conditional test in a loop going from 1 to 10. Any hints?

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-10-25 17:31
    When you printed the barcode, did it come out nice and black? Does the sheet of paper sit flat on the floor without curls or wrinkles? Do the other barcodes work okay?

    -Phil
  • neerdowellneerdowell Posts: 25
    edited 2011-10-25 17:47
    Yeah, nice and black. Sits flat on hardwood floor, no wrinkles. I tried barcode 2, same results.

    I've attached the .scb file. Am I doing something wrong?
  • neerdowellneerdowell Posts: 25
    edited 2011-10-25 18:37
    I added an observe condition tile in the loop before the conditional test, and it had no effect. According to the gui help file, it is optional anyhow.
  • neerdowellneerdowell Posts: 25
    edited 2011-10-25 19:03
    I changed the move command (previously was for 5 seconds) to 0 time, thinking that maybe the sensing and the 5-second move were not asynchronous, but unlimited time would be. Didn't help.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-10-25 19:09
    Try using the Observation Deck to see if the black of your barcodes is registering. BTW, when you tilt the paper they're printed at an angle to the light, does the ink seem shiny at all?

    -Phil
  • neerdowellneerdowell Posts: 25
    edited 2011-10-25 20:15
    Thanks Phil. The observation deck does show the sensors reacting to the black bars as I pass the robot over the bar code paper, holding it slightly above the paper since the wheels don't turn freely in this mode. The ink (from my Canon laser printer) doesn't seem shiny, and I used a black marker to make it a bit darker, and still no success. Is the code I posted correct?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-10-25 21:11
    Looking at your code, I see the problem. When you tell the S2 to move for a certain amount of time, it does that first before doing anything else. You your case, it finishes its move before even beginning the loop that looks for the barcode. But, even if you had used an indefinite move, a loop of 100 iterations would probably finish before the S2 encountered the barcode. The answer to this is twofold:
    1. Start an indefinite move (i.e. one without a time limit) at the beginning of your program.
    2. In an infinite loop, check for the barcode as you do now.
    3. When it sees the barcode, have it flash its lights, then stop.

    From there, you can build more complex behaviors.

    -Phil
  • neerdowellneerdowell Posts: 25
    edited 2011-10-26 03:11
    Phil, you da' man!

    That worked. I see that the robot is sensitive to how much light is shining on the paper with the barcode on it. The success of this method seems to depend upon where I place the paper; if I put it at a certain place, it never works, and if I put it at a different place, it always works. It seems the brighter the room, the better.

    Attached is the code you suggested that works.

    One question: how do you get out of an infinite loop? I'm thinking, subroutine maybe?

    Don Shepherd
Sign In or Register to comment.