Robotic Arm

The robotic arm

The robotic arm

Glad to move away from the clothing domain, I built a simple single degree of freedom robotic arm. All of the materials used to make the arm were scavenged from various scrap bins laying around the CMU Robotics Club. I also used this excercise to practice a little “improvisational building”, that is, I had no predefined design or plan of what this arm was going to look like, rather, I just started building and the form of the arm evolved as I built.  The robot uses two servos, one to control the position of the arm, and the other to control the opening and closing of the gripper.

The arm has two modes, which are selected by throwing a 3 postion switch to the left or right (the middle position is neutral). Flipping the switch to the right puts the arm in automatic mode. Explaining the automatic mode requires a bit of additional information about the area the robotic arm operates in. There is a small wooden block with a rounded recess for placing a small copper ball into. This rounded recess contains two wires, creating an open switch. When the copper ball is placed in the recess, the circuit is completed and the switch activated. The code running the robot then moves the robotic arm into a position so it can grab the ball from the block. After moving into position and pausing for a second, the gripper closes and grabs the ball. Then , the arm moves to a position to drop the ball into a square box. After dropping the ball, the arm returns to an idle position, and then conintues reading the checking the ball switch to see if another ball has set on the block. The robot will continuously pick and place the balls as long as it is fed them.

Flipping the mode selector switch to the left activates the manual control mode, giving the user control over the arm. Pressing the push button on the control panel toggles the gripper between the open and closed positions. Turing the knob, which is connected to a potentiometer, sets the position of the arm.

The code to operate the arm can be viewed here (.txt). It uses the ServoTimer1 library for controlling the servos.

Here is a short video demonstrating the robot’s capabilities:

Automatic Sunglasses Hat

The coolest hat this side of the Mississippi

After my experiences from the first two exercises, I wanted to create something that went beyond using just LED-based outputs for Project 1. I also wanted to implement a sensor-based input, something I hadn’t tried previously. These desires led me to create the automatic sunglasses hat.

The idea was to attach a pair of sunglasses to a hat, then add a motor to raise and lower them. A light sensor embedded in the hat would read in the amount of light reaching the hat and user, then the sunglasses would be raised or lowered based on the amount of light being above or below a certain threshold. Additionally, there would be a switch so the user could override the system. For a light sensor, I used a photoresistor, and a simple pushbutton switch for the override.

To control the motor to raise and lower the glasses, an additional circuit was needed. This circuit is called an H-bridge, and allows the motor run off of an alternate power supply and be controlled by digital outputs from the Arduino. Different combinations of high/low signals sent to three pins will make the motor turn forwards or backwards, as well as stop the motor. To make the H-bridge control circuit, I used an L298N full bridge driver. The L298N contains two H-bridges, though I only needed to use one for this project. One of my motivations for doing this project was learning to create more advanced circuits, and making the H-bridge circuit helped me achieve that goal. Creating the circuit was challenging, but in the end, rewarding. I had trouble getting the circuit to run the motor, and tore it down and rebuilt it several times. Eventually, I realized that the H-bridge was causing a small voltage drop from the input power to the motor, and this drop was just enough to take the voltage below the operating threshold of the motor. I bumped up the power on power supply by 1 volt, and then everything worked perfectly.

The sunglasses are attached to the hat by two metal brackets bolted to the rim. Attached to one bracket is a motor with integrated gearbox. A small socket head cap screw joins the sunglasses to the gearbox output, which creates the connection that transfers the rotation from the motor to the sunglasses. Attached to the other bracket is a simple momentary push button switch. The light sensor is attached directly in the middle of the brim of the hat, pointing straight ahead.

The hat operates under simple principles. If the light is brighter than the set threshold, the sunglasses are lowered to protect the wearer’s eyes (the defalt position for the sunglasses is up). If the light is not brighter than the set threshold, then the sunglasses go to the raised position. If the push button is pressed when the glasses are down, the sunglasses will return to the up position and stay there for as long as the user presses the button. If the light is still too bright when the button is released, the glasses are lowered; if the light is no longer bright when the button is released, the glasses reamain up.

Below is an image gallery, along with the code used to control the hat.

