Show Posts
Pages: 1 [2] 3 4 ... 11
16  Using Arduino / Programming Questions / Re: Soil Moisture Sensor - Troubles! on: January 08, 2014, 06:34:49 pm
Try this simple sketch:
Code:
/*
  # Example code for the moisture sensor
  # Editor     : Lauren
  # Date       : 13.01.2012
  # Version    : 1.0
  # Connect the sensor analog out to the A0(Analog 0) pin on the Arduino board
  # Connect the sensor VCC pin to 5v pin on Arduino the board
  # Connect the sensor GND pin to GND pin on the Arduino board.
  # the sensor value description
  # 0  ~300     dry soil
  # 300~700     humid soil
  # 700~950     in water
*/

void setup(){
 
  Serial.begin(57600);
 
}

void loop(){
 
  Serial.print("Moisture Sensor Value:");
  Serial.println(analogRead(0)); 
  delay(100);
 
}
17  Using Arduino / Sensors / Re: corrosion proof electrode material for soil humidity sensor? on: January 08, 2014, 06:17:31 pm
Post a pic, could be salt or mineral build up from fertilizer in the soil.
18  Using Arduino / Project Guidance / Re: rotary encoder limiting on: January 08, 2014, 12:36:10 pm
Try this:
Code:
/* interrupt routine for Rotary Encoders


 The average rotary encoder has three pins, seen from front: A C B
 Clockwise rotation A(on)->B(on)->A(off)->B(off)
 CounterCW rotation B(on)->A(on)->B(off)->A(off)

 and may be a push switch with another two pins, pulled low at pin 8 in this case


 */

// usually the rotary encoders three pins have the ground pin in the middle
enum PinAssignments {
  encoderPinA = 2,   // right (labeled DT on our decoder, yellow wire)
  encoderPinB = 3,   // left (labeled CLK on our decoder, green wire)
  clearButton = 8    // switch (labeled SW on our decoder, orange wire)
                // connect the +5v and gnd appropriately
};

volatile byte encoderPos = 0;  // a counter for the dial
byte lastReportedPos = 1;   // change management
static boolean rotating = false;    // debounce management

// interrupt service routine vars
boolean A_set = false;
boolean B_set = false;

int pressCount = 0;

void setup() {

  pinMode(encoderPinA, INPUT_PULLUP); // new method of enabling pullups
  pinMode(encoderPinB, INPUT_PULLUP);
  pinMode(clearButton, INPUT_PULLUP);
  pinMode(9, OUTPUT);
  pinMode(13, OUTPUT);
  // turn on pullup resistors (old method)
  //digitalWrite(encoderPinA, HIGH);
  // digitalWrite(encoderPinB, HIGH);
  // digitalWrite(clearButton, HIGH);

  // encoder pin on interrupt 0 (pin 2)
  attachInterrupt(0, doEncoderA, CHANGE);
  // encoder pin on interrupt 1 (pin 3)
  attachInterrupt(1, doEncoderB, CHANGE);

  Serial.begin(9600);  // output
}

// main loop, work is done by interrupt service routines, this one only prints stuff
void loop() {
  rotating = true;  // reset the debouncer

  if (lastReportedPos != encoderPos) {
    Serial.print("Index:");
    Serial.println(encoderPos, DEC);
    lastReportedPos = encoderPos;
  }
  if (digitalRead(clearButton) == LOW )  {
    /*delay(300);
     pressCount ++;
     //Reset count if over max mode number
     if(pressCount > 2)
     {
     pressCount = 0;
     }
     switch (pressCount) {

     case 0:
     digitalWrite(13, LOW);
     break;
     case 1:
     analogWrite(9,25);
     break;
     case 2:
     analogWrite(9,0);
     digitalWrite(13, HIGH);
     break;

     }*/
    encoderPos = 0;
  }
  switch (encoderPos) {

    case 0:
      digitalWrite(9, LOW);
      digitalWrite(13, LOW);
      break;

    case 1:
      digitalWrite(9, LOW);
      digitalWrite(13, HIGH);
      break;

    case 2:
      digitalWrite(13, LOW);
      digitalWrite(9, HIGH);
      break;
    case 3:
      digitalWrite(13, LOW);
      digitalWrite(9, HIGH);
      break;
  }

}



// Interrupt on A changing state
void doEncoderA() {
  // debounce
  if ( rotating ) delay (1);  // wait a little until the bouncing is done
  // Test transition, did things really change?
  if ( digitalRead(encoderPinA) != A_set ) { // debounce once more
    A_set = !A_set;
    // adjust counter + if A leads B
    if ( A_set && !B_set && encoderPos != 5)
    {
      encoderPos += 1;
    }
    if ( A_set && !B_set && encoderPos == 5)
    {
      encoderPos = 0;
    }

    rotating = false;  // no more debouncing until loop() hits again
  }
}

