Dust sensor

The Sharp’s GP2Y1010AU0F dust sensor is worth a play.

I followed the instructions from http://sensorapp.net/?p=479 for connecting.
Substituted used 150ohm, and 183uf 25v capacitor for the 250uf in the circuit.

Seemed to work.

Programs follow

int dustPin=0;
int dustVal=0;

int ledPower=2;
int delayTime=280;
int delayTime2=40;
float offTime=9680;
void setup(){
pinMode(4, OUTPUT);

void loop(){
// ledPower is any digital pin on the arduino connected to Pin 3 on the sensor
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


Processing Code

// Graphing sketch

// Created 20 Apr 2005
// Updated 18 Jan 2008
// by Tom Igor
//edited using http://arduinobasics.blogspot.co.uk/2012/07/arduino-basics-simple-arduino-serial_09.html to make it work 
// This example code is in the public domain.

import processing.serial.*;

Serial myPort; // The serial port
int xPos = 1; // horizontal position of the graph

void setup () {
// set the window size:
size(400, 300); 

// List all the available serial ports
// I know that the first port in the serial list on my mac
// is always my Arduino, so I open Serial.list()[0].
// Open whatever port is the one you're using.
myPort = new Serial(this, Serial.list()[0], 9600);
// don't generate a serialEvent() unless you get a newline character:
// set inital background:
void draw () {
// everything happens in the serialEvent()

void serialEvent (Serial myPort) {
// get the ASCII string:
//String inString = myPort.readStringUntil('\n');
String inString = new String(myPort.readBytesUntil('\n'));
if (inString != null) {
// trim off any whitespace:
inString = trim(inString);
// convert to an int and map to the screen height:
float inByte = float(inString); 
inByte = map(inByte, 0, 1023, 0, height);

// draw the line:
line(xPos, height, xPos, height - inByte);

// at the edge of the screen, go back to the beginning:
if (xPos >= width) {
xPos = 0;
else {
// increment the horizontal position:


Leave a Reply

Your email address will not be published. Required fields are marked *