Project showcase
Bugboy!!!

Bugboy!!!

A little device that frantically moves when objects move closer to it.

  • 5 views
  • 0 comments
  • 0 respects

Components and supplies

Necessary tools and machines

3drag
3D Printer (generic)

Apps and online services

About this project

Sometimes I find myself wishing there was a generic device that I could used to create some simple movement quickly. I came up with Bugboy after I created Specimen #1. I wanted to strip the complexity out of the same idea, but keep the principle of response to light and shadow. There's so much you can do with an analog sensor. It's a matter of pinpointing (somewhat) specific values in the readings and triggering the desired response from there.

Here's a brief video of the mechanism with a creature skin attached. In this application, I also added neopixels under the skin and a pincer mechanism for the jaws.

I wanted the movement to become increasingly frenetic as the shadow moves closer and intensifies, but the opposite could easily be achieved with a few value changes in the code.

The mechanics are very simple, and little more than a simple 3D printed servo bracket with some semi flexible PLA appendages attached. I'm learning that sometimes this approach can have a greater effect than something extremely elaborate.

Code

bugboyArduino
// NeoPixel Ring simple sketch (c) 2013 Shae Erisson
// released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif */
#include <Servo.h>
// These constants won't change:
const int sensorPin = A0;    // pin that the sensor is attached to
const int ledPin = 13;        // pin that the LED is attached to



// variables:
int sensorValue = 0;         // the sensor value
int sensorMin = 1023;        // minimum sensor value
int sensorMax = 0;           // maximum sensor value
Servo head;
Servo rightArm;
Servo leftArm;
Servo rightLeg;
Servo leftLeg;
Servo pincer;

//**************************neopixel stuff*****************************************************************/
// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1
#define PIN            6
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS      38

// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int delayval = 500; // delay for half a second
void setup() {
  
    // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
#if defined (__AVR_ATtiny85__)
  if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
  /**************************** End of trinket special code***********************************************/

 
  
   head.attach(3);
   rightArm.attach(5);
   leftArm.attach(7);
   pincer.attach(8);
   rightLeg.attach(10);
   leftLeg.attach(11);
  // turn on LED to signal the start of the calibration period:
  pinMode(13, OUTPUT);
  digitalWrite(13, HIGH);

  // calibrate during the first five seconds 
  while (millis() < 5000) {
    sensorValue = analogRead(sensorPin);

    // record the maximum sensor value
    if (sensorValue > sensorMax) {
      sensorMax = sensorValue;
    }

    // record the minimum sensor value
    if (sensorValue < sensorMin) {
      sensorMin = sensorValue;
    }
     pixels.begin(); // This initializes the NeoPixel library.
   // Serial.begin(9600);
  }

  // signal the end of the calibration period
  digitalWrite(13, LOW);
}

void loop() {
  
  
  // read the sensor:
  sensorValue = analogRead(sensorPin);
  Serial.println(sensorValue);
  // apply the calibration to the sensor reading
  sensorValue = map(sensorValue, sensorMin, sensorMax, 0, 255);

  // in case the sensor value is outside the range seen during calibration
  sensorValue = constrain(sensorValue, 0, 255);

  // fade the LED using the calibrated value:
  analogWrite(ledPin, sensorValue);
  head.write(sensorValue);
   rightArm.write(sensorValue);
    leftArm.write(sensorValue);
     rightLeg.write(sensorValue);
      leftLeg.write(sensorValue);
      pincer.write(sensorValue);
    // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.

  for(int i=0;i<NUMPIXELS;i++){

    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor(i, pixels.Color(255,255,255)); // Bright white color.

    pixels.show(); // This sends the updated pixel color to the hardware.

    //delay(delayval); // Delay for a period of time (in milliseconds).

  }
}

Comments

Similar projects you might like

Joy Robot (Robô Da Alegria)

Project tutorial by Igor Fonseca Albuquerque

  • 4,738 views
  • 6 comments
  • 34 respects

Stringent, the $15 Wall Plotter

Project tutorial by Fredrik Stridsman

  • 60,826 views
  • 64 comments
  • 251 respects

(SAL) Sonar&Alexa Lights

Project in progress by Matthew Reed

  • 1,143 views
  • 0 comments
  • 0 respects

Walbi, the Walking Biped

Project tutorial by Team The Inner Geek

  • 9,470 views
  • 6 comments
  • 110 respects

Automatic Button Dispenser

Project tutorial by Jeremy S. Cook

  • 3,289 views
  • 6 comments
  • 19 respects

Project 1: 2WD Obstacle Avoiding Robot

Project showcase by HDA Robotics

  • 35,031 views
  • 16 comments
  • 41 respects
Add projectSign up / Login