Blink Homework / Fabiola

I decided to hook up the Sharp optical dust sensor that I bought from Sparkfun last week, to visualize the invisible through a wonderful little LED. This might lead to a “dust painting” that I wanted to make so that people with asthma can in a more aesthetically pleasing way be aware of their air quality in the home and get motivated to keep their space clean. However, through my exploration, I realized that it’s very difficult to motivate though a passive object that lives separately from you. So why not bring it closer to the body? If I succeed in miniaturizing the electronics, I would love to develop this into some sort of dust earring that lights up when the air around you is poor, in the form factor of a water drop in glass.

The sensor did not come with the appropriate cables, so order them as well if you are thinking about using the device. The output surface is very small, and although I could solder it, I was afraid to destroy the device so copper tape became my temporary solution.

Screen Shot 2014-09-11 at 11.38.06 PM

I started by looking at the spec sheet, but it didn’t give a rookie too much information so scattered the internet for a good tutorial. I ended up following this one,  and had some problems following the schematic at first, but with some help it became apparent that some of the symbols in the schematic are not universal.

For the schematics below I used a placeholder for the dust sensor since it is not available in Fritzing, and neither could I find a download.

Screen Shot 2014-09-24 at 4.46.38 PM

Screen Shot 2014-10-31 at 3.20.35 PM

Screen Shot 2014-10-31 at 3.22.22 PM

As you can see I’m using a different connector in place of the dust sensor. The image below will give you a better understanding of how to hook it up.


Below is a test with the sensor in D12, set to blink every time the value hits over 225.

I was surprised by the accuracy actually, and found this article comparing a pretty advanced system with good results. I also discovered that D12 has much better air quality than my apartment.

Update: Now the RGB LED works! Blue equals best air quality (0-225), green equals ok quality (225-500) and red equals bad quality (500 and above). Below I’m blowing smoke over it.

// Code slightly modified from this tutorial.

int dustPin=0;
int dustVal=0;
int redVal = 0;
int blueVal = 0;
int greenVal = 0;

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

int ledPower=2;

int delayTime=280;

int delayTime2=40;

float offTime=9680;
void setup(){

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

void loop(){

digitalWrite(BLUE, 255); // turn the LED off by making the voltage LOW
digitalWrite(GREEN, 255); // turn the LED off by making the voltage LOW
digitalWrite(RED, 255); // turn the LED off by making the voltage LOW

// ledPower is any digital pin on the arduino connected to Pin 3 on the sensor

if (dustVal < 224) {
digitalWrite(BLUE, 0);
delay(1000); // wait for a second

if (dustVal > 225 && dustVal < 500) {
digitalWrite(GREEN, LOW); // turn the LED off by making the voltage LOW

if (dustVal > 501) {
digitalWrite(RED, 0);
delay(1000); // wait for a second

digitalWrite(ledPower, LOW); // power on the LED
dustVal=analogRead(dustPin); // read the dust value via pin 5 on the sensor
digitalWrite(ledPower,HIGH); // turn the LED off




Leave a Reply

Your email address will not be published.