Click the link below and....Get Sparked!

Thursday, February 11, 2010

Arduino Simple Moisture Tester



This is a simple Moisture Tester that I made using an Arduino MEGA, a 10 Element Bar Graph LED Array (Part Number: HDSP-4832), and some Galvanized Nails as sensor probes.

Essentially, the Arduino measures the resistance between the nails and sends that data to the code which determines how many LED's to light up. The higher the number, the more LED's light up. Simple!

Here's a picture of the circuit.



And a screenshot of the Serial Monitor output from the Arduino Code:



And here's the code:
------------------------------



// Arduino Simple Moisture Tester
// By Paul D'Intino
// Feb 11 2010

//initialize values
int moistureSensor = 0;
int moisture_val;
int lightSwitch1 = 35;
int lightSwitch2 = 37;
int lightSwitch3 = 39;
int lightSwitch4 = 41;
int lightSwitch5 = 43;
int lightSwitch6 = 45;
int lightSwitch7 = 47;
int lightSwitch8 = 49;
int lightSwitch9 = 51;
int lightSwitch10 = 53;


void setup() {
Serial.begin(9600); //open serial port

//setup Digital pins as Outputs
pinMode (lightSwitch1, OUTPUT);
pinMode (lightSwitch2, OUTPUT);
pinMode (lightSwitch3, OUTPUT);
pinMode (lightSwitch4, OUTPUT);
pinMode (lightSwitch5, OUTPUT);
pinMode (lightSwitch6, OUTPUT);
pinMode (lightSwitch7, OUTPUT);
pinMode (lightSwitch8, OUTPUT);
pinMode (lightSwitch9, OUTPUT);
pinMode (lightSwitch10, OUTPUT);

//set all the LEDS to OFF on startup

digitalWrite (lightSwitch1, LOW);
digitalWrite (lightSwitch2, LOW);
digitalWrite (lightSwitch3, LOW);
digitalWrite (lightSwitch4, LOW);
digitalWrite (lightSwitch5, LOW);
digitalWrite (lightSwitch6, LOW);
digitalWrite (lightSwitch7, LOW);
digitalWrite (lightSwitch8, LOW);
digitalWrite (lightSwitch9, LOW);
digitalWrite (lightSwitch10, LOW);
}