/*sunglasses is code for controlling automated sunglasses on a hat. A light sensor takes
continuous readings and automatically lowers a pair of sunglasses to protect the wearer's
eyes when the light reaches a certain brightness threshold. If the light drops below the
brightness threshold, the glasses are raised. A push button can act as an override and raise
the sunglasses from the down position, keeping the sunglasses up for the lentgh of time it
is held down.

An h-bridge controls the motor to raise and lower the glasses. It has three inputs:
one to enable and two to control direction. Setting the control pins to opposite values
(one HIGH, one LOW) sets the motor's direction. Setting the control pins to equal values
brakes the motor. Setting the enable pin to HIGH turns on the motor, setting it to LOW turns
the motor off.

By Rich Pantaleo, October 2008
*/


int Cpin = 9;  //High/low h-bridge pin
int Dpin = 10; //High/low h-bridge pin
int Vpin = 11; //Main h-bridge enable pin
int pushButton = 2;  //Pin for push button switch
int lightSensor = 0; //Pin for light sensor input
int brightness = 0;  //Set up variable for reading value from light sensor
int buttonVal = 0;   //Set up variable to reading value from push button input
boolean glassesDown = false; //Flag that stores if sunglasses are up or down
boolean buttonDown = false;  //Flag that stores if the push button is pressed or notm
void setup(){
pinMode(Cpin, OUTPUT); //Declare pin as output
pinMode(Dpin, OUTPUT); //Declare pin as output
pinMode(Vpin, OUTPUT); //Declare pin as output
pinMode(pushButton, INPUT); //declare push button as input
pinMode(lightSensor, INPUT);//delcare ligth sensor as input
digitalWrite(Vpin, LOW); //Disable motor
}
void loop(){

brightness = analogRead(lightSensor); //Read the input value of the light sensor
buttonVal= digitalRead(pushButton);   //Read the input value of the push button

  if(brightness<=530 && glassesDown == false && buttonDown == false){ //If the brightness is below a set threshold, the glasses are not down, and the push button is not down
    sunglassesdown();//Put the sunglasses down
  }
 
  if(brightness>530 && glassesDown == true && buttonDown == false){ //If the brightness is above a set threshold, the glasses are down, and the push button is not down
    sunglassesup();//Put the sunglasses up
  }
 
  if(buttonVal == HIGH && buttonDown == false && glassesDown == true){//If the push button is pressed down and the sunglasses are down
   sunglassesup(); //Put the sun glasses up
   buttonDown = true; //Set the push button flag to down

  }
  if(buttonVal == LOW){//If the push button is not being pressed
  buttonDown = false; //Set the push button value to up
  }
}
void sunglassesdown(){       //Put the sunglasses down
 digitalWrite(Cpin, LOW);    //Send no signal pin C on the h-bridge
  digitalWrite(Dpin, HIGH);  //Send a signal to pin D on the h-bridge, now the motor is set to turn forward and lower the sunglasses
  digitalWrite(Vpin, HIGH);  //Send a signal to pin V on the h-bridge, enable the motor
  delay(380);                //Run the motor for 380 milliseconds
  digitalWrite(Cpin, HIGH);  //Brake the motor
  digitalWrite(Vpin, LOW);   //Disable the motor
  glassesDown = true;        //Set the glasses flag to down
}

void sunglassesup(){         //Put the sunglasses up
  digitalWrite(Cpin, HIGH);  //Send a signal pin C on the h-bridge
  digitalWrite(Dpin, LOW);   //Send no signal to pin D on the h-bridge, now the motor is set to turn backward and raise the sunglasses
  digitalWrite(Vpin, HIGH);  //Send a signal to pin V on the h-bridge, enable the motor
  delay(380);                //Run the motor for 380 milliseconds
  digitalWrite(Dpin, HIGH);  //Brake the motor
  digitalWrite(Vpin, LOW);   //Disable the motor
  glassesDown = false;       //Set the glasses flag to up
}

 

 

 

Hat-mounted mood broadcasting device

For exercise 2, I modified the same hat that I used in exercise 1. I decided to make a hat that was capable of signalling to other people the mood of the wearer. This is accomplished using a tri-color RGB LED, a potentiometer, momentary push button switch, and the Arduino.

The idea is that the hat wearer can broadcast 3 different moods. By pushing the button, he or she can turn on either the red, blue, or green diode of the LED. Blue = sad, green = happy, and red = angry. Using the potetniometer, the wearer can adjust the brighness of the LED, and this corresponds directly to the intensity of the mood. The brighter the light, the sadder, angrier, or happier the wearer.

