Click the link below and....Get Sparked!
Showing posts with label Arduino. Show all posts
Showing posts with label Arduino. Show all posts
Monday, March 18, 2013
SMS Alert Flow Switch
Although I have been quiet lately on my blog, I have been working on a few projects. One of which is an SMS alert system for a friends pump shed for his farm.
This system is pretty straight forward and not overly complicated, however there were some requirements that made the code a bit tricky to sort out. Uses an Arduino UNO and an GPRS Shield. Total cost around AU$150. Anyway, here is the final result.


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);
}
}
Sunday, November 22, 2009
Arduino & Servo Control Using The Mouse
After the iPhone & Arduino project, I wanted to try some mechanical objects with the Arduino MEGA. This is the first test of controlling a Servo connected to the Arduino MEGA by moving the mouse.
The mouse X axis is read by a Processing Sketch and then sent to the arduino to tell the servo to rotate.
I have updated the code to include Y axis, however I only have 1 servo at the moment =P
I will post a new video once I have received more servos...
UPDATE: Here are the Processing and Arduino source codes for this project:
Arduino
ServoAppArduino.pde(File Size: 755 Bytes - Downloads:
Processing
ServoAppTest1.pde(File Size: 1.31KB - Downloads:
Enjoy!
Saturday, November 21, 2009
iPhone & Arduino: Controlling 2 LED's Using WiFi
Ok so it's been quite a while between posts.
I've been working on some projects using the Arduino MEGA.
In this example I've used the iPhone connected to Arduino via WiFi using a custom layout from TouchOSC to control the Green and Red LED's. The application sending information to the Arduino is Processing.
Sunday, August 2, 2009
Arduino TouchScreen Test 1
This is a simple test of a 4-Wire resistive touchscreen connected to an Arduino MEGA running a simple Paint application that I wrote in Processing.
The Arduino code was based on the code from this website:
http://mnicolato.altervista.org/arduino/ardtouch.htm
(The website will need translation, however, the video and code are there)
Below is the Processing code for the Arduino Touch Screen Paint application I wrote for the above video...
Enjoy!
The processing app I wrote is a derivative of the Virtual Color Mixer code found here:
http://www.arduino.cc/en/Tutorial/VirtualColorMixer
Stay tuned for more shortly....
The Arduino code was based on the code from this website:
http://mnicolato.altervista.org/arduino/ardtouch.htm
(The website will need translation, however, the video and code are there)
Below is the Processing code for the Arduino Touch Screen Paint application I wrote for the above video...
Enjoy!
// Touch Screen Paint v1.1
// This example takes in a serial string of comma-separated values
// from a 4-Wire Resistive touch screen (0 to 1023), maps them to the range
// 0 to 480 or 0 to 800 of x,y values, and uses them to draw a line on the screen.
// By
// Paul D'Intino
import processing.serial.*;
float xPos = 0; // touch screen x value
float yPos = 0; // touch screen y value
Serial myPort;
void setup() {
size(800, 480); //define the size of the Paint window
background(0); //set the background to black
// List all the available serial ports
println(Serial.list());
// Open whatever port is the one you're using.
myPort = new Serial(this, Serial.list()[2], 9600);
// don't generate a serialEvent() unless you get a new line character:
myPort.bufferUntil('\n');
}
void draw() {
}
void serialEvent(Serial myPort) {
// get the ASCII string:
String inString = myPort.readStringUntil('\n');
//background(0);
if (inString != null) {
// trim off any whitespace:
inString = trim(inString);
// split the string on the commas and convert the
// resulting substrings into an integer array:
float[] sensor = float(split(inString, ","));
// if the array has at least three elements, you know
// you got the whole thing. Put the numbers in the
// color variables:
if (sensor.length >=2) {
// map them to the range 0-255:
xPos = map(sensor[0], 0, 1023, 0, 480);
yPos = map(sensor[1], 0, 1023, 0, 800);
//define the stroke and fill color of the circle
stroke(0,255,0); //green (R,G,B)
fill(0,255,0); //green (R,G,B)
//draw the circle at the touch screen sensor x and y position
ellipse(yPos,xPos,10,10);
//print the serial x,y data for debugging purposes only
println(inString);
}
}
}
The processing app I wrote is a derivative of the Virtual Color Mixer code found here:
http://www.arduino.cc/en/Tutorial/VirtualColorMixer
Stay tuned for more shortly....
Subscribe to:
Posts (Atom)