Flowers and Carbon Monoxide

by renee.reaves.3 in Circuits > Tools

682 Views, 0 Favorites, 0 Comments

Flowers and Carbon Monoxide

20150428_203829-1.jpeg

I wanted to create a fun way to integrate a household decoration and a Carbon Monoxide detector. I didn't want the device to scream like most alarms do, I wanted it to be subtle. This is why I chose to do a flower arrangement and RGB led. Tell me what you guys think and enjoy!

Gather Your Tools

ArduinoUnoSmd450px.jpg

Things You will need:

Arduino

Carbon Monoxide Sensor MQ-7 (ordered off of Amazon)

RGB led's (common anthode)

Soldering Iron/Solder

Bread Board/Solder Board (copper board)

Wire Cutters/Strippers

Small pliers

male wires

1k resistors (at least 2)

*two pinches of patience*

Step 2: Testing Your Devices

20150408_134331.jpeg
20150420_135715-1.jpeg

First you want to test your add ons (RGB led and Carbon Monoxide sensor). Just to make sure they work, because of they don't work you might have to re-order your devices.

Here is the code I used to test my RGB:

#define GREEN 3
#define BLUE 5 #define RED 6 #define delayTime 20

void setup() {

pinMode(GREEN, OUTPUT); pinMode(BLUE, OUTPUT); pinMode(RED, OUTPUT); digitalWrite(GREEN, HIGH); digitalWrite(BLUE, HIGH); digitalWrite(RED, HIGH); }

int redVal; int blueVal; int greenVal; void loop() { int redVal = 255; int blueVal = 0; int greenVal = 0; for( int i = 0 ; i < 255 ; i += 1 ){ greenVal += 1; redVal -= 1; analogWrite( GREEN, 255 - greenVal ); analogWrite( RED, 255 - redVal );

delay( delayTime ); } redVal = 0; blueVal = 0; greenVal = 255; for( int i = 0 ; i < 255 ; i += 1 ){ blueVal += 1; greenVal -= 1; analogWrite( BLUE, 255 - blueVal ); analogWrite( GREEN, 255 - greenVal );

delay( delayTime ); } redVal = 0; blueVal = 255; greenVal = 0; for( int i = 0 ; i < 255 ; i += 1 ){ redVal += 1; blueVal -= 1; analogWrite( RED, 255 - redVal ); analogWrite( BLUE, 255 - blueVal );

delay( delayTime ); } }

Here is the code I used to test my sensor:

// Digital pin 8 will be called 'pin8'
int pin8 = 8; // Analog pin 0 will be called 'sensor' int sensor = A0; // Set the initial sensorValue to 0 int sensorValue = 0;

// The setup routine runs once when you press reset void setup() { // Initialize the digital pin 8 as an output pinMode(pin8, OUTPUT); // Initialize serial communication at 9600 bits per second Serial.begin(9600); }

// The loop routine runs over and over again forever void loop() { // Read the input on analog pin 0 (named 'sensor') sensorValue = analogRead(sensor); // Print out the value you read Serial.println(sensorValue, DEC); // If sensorValue is greater than 500 if (sensorValue > 500) { // Activate digital output pin 8 - the LED will light up digitalWrite(pin8, HIGH); } else { // Deactivate digital output pin 8 - the LED will not light up digitalWrite(pin8, LOW); }

}

Step 3: Code

#define BLUE 5

#define RED 6 #define delayTime 20 int redVal; int blueVal;

// Analog pin 0 will be called 'sensor' int sensor = A0; // Set the initial sensorValue to 0 int sensorValue = 0; // The setup routine runs once when you press reset void setup() { pinMode(BLUE, OUTPUT); pinMode(RED, OUTPUT); digitalWrite(BLUE, LOW); digitalWrite(RED, LOW);

// Initialize serial communication at 9600 bits per second Serial.begin(9600); }

// The loop routine runs over and over again forever void loop() { // Read the input on analog pin 0 (named 'sensor') sensorValue = analogRead(sensor); // Print out the value you read Serial.println(sensorValue, DEC); // If sensorValue is greater than 500 // if (sensorValue <= 220) { // digitalWrite(BLUE, LOW); // } // else { // // Deactivate digital output pin 8 - the LED will not light up // digitalWrite(BLUE, HIGH); // if (sensorValue >= 220) { // digitalWrite(RED, LOW); // } // else { // // Deactivate digital output pin 8 - the LED will not light up // digitalWrite(RED, HIGH); // } // }

redVal =255-map(sensorValue,200,250, 0,255); blueVal =map(sensorValue,200,250,0,255);

analogWrite(BLUE, blueVal); analogWrite(RED, redVal); }

Step 4: Solder Time

After you have tested and you are sure your set-up of the Arduino works it is time to solder your device together.

It should look something like this (depending on how you set up your copper board):

*pictures coming soon I promise*

What Is the Code Saying?

Basically the code is talking to the Arduino board and telling the sensor when it detects Carbon Monoxide change color. In my case I used a RGB led and I only used the red and blue legs. So when the levels reach the number calibrated on my sensor the LED will turn red and when the levels are "normal" the light will turn blue. If there is a little Monoxide catching the sensor the LED will turn a purplish, pink color.

Step 5: Make It Cool

20150429_135214-1.jpeg
20150429_135614.jpeg
20150429_135347.jpeg

Last step is to put your finished working sensor into something cool. It can be whatever form you like just be careful to not cover your sensor too much or it wont be able to read Carbon Monoxide. I choose to make mine look like a bouquet of flowers, that someone could easily decorate there homes with. It doesn't matter what it is as long as the sensor does its job. Let's get creative!