Project 2: Automated Chair

This project came about by me wanting to use conductive paint as I saw it as something different and more enjoyable for user experience. After brainstorming some ideas I came up with creating an automated chair with painted controls.

I then split the parts into 3 sections to make it easier to get working; part one was a servo arm cup holder controlled by a paint potentiometer, part two is a fan controlled by temperature of the user or room, and part 3 was a seat sensor to trigger lights and let everyone know you are in your throne. Then I combined the parts knowing that they all worked individually.

Photo 15-04-2015 00 17 30

Part 1: Paint potentiometer controlled servo

I found this from a tutorial by bare conductive, the company that produce the paint, on their youtube channel that explained how to create a potentiometer using the conductive paint.

I then added in the servo code so that the paint would control its movement.

Code

#include Servo myservo; // create servo object to control a servo

int potpin = 0; // analog pin used to connect the potentiometer

int val; // variable to read the value from the analog pin

void setup()

{

myservo.attach(9); // attaches the servo on pin 9 to the servo object

}

void loop()

{

val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)

val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)

myservo.write(val); // sets the servo position according to the scaled value

delay(15); // waits for the servo to get there

}

Circuit Layout

knob_bb

Working Part

Part 2: Temperature sensor Controlled Fans

The second step I took was creating the section of code and layout for fans controlled by a temperature sensor. Firstly i set up the code to get the fans running when the power was plugged in.

Then I added in the code for the Temp sensor readings and added the necessary components to the circuit board.

Circuit Layout

temp sesnsor fans_bb

– 2 DC Fans

– Temperature sensor

– Jumper wires

Code

int pin = 5;

int fan = 12;

int fan2 = 13;

void setup()

{

Serial.begin(9600);

pinMode(pin, INPUT);

pinMode(fan, OUTPUT);

}

void loop()

{

int reading = analogRead(pin);

reading = map(reading, 0, 1023, 0, 100);

Serial.println(reading);

if(reading >=15)

{

Serial.println(“FAN ON”);

digitalWrite(fan, HIGH);

digitalWrite(fan2,HIGH);

}

else

{

Serial.println(“FAN OFF”);

digitalWrite(fan,LOW);

digitalWrite(fan2,LOW);

}

delay(1000);

}

Working circuit

Part 3: Touch sensor with LEDs

This section is based off another bare paint tutorial for a capacitive sensor, and using the examples from the Cap Sense library download from Arduion website ( http://playground.arduino.cc/Main/CapacitiveSensor?from=Main.CapSense ) I added LED’s to the circuit and made it a touch sensor.

After using the setup from this tutorial I added a basic LED setup and used the arduino library code.

Code

#include CapacitiveSensor cs_4_2 = CapacitiveSensor(4,2); // 10M resistor between pins 4 & 2, pin 2 is sensor pin

// add a wire and or foil if desired

int receivePin = 2;

int sendPin = 4;

int ledPin1 = 10;

int ledPin2 = 9;

void setup()

{

cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF); // above: turn off autocalibrate on channel 1 – just as an example

Serial.begin(9600);

pinMode(ledPin1, OUTPUT);

pinMode(ledPin2, OUTPUT);

}

void loop()

{

long start = millis();

long total = cs_4_2.capacitiveSensor(30);

Serial.print(millis() – start); // check on performance in milliseconds Serial.print(“\t”); // tab character for debug windown spacing

Serial.print(total); // print sensor output

Serial.println(); // parameters to set level for PWM output

float level1;

float level2;

float threshold1 = 0;

float threshold2 = 100;

float max = 3000;

if (total < threshold1)

{

level1 = 0;

}

else

{

level1= map(total,threshold1,max,0,1023);

}

if (total < threshold2)

{

level2 = 0;

}

else

{

level2= map(total,threshold2,max,0,1023);

}

analogWrite(ledPin1,level1);

analogWrite(ledPin2,level2);

delay(1); // arbitrary delay to limit data to serial port

}

Circuit Layout

capacitive sensor with leds

Working circuit

Combining all the parts

I then went about adding the three sections together one at a time to reduce errors and make it easier to iron out the bugs. I started with the paint potentiometer servo and the temperature sensor fans, combining the code to start.

Code for paint servo with temp sensor fans

#include Servo myservo; // create servo object to control a servo

int pin = 5;

int fan = 12;

int fan2 = 13;

int potpin = 0; // analog pin used to connect the potentiometer

int val; // variable to read the value from the analog pin

void setup()

{

Serial.begin(9600);

pinMode(pin, INPUT);

pinMode(fan, OUTPUT);

myservo.attach(6);

}

void loop()

{

val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)

val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)

myservo.write(val); // sets the servo position according to the scaled value

delay(15);

int reading = analogRead(pin);

reading = map(reading, 0, 1023, 0, 100);

Serial.println(reading);

if(reading >=15)

{

Serial.println(“FAN ON”);

digitalWrite(fan, HIGH);

digitalWrite(fan2,HIGH);

}

else

{

Serial.println(“FAN OFF”);

digitalWrite(fan,LOW);

digitalWrite(fan2,LOW);

}

delay(1000);

}

Circuit layout

I then combined the two circuits

temp sesnsor fans and pot servo_bb

Working circuit

After these two were running together I added in the touch sensor to the code and circuit board.

Final Code #include #include CapacitiveSensor cs_4_2 = CapacitiveSensor(4,2);

Servo myservo; // create servo object to control a servo

int pin = 5;

int fan = 12;

int fan2 = 13;

int potpin = 0; // analog pin used to connect the potentiometer

int val; // variable to read the value from the analog pin

int receivePin = 2;

int sendPin = 4;

int ledPin1 = 10;

int ledPin2 = 9;

void setup()

{

Serial.begin(9600);

pinMode(pin, INPUT);

pinMode(fan, OUTPUT);

myservo.attach(6);

cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF); // above: turn off autocalibrate on channel 1 – just as an example

Serial.begin(9600);

pinMode(ledPin1, OUTPUT);

pinMode(ledPin2, OUTPUT);

}

void loop()

{

long start = millis();

long total = cs_4_2.capacitiveSensor(30);

float level1;

float level2;

float threshold1 = 0;

float threshold2 = 100;

float max = 3000;

if (total < threshold1)

{

level1 = 0;

}

else

{

level1= map(total,threshold1,max,0,1023);

}

if (total < threshold2)

{

level2 = 0;

}

else

{

level2= map(total,threshold2,max,0,1023);

}

analogWrite(ledPin1,level1);

analogWrite(ledPin2,level2);

delay(1);

val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)

val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)

myservo.write(val); // sets the servo position according to the scaled value

delay(15);

int reading = analogRead(pin);

reading = map(reading, 0, 1023, 0, 100);

Serial.println(reading);

if(reading >=15)

{

Serial.println(“FAN ON”);

digitalWrite(fan, HIGH);

digitalWrite(fan2,HIGH);

}

else

{

Serial.println(“FAN OFF”);

digitalWrite(fan,LOW);

digitalWrite(fan2,LOW);

}

delay(1000);

}

Complete Circuit layout

project 2_bb

Final Product

Photo 15-04-2015 00 17 30

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s