# Sensor Crane

631

6

2

This instructable was created in fulfillment of the project requirement of the Makecourse at the University of South Florida (www.makecourse.com).

The sensor crane is a design that utilizes capacitance sensing technology in order to direct the motion of load control. The concept behind this is to generate an RC circuit with a few household products and to analyze the charge time of this circuit with the help of the Arduino Uno. Most parts selected were merely out of convenience.

### Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

## Step 1: Parts

The core of this project revolves around the following pieces:

1. Arduino Uno
2. 1x 10 Megaohm Resistor
3. 1x 220 Ohm Resistor
4. 1x Set of alligator clamps
5. Step Motor 28BYJ-48 + Shield
6. 3D printed Crane Parts
7. Aluminum Foil
8. Cardboard
9. String

## Step 2: Function

Here we see the function block diagram. The hand forms a capacitor with the aluminum foil: effectively storing a charge from the Arduino signal sent to the foil. The Arduino measures the time it takes for the capacitor to charge. The Arduino uses this information and initiates the stepper motor in either direction accordingly.

## Step 3: Layout

This is the circuit layout. Simply put, we have a wire feeding into the aluminum foil with a 10 Megaohm resistor. This is known as the send pin; the pin that allows the capacitor to begin storing energy. The receiving pin is attached with a small resistor (such as the listed 220 Ohm resistor) in order to prevent er. The Arduino is then attached to a SHIELDED stepper motor to protect the Arduino. NOTE: The shield is not shown in the image above.

## Step 4: Code

The following code is used in order to control the motor based on the RC circuit design. The CapacitiveSensor Library is used in order to simplify the sensing process. You can find and download this library here. The comments in the code will hopefully illuminate the code's purpose.

```#include CapacitiveSensor   cs_4_6 = CapacitiveSensor(4,6);        // 10M resistor between pins 4 & 6. Pin 4 is the signal pin and pin 6 is the sensor pin.#define pin1  12//these are the Arduino pins that we use to activate coils 1-4 of the stepper motor
#define pin2  13
#define pin3  10
#define pin4  11
#define delaytime x   //delay time in ms to control the stepper motor delaytime.int x = 8;//8 is about the fastest that can yield reliable operation without missing steps
void Step_A(){
digitalWrite(pin1, HIGH);//turn on coil 1
digitalWrite(pin2, LOW);
digitalWrite(pin3, LOW);
digitalWrite(pin4, LOW);
}
void Step_B(){
digitalWrite(pin1, LOW);
digitalWrite(pin2, HIGH);//turn on coil 2
digitalWrite(pin3, LOW);
digitalWrite(pin4, LOW);
}
void Step_C(){
digitalWrite(pin1, LOW);
digitalWrite(pin2, LOW);
digitalWrite(pin3, HIGH); //turn on coil 3
digitalWrite(pin4, LOW);
}
void Step_D(){
digitalWrite(pin1, LOW);
digitalWrite(pin2, LOW);
digitalWrite(pin3, LOW);
digitalWrite(pin4, HIGH); //turn on coil 4
}
void step_OFF(){
digitalWrite(pin1, LOW); //power all coils down
digitalWrite(pin2, LOW);
digitalWrite(pin3, LOW);
digitalWrite(pin4, LOW);
}//these functions run the above configurations in forward and reverse order
//the direction of a stepper motor depends on the order in which the coils are turned on.
void forward(){//one tooth forward
step_OFF();
long total2 = cs_4_6.capacitiveSensor(30);
Serial.print(total2);                  // serial print sensor output 2. This is necessary to ensure the signal is being updated initially.
Serial.print("\n");
delay(delaytime);
Step_A();
delay(delaytime);
Step_B();
delay(delaytime);
Step_C();
delay(delaytime);
Step_D();
delay(delaytime);}void backward(){//one tooth backward
step_OFF();
long total2 = cs_4_6.capacitiveSensor(30);
Serial.print(total2);                  // serial print sensor output 2. This is necessary to ensure the signal is being updated initially.
Serial.print("\n");
delay(delaytime);
Step_D();
delay(delaytime);
Step_C();
delay(delaytime);
Step_B();
delay(delaytime);
Step_A();
delay(delaytime);

}/***************************setup function****************************************************/void setup() {
Serial.begin(9600);//start serial communication
pinMode(pin1, OUTPUT); // initiate motor pins
pinMode(pin2, OUTPUT);
pinMode(pin3, OUTPUT);
pinMode(pin4, OUTPUT);}/***************************main loop*********************************************************/void loop() {
delaytime = x;
int numberOfSteps = 30;
long total2 = cs_4_6.capacitiveSensor(30);
Serial.print(total2);                  // print sensor output 2
Serial.print("\n");         if (total2 > 2000){             //Capacitive Sensing Conditional. NOTE: THESE THRESHOLD VALUES VARY WITH FOIL SIZE, RESISTOR SIZE AND OTHER VARIABLES. Be sure to test out these values prior to project construction.
while(numberOfSteps>0)             //After increasing by a certain threshold between two measuring periods, initiate stepper motor backward
{
backward();       //going backward
numberOfSteps --;}}

if (total2 < 500 && total2 > 150){     //If decreasing past a threshold, initiate stepper motor forward
while(numberOfSteps>0)
{
forward();       //going forward
numberOfSteps --;}}
if (total2 < 150){                      // This condition is made to ensure noise is kept our of the equation.
step_OFF();
}
delay(50);
}```

## Step 5: 3D Parts

The crane is developed in two parts: the base and mast and the jib and tower. Each part was taken care to fit together well (with hole and insert differences of a tenth of an inch). The crane itself is used to support a number of pounds, depending on the material it is printed with. The jib portion slides snug into the mast for simple attachment. The .stl files can be found attached.

## Recommendations

• ### Internet of Things Class

22,839 Enrolled

## 2 Discussions

what's the sensor use for