The LED, embedded in the brim of the hat, has one cathode and three anodes (one each for red, green, and blue). Each of the anodes is connected to a PWM pin on the Arduino so the brightness can be controlled by an analog input. The push button and potentionmeter are  also mounted on the brim.

After powering up the Arduino, the LED is off. Pressing the button twice will illuminate the blue  diode. Two more button presses turns off the blue diode and illuminates the green diode. Two more presses and the green diode is turned off and the red diode is turned on. Finally, two more button presses turns of the LED completely, and you are back at the beginning of the cycle. During this entire loop, the brightness of the LED is controlled by the potentiometer, which is acting as an analog input into the Arduino.

Below is the code, and below the code is a photo gallery of the finished project.

/*
This is a program used to control a tri-color LED (or three LEDs) with a push button swtich.
The push button turns the various colors (or LEDS) on and off, and the potentiometer controls the brightness

By Rich Pantaleo
Adapted from Greg Saul's 'Button' code, presented during a 'Making Things Interactive' lecture in September 2008

*/

int blueled = 11; // choose the pin for the blue LED
int redled = 10; // choose the pin for the red LED
int greenled = 9; // choose the pin for the green LED
int inputPin = 3; // choose the input pin for the push button
int potPin = 5 ; // analog input pin for potentiometer
int potVal = 0 ; // value from potentiometer
int buttonstatus = 0; // variable for reading the pin status
int counter = 0; // store the number of button presses
boolean buttonDown = false; // a flag that stores if the button is beeing pressed down or not

void setup() {
pinMode(blueled, OUTPUT); // declare blue LED as output
pinMode(redled, OUTPUT); // declare red LED as output
pinMode(greenled, OUTPUT); // delcare green LED as output
pinMode(inputPin, INPUT); // declare pushbutton as input
digitalWrite(blueled, LOW); // turn Blue LED OFF
digitalWrite(redled, LOW); // turn Red LED OFF
digitalWrite(greenled, LOW); // turn Green LED OFF
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps

}

void loop(){

potVal = analogRead(potPin); //Read the potentiometer input
buttonstatus = digitalRead(inputPin); // read input value from button

if (buttonstatus == HIGH && buttonDown == false) { // check if the input is HIGH and the button is not already been held down
buttonDown = true; // set the button flag to down
counter = counter +1; // add one to the counter
Serial.println(counter); // send the current counter value to the computer
}

if (buttonstatus == LOW){ // if we are no longer pressing the button down
buttonDown = false; // set the buttonDown value to up
}

if(counter == 2 || counter == 3){ // After the button has been pressed twice
analogWrite(blueled, potVal/3); // Turn on the blue LED to a value equal to the input from the potentiometer divided by 3
}
if(counter == 4 || counter == 5){ // After two more button presses
analogWrite(blueled, 0); // Turn off the blue LED
analogWrite(greenled, potVal/3); // Turn on the green LED to a value equal to the input from the potentiometer divided by 3
}
if(counter == 6 || counter == 7){ // After two more button presses
analogWrite(greenled, 0); // Turn off the green LED
analogWrite(redled, potVal/3); // Turn on the red LED to a value equal to the input from the potentiometer divided by 3
}
if (counter > 7){ // After two more button presses
analogWrite(redled, 0); // Turn off the red LED
counter = 0; // Set the counter back to 0
}

}

Turn signal hat

The guts of the turn signal hat

For the first assignment of embedding LEDs and switches in clothing, I chose to make a hat with a built in turn signal.

Two red LEDs were used, each placed in on the back of the hat, one on the left side of the wearer’s head and one on the right side. Throwing the switch to the left or right causes the corresponding left or right LED to blink, thus signaling to those behind the wearer the direction the wearer intends to turn.

A 3-position toggle switch activates the LEDs. A piece of plastic is attached to the switch to create a turn signal lever, like one might find in a car or truck. For example, In the configuration shown to the left, pushing the lever away from the wearer moves the switch to the wearer’s right, thus causing the right LED to blink. Moving the switch to the center position turns the LED off.

The circuit is based on the switch with pull-up resistor example done in class. The left and right pins of the switch are each connected to their own digital pin on the Arduino, and each LED is connected to its own digital pin as well. The program that runs the hat checks if a digital input is HIGH or LOW, and either turns off the LED or begins the LED blinking cycle. Click here to download the code used to control the turn signal hat (.pde file for arduino)

See below for a few more pictures of the hat.