Tuesday, July 17, 2012

PIR Sensor Wheelchair Cyclops!

Ever seen a wheelchair bound cyclops stuck in a reverse loop? Behold... PIR Cyclops!  The Cyclops detects motion using the PIR sensor (his eyeball) and once it is detected, he wheels backwards for a short time (using a continuous servo).

Video 1:  The PIR Cyclops in action.

This guy was built using an Arduino, PIR sensor and a continuous servo.  All readily available from adafruit.com.  Full on instructions for creating this little guy will be posted to the blog and also the instructables website soon.  The Arduino code is posted below.  Also, here are a few pictures (no specific order) of the build:

Image 1: Wiring for the PIR sensor is routed through the Cyclops' neck.

Image 2: Arms and hands are painted and connected.

Image 3: Foam is spackled and sanded to create the pieces of the Cyclops' body.

Image 4: The rough shape of the Cyclops is cut from a foam block.  The PIR sensor is inserted into the Cyclops' head.

Image 5: Rubber bands hold shut the trap door in the bottom of the wheelchair where the Arduino connects to the PIR sensor, continuous servo and power source (9V battery).

Image 6:  The armless Cyclops waits for a few final parts.

Image 7: The continuous servo is attached to one of the wheels on the wheelchair.

Image 8: The finished product sits motionless waiting to detect movement.

Arduino CODE:

// Servo driven by PIR Sensor
// Whim of ImagineN4tion
// 5.21.2012

#include <Servo.h>
Servo myservo;  // create servo object to control a servo 
                // a maximum of eight servo objects can be created 

int PIR = 2;      //Define what pin the PIR sensor is on
int PIRval = 0;    //Define variable that will store the PIR reading, set to 0 for now
int servo = 9;    //Define what pin the servo is on

void setup(){
  //Serial.begin(9600);  //Start the serial port
  pinMode(PIR, INPUT);
  pinMode(servo, OUTPUT);
    myservo.attach(servo);  // attaches the servo on pin 9 to the servo object 

void loop(){
  PIRval = digitalRead(PIR);    //Read the PIR sensor on pin 2 and store the value to 'PIRval'
  //Serial.println("sensor reading =");
  //Serial.println(PIRval);    //Print the value stored in PIR to the serial port
  //Note the servo being used here is a continuous rotation servo calibrated so that
  //the servo is stopped at a write value of 90.  Forward = 180, reverse = 0. 
  if(PIRval == LOW){    //If there is no movement do nothing
  else{                  // Else if there is movement drive servo forward

No comments:

Post a Comment