// Interrupt on B changing state, same as A above
void doEncoderB() {
  if ( rotating ) delay (1);

  if ( digitalRead(encoderPinB) != B_set) {
    B_set = !B_set;
    //  adjust counter - 1 if B leads A

    if ( B_set && !A_set && encoderPos == 0)
    {
      encoderPos = 5;
    }
    if ( B_set && !A_set )
    {
      encoderPos -= 1;
    }

    rotating = false;
  }
}
Works well for limiting encoder, sketch is set for a limit of 4.
Check on serial monitor.
19  Using Arduino / Sensors / Re: Piezo sensor sensitivity. on: January 07, 2014, 10:58:59 am
I used a LM386 amp module like this one.
If you are planning on using a speaker and don't have the above module then connect the LM386 chip like the circuit shows here.
If you plan on feeding the signal to an analog pin then use a LM358 like in the circuits described here .
20  Using Arduino / Sensors / Re: corrosion proof electrode material for soil humidity sensor? on: January 06, 2014, 10:52:16 am
Check out this soil sensor using 316 stainless probes, there's a sketch at the bottom of the page and instructions, maybe you can get some ideas from there.
21  Using Arduino / Sensors / Re: corrosion proof electrode material for soil humidity sensor? on: January 05, 2014, 06:42:29 pm
Stainless is great, electric fence wire works well.
22  Using Arduino / Sensors / Re: MQ-7 CO Module Setup on: January 04, 2014, 11:37:03 am
No and no, like I said here "You wire that module right to your Arduino, all needed components are on the module."
Gnd pin -> Gnd on module, 5V pin -> VCC pin on module, Analog pin -> AOUT pin on module.
23  Using Arduino / Sensors / Re: Piezo sensor sensitivity. on: January 04, 2014, 07:00:41 am
Glad to hear it's doing what you want.
That circuit is open to modifications depending on the piezo used.
I tried 4 different piezos and had to modify the circuit for each one to get a clean pulse.
As the author states "Be warned that piezo are all differents, and that size matters… So experiment with that before engraving the above stuff in copper."
 The way you have the circuit is fine, actually better if you are using the BAT85 diodes or any diode rated under 200V VRRM.
If you read the comments of that link Alan Burlison advises putting the zener in parallel first to protect the BAT85 diodes from over voltage. He also says the second diode isn't needed, I only found that to work with one of the piezos I tested.
So the circuit you used does this: Zener only allows 5.1xx volts to pass, diodes rectify to positive only voltage, RC filter cleans pulse.
**edit**In each test I checked the output using an oscilloscope to make sure it was a cleaned up pulse.
Were you able to test with an oscilloscope?
24  Using Arduino / Sensors / Re: 2 wire temperature sensor on: January 03, 2014, 04:43:40 pm
Do yo have 10 x 1k resistors?
If so put them in series for 10k, might be a bit messy on the breadboard but will do the job.
**Have a multimeter? Test the resistance of the sensor.
25  Using Arduino / Sensors / Re: 2 wire temperature sensor on: January 03, 2014, 02:19:53 pm
Thermistor?
Try this tutorial.
26  Using Arduino / Sensors / Re: MQ-7 CO Module Setup on: January 03, 2014, 07:52:35 am
You wire that module right to your Arduino, all needed components are on the module.
Here is a tutorial for that family of sensors,use the AOUT pin on the MQ-7 module.
The trim cap is for adjusting DOUT.
Accurate calibration is difficult at home, the datasheet tells you to allow the module to pre-heat "No Less Than 48 Hours".
A good way to self calibrate is:
1.  Set your project up in the location that needs monitoring in a place where no one will be breathing on it.
2. Allow the 48+ hour pre-heat.
3. View the readings on the IDE serial monitor, that will be the areas "natural CO level" reading.
4. (Tricky part here) Determine the level of CO (IDE serial reading) needed to trigger an action.
5. Put your "trigger value" in the tutorial code here:
Code:
if (sensorValue >= 750)// Change 750 to your CO trigger limit

Hope this helps.
27  Using Arduino / Sensors / Re: Piezo sensor sensitivity. on: January 02, 2014, 10:54:44 pm
I tried this to amplify the "knock" a piezo picked up:
5.1v zener in parallel with piezo + 1N5819 in series > 1M ohm & 4.7nf cap in parallel> LM386 amp module 5V > speaker 8 ohm 1/2 watt
P++++5.1++1N5819+++1M++4.7+++++L++++++/ |
i           z                         O      N           M          /S |
e          e                         H       F           3          |  P  >
z          n                        M       |            8           \K |
o-Gnd-|----------------|-----|-------6--------\ |   
It amplified the signal just fine, could here it through the speaker but the tones produced from the piezo are very low.
I used the conditioner setup described by Alan Burlison from the comments of the link I posted earlier.
It really cleans up the piezo pulse no "ring like a bell" effect as you described earlier, it produces a signal from a few mV to 5.2V depending on "knock" intensity.
28  Using Arduino / Sensors / Re: Piezo sensor sensitivity. on: January 02, 2014, 09:23:38 am
One thing here, " lower/distant knocks" are different situations.
Lower can mean standing right over the piezo and tapping foot lightly.
Distance could mean standing in entrance of room slamming or tapping foot on floor, compared to standing 1 foot from device doing the same.
How to tell if it is just a lower knock? Or if it is a knock of distance?
For distance maybe 2 or more piezos a distance apart, compare the readings, difference of readings give distance from primary piezo pickup.
Do you have a link to the info of the circuit you posted?
Maybe you could condition the piezo signal like described here, gives one nice pulse.
                   
29  Using Arduino / Sensors / Re: Piezo sensor sensitivity. on: January 02, 2014, 07:21:05 am
If you want to set the minimum knock/thump that's sensed to trigger your required action, then in your sketch add a check like this:
Code:
int piezoPin = A1;

void setup()
{
  pinMode(piezoPin, INPUT);

}

void loop()
{
  int knock = analogRead(piezoPin);
  if(knock >= 1000) // change 1000 to the minimum knock/thump value that you need to react to
  {
    //perform action in response to knock/thump
  }

}
If you have a range that you want to react to, you can use an "if" statement like this:
Code:
if(knock > 500 && knock < 1000 ) // change knock/thump range values to what you need to react to
  {
    //perform action in response to knock/thump
  }
30  Using Arduino / Audio / Re: playing tones based on micros() on: December 31, 2013, 11:20:14 am
Nope, wrong bootloader ... didn't catch that in you are using the mega32A, sorry.
Pages: 1 [2] 3 4 ... 11