void loop() {
moisture_val = analogRead(moistureSensor); // read the value from the moisture-sensing probes
Serial.print("moisture sensor reads "); //output the value from the sensors
Serial.println( moisture_val );

//Step 1 - setup the maximum value with all LEDS on
if (moisture_val >= 1000 )
{
digitalWrite(lightSwitch1, HIGH);
digitalWrite(lightSwitch2, HIGH);
digitalWrite(lightSwitch3, HIGH);
digitalWrite(lightSwitch4, HIGH);
digitalWrite(lightSwitch5, HIGH);
digitalWrite(lightSwitch6, HIGH);
digitalWrite(lightSwitch7, HIGH);
digitalWrite(lightSwitch8, HIGH);
digitalWrite(lightSwitch9, HIGH);
digitalWrite(lightSwitch10, HIGH);
delay(10);
}

//Step 2
else if (moisture_val >= 800 && moisture_val <= 900 )
{
digitalWrite(lightSwitch1, HIGH);
digitalWrite(lightSwitch2, HIGH);
digitalWrite(lightSwitch3, HIGH);
digitalWrite(lightSwitch4, HIGH);
digitalWrite(lightSwitch5, HIGH);
digitalWrite(lightSwitch6, HIGH);
digitalWrite(lightSwitch7, HIGH);
digitalWrite(lightSwitch8, HIGH);
digitalWrite(lightSwitch9, HIGH);
digitalWrite(lightSwitch10, LOW);
delay(10);
}

//Step 3
else if (moisture_val >= 700 && moisture_val <= 800 )
{
digitalWrite(lightSwitch1, HIGH);
digitalWrite(lightSwitch2, HIGH);
digitalWrite(lightSwitch3, HIGH);
digitalWrite(lightSwitch4, HIGH);
digitalWrite(lightSwitch5, HIGH);
digitalWrite(lightSwitch6, HIGH);
digitalWrite(lightSwitch7, HIGH);
digitalWrite(lightSwitch8, HIGH);
digitalWrite(lightSwitch9, LOW);
digitalWrite(lightSwitch10, LOW);
delay(10);
}


//Step 4
else if (moisture_val >= 600 && moisture_val <= 700 )
{
digitalWrite(lightSwitch1, HIGH);
digitalWrite(lightSwitch2, HIGH);
digitalWrite(lightSwitch3, HIGH);
digitalWrite(lightSwitch4, HIGH);
digitalWrite(lightSwitch5, HIGH);
digitalWrite(lightSwitch6, HIGH);
digitalWrite(lightSwitch7, HIGH);
digitalWrite(lightSwitch8, LOW);
digitalWrite(lightSwitch9, LOW);
digitalWrite(lightSwitch10, LOW);
delay(10);
}


//Step 5
else if (moisture_val >= 500 && moisture_val <= 600 )
{
digitalWrite(lightSwitch1, HIGH);
digitalWrite(lightSwitch2, HIGH);
digitalWrite(lightSwitch3, HIGH);
digitalWrite(lightSwitch4, HIGH);
digitalWrite(lightSwitch5, HIGH);
digitalWrite(lightSwitch6, HIGH);
digitalWrite(lightSwitch7, LOW);
digitalWrite(lightSwitch8, LOW);
digitalWrite(lightSwitch9, LOW);
digitalWrite(lightSwitch10, LOW);
delay(10);
}


//Step 6
else if (moisture_val >= 400 && moisture_val <= 500 )
{
digitalWrite(lightSwitch1, HIGH);
digitalWrite(lightSwitch2, HIGH);
digitalWrite(lightSwitch3, HIGH);
digitalWrite(lightSwitch4, HIGH);
digitalWrite(lightSwitch5, HIGH);
digitalWrite(lightSwitch6, LOW);
digitalWrite(lightSwitch7, LOW);
digitalWrite(lightSwitch8, LOW);
digitalWrite(lightSwitch9, LOW);
digitalWrite(lightSwitch10, LOW);
delay(10);
}

//Step 7
else if (moisture_val >= 300 && moisture_val <= 400 )
{
digitalWrite(lightSwitch1, HIGH);
digitalWrite(lightSwitch2, HIGH);
digitalWrite(lightSwitch3, HIGH);
digitalWrite(lightSwitch4, HIGH);
digitalWrite(lightSwitch5, LOW);
digitalWrite(lightSwitch6, LOW);
digitalWrite(lightSwitch7, LOW);
digitalWrite(lightSwitch8, LOW);
digitalWrite(lightSwitch9, LOW);
digitalWrite(lightSwitch10, LOW);
delay(10);
}

//Step 8
else if (moisture_val >= 200 && moisture_val <= 300 )
{
digitalWrite(lightSwitch1, HIGH);
digitalWrite(lightSwitch2, HIGH);
digitalWrite(lightSwitch3, HIGH);
digitalWrite(lightSwitch4, LOW);
digitalWrite(lightSwitch5, LOW);
digitalWrite(lightSwitch6, LOW);
digitalWrite(lightSwitch7, LOW);
digitalWrite(lightSwitch8, LOW);
digitalWrite(lightSwitch9, LOW);
digitalWrite(lightSwitch10, LOW);
delay(10);
}

//Step 9
else if (moisture_val >= 100 && moisture_val <= 200 )
{
digitalWrite(lightSwitch1, HIGH);
digitalWrite(lightSwitch2, HIGH);
digitalWrite(lightSwitch3, LOW);
digitalWrite(lightSwitch4, LOW);
digitalWrite(lightSwitch5, LOW);
digitalWrite(lightSwitch6, LOW);
digitalWrite(lightSwitch7, LOW);
digitalWrite(lightSwitch8, LOW);
digitalWrite(lightSwitch9, LOW);
digitalWrite(lightSwitch10, LOW);
delay(10);
}

//Step10 - setup the minimum value with all LEDS off but one Red LED.


else
{
digitalWrite(lightSwitch1, HIGH);
digitalWrite(lightSwitch2, LOW);
digitalWrite(lightSwitch3, LOW);
digitalWrite(lightSwitch4, LOW);
digitalWrite(lightSwitch5, LOW);
digitalWrite(lightSwitch6, LOW);
digitalWrite(lightSwitch7, LOW);
digitalWrite(lightSwitch8, LOW);
digitalWrite(lightSwitch9, LOW);
digitalWrite(lightSwitch10, LOW);
delay(10);
}

}


Wednesday, February 3, 2010

MultiTouch using IR Pen & WorldWind JAVA - Concept Test 1



This is the first Concept Test of a Multi-touch device using only 1 IR Pen.

Ordinary 'single' touch controls are possible when the IR Pen is touching the screen, and also Multi-touch 'pinch' gestures for zooming by brining the IR Pen closer or further away from the screen.


.

Tuesday, February 2, 2010

PS3 Eye Lens Test

With my portable 17" Multi-touch screen I recently built, I have been using the 2.1mm FishEye lens on my PS3 Eye camera with great success.

I have just started a 32" DSI setup and the 2.1mm lens is too distorted to detect blobs on the edge of the screen.

So I recently bought a pack of 6 lenses from DealExtreme to try different angles.
The product is called "2.8mm~16mm Fixed IRIS Lens Set for Webcams and Security/CCTV Cameras (6-Lens Pack)" and it costs USD$14.91.



I have posted a screenshot below of the output from the PS3 Eye using the different lenses.