The pushbutton allows the user to start a 3D scan by the push of a button, similar to how a real portable camera works.  I wasnt able to access the beagleboards user button with software, so I used a simple SPST switch and wired one side to GND and the other to GPIO 139.  I mounted the button on the topside of the polycarb housing.  With project deadlines luming, I didn’t add any hardware de-bouncing, but this can be done later in software.

The guys over at ridgerun have a great example on GPIO and interrupts, which I have modified to suit my purposes.  I have posted modifications below:

GPIO Setup:

gpio = 139; // SPST connected to GPIO 139
gpio_export(gpio); //export to user space
gpio_set_dir(gpio, 0); //set direction to input
gpio_set_edge(gpio, “falling”);  // Set interrupt edge, can be rising, falling or both.
gpio_fd = gpio_fd_open(gpio);

Upon interrupt:

printf("Starting Scann");
slScanner(); // run the sl code
printf("Scan Completen");
printf("Press button to scan again or Ctrl C to quit");

<–Previous     Project Home     Next –>

Be Sociable, Share!
  1. Mark Right says:

    Hi man, it seems a great work :) could you explain me in detail how to configure the board to manage the GPIO pin ?! Are you working on linux host? I have a beagle bone instead a beagle board but it should be the same way i suppose …
    Thanks a lot

  2. maxmike says:

    How would you turn off interrupts after the first one in the polling loop – and then reset them?
    I tried:

    gpio_set_value(gpio, 0);

    gpio_set_value(gpio, 1);

    since I expect falling edges as interrupts.

    The first statement works and I only get one interrupt before calling the interrupt service, but when I
    invoke the second statement it goes into an infinite loop delivering interrupts.