kaandog – Physical Computing https://courses.ideate.cmu.edu/16-223/f2014 Carnegie Mellon University, IDeATe Fri, 11 Aug 2017 21:41:33 +0000 en-US hourly 1 https://wordpress.org/?v=4.7.28 Tutorial: Pixy (CMUcam5) https://courses.ideate.cmu.edu/16-223/f2014/tutorial-pixy-cmucam5/ Mon, 15 Dec 2014 04:49:16 +0000 http://courses.ideate.cmu.edu/physcomp/f14/16-223/?p=3541 This tutorial will focus on the correct way to set up and receive information from a Pixy using an Arduino Uno.  Please note that cmucam.org also provides instructions for the Pixy in the Pixy Quick Start Guide on their WIKI.

Set-Up

Powering the Pixy

Ideal:

Pixy can be powered through the Arduino cable provided, just plug in the cable and your pixy should be good to go!

Alternatives:

If, for some reason you decide to power the Pixy through the Vin and GND pins, be careful, these are not reverse polarity protected so you can kill the Pixy if you get the pins backwards.

Other options for powering Pixy are detailed here.

Starting up the Pixy

Apply power to Pixy to start it up.  After this one two things will happen:

If the pixy is configured to “recognize” an object, it will flash red every time that object is recognized and the pixy will send this data to the Arduino.

If the pixy wasn’t configured to recognize any object it will just go into an idle state. If you want to set a new signature, see “Programming” the Pixy.

“Programming” the Pixy

Ideal:

Unless you’re trying to recognize extremely complex objects and patterns, I recommend just configuring the pixy without the use of a computer.

Once the pixy is on, press and hold the button until the RGB led starts blinking in different colors. Once the seizure session stops, place the object that you want the pixy to recognize right in front of the camera (the led should be the color of the object at this point) and press the button (don’t hold it down). If the LED stops flashing, pixy has recognized your object and is now configured to recognize that object! If not, try again.

Alternative:

The pixy can also be loaded with signatures to recognize using the CMUcam5 software. This method may or may not work properly, depending on the firmware you have installed on the pixy. Open up pixymon, plug in the pixy, and highlight the object you want your pixy to recognize. If you want to clear or set new signatures, you can do this all through pixymon.

Configuring the Arduino

Once you have hooked up the pixy to the Arduino and configured the pixy to recognize an object, all you have to do is write the proper code to interpret the data from the pixy.

Install the Pixy Library

Download the pixy library from this link:

http://www.cmucam.org/attachments/download/1054/arduino_pixy-0.1.3.zip

In the Arduino IDE, import the newly downloaded library from Sketch->Import Library.

Writing Code

We will be using the pixy API to work with the data sent over from the pixy. The pixy API makes it extremely convenient to parse the data sent over from the pixy to the Arduino.

Data is received in “blocks”, where each block represents properties of an object that was detected. Blocks can tell you how big the object is on the screen, where it is and other useful information.

Here’s a quick guide to get you started:

Start by including the headers for pixy and SPI libraries:

#include <SPI.h>

#include <Pixy.h>

Declare a pixy global like so:

Pixy pixy;

In your setup function, initialize the pixy global:

pixy.init();

In your loop function you’re going to want to poll the pixy for recognized objects like so:

  uint16_t blocks; //size of array pixy sends

  blocks = pixy.getBlocks();

  if (blocks) // if there were any recognized objects

  {

    //finds the largest object that fits the signature

    for (j = 0; j < blocks; j++){

      prod = pixy.blocks[j].width * pixy.blocks[j].height;

      if (prod > maxProd) //save the new largest obj

          maxJ = j;

    }

This sample code goes through all the “blocks” (which represent objects that are found) and finds the largest block that fits the signature. This is done by checking the blocks area by multiplying the width and height. Blocks also hold more information that you can check, here’s a full list:

  • pixy.blocks[i].signature
    • signature of the object, from 1 to 7
  • pixy.blocks[i].x
    • x coordinate of the object, from 0 to 319
  • pixy.blocks[i].y
    • y coordinate of the object, from 0 to 199
  • pixy.blocks[i].width
    • width of the object, from 1 to 320
  • pixy.blocks[i].height
    • height of the object, from 1 to 200
  • pixy.blocks[i].print()
    • prints the objects received, to the serial port makes debugging easy

If all went well, your arduino should be correctly finding the proper largest object that was picked up by the pixy. To investigate code that was written for Bull, just go to the link:

https://github.com/kaandog/Bull/blob/master/Bull.ino

]]>
Final Project – Gloves https://courses.ideate.cmu.edu/16-223/f2014/gloves/ Wed, 10 Dec 2014 23:53:00 +0000 http://courses.ideate.cmu.edu/physcomp/f14/16-223/?p=3305  

Kaan Dogrusoz

Jonathan Ortiz

Myles Blodnick

Abstract

Gloves is a project that focused on mapping the position of fingers on a hand in real time and producing an appropriate output.

Why We Did This

Our goal was to create a wearable product that could have a wide range of applications. Noticing that we interact with the world around us by using our hands, we decided that getting a real-time estimation of the gestures one’s hands are making at any given time was valuable information as it could be used to control electronics, open a new level in wireless communication  and bring a new dimension into interacting with the virtual world.

Final Thoughts

If we were to have a next iteration, we would focus on a more complex use case for our glove. While being able to emulate music has potential, we believe that there is a lot more to discover and implement in this area, and we would like to explore further possibilities enabled by wireless communication with another glove.

Topics of interest include:

  • Sending sign language wirelessly
  • Playing an instrument with the owner of the other glove
  • Glove as a mouse/keyboard

Technical Notes

Gloves consist of 5 Flex sensors, an 8 ohm speaker, 5 22k ohm resistors and Arduino Nano with an ATmega328.

Github:

https://github.com/kaandog/PianoHands

Video:

Image Gallery:

]]>