Show Posts
Pages: 1 2 [3] 4 5 ... 34
31  Using Arduino / Project Guidance / Re: Potentiometer Temperature Stability on: August 07, 2014, 02:13:59 pm
Ok, why don't you put the temperature sensor in the water next to the ph probe?

Jumpers would be connected to resistors of different values hooked up in parallel, leading to an analogue input. Depending which jumper you short, you get different readings.

But I still don't get it. The ph changes with temperature. It's not that you get false readings - the actual ph changes, right? So who cares what temperature the water is? You need to adjust ph regardless.
32  Using Arduino / Project Guidance / Re: Potentiometer Temperature Stability on: August 07, 2014, 01:37:11 pm
I'd say that the stability over such small ranges is much better than your ability to eyeball the position and the actual temperature.
Alternatives to a pot is several jumpers, each for a predetermined temperature value.
But seriously, how much do you expect the temperature to fluctuate? And more importantly how large are the variations in ph with the change of temperature?
Uh, whatever the change in ph due to temperature, it's actual ph, isn't it? Are you sure you should compensate? Perhaps the ph probe needs compensation?
33  Using Arduino / Project Guidance / Re: Itead HC-06 Module, how to connect to Arduino on: August 07, 2014, 01:26:24 pm
Have you checked their documentation?
http://wiki.iteadstudio.com/HC06_Serial_Bluetooth_Brick#Demo

Note that this is 3,3V device. Plugging it into a 5V Arduino UNO can damage it.
34  Using Arduino / Project Guidance / Re: Two switches, one light, conditional? on: August 07, 2014, 12:19:59 pm
Get rid of this.

Code:
if (digitalRead(buttonPin) == HIGH)
  {
    delay(100);                        // delay to debounce switch
    ledon = !ledon;                // toggle running variable
    digitalWrite(soundPin, ledon);      // indicate via LED
  }

You don't want to mess with the value of ledon unless there is a change in the state of the button. What this does is toggle the ledon value and turns the buzzer on and off rapidly for as long as buttonPin is HIGH. You want only one change.


For the off timer, you started to work with millis(). That's fine and you'll need to get to know how to use it eventually, so why not now, eh?
I'm not sure how familiar are you with it, so forgive me if I cover the basics.

millis() gives you the time in milliseconds from the moment the microchip was turned on. It doesn't tell the time, only elapsed time. It's like a stopwatch, not a clock.
Using it is the same as you use any watch when you want to do something for a period of time. In your case you want to turn off a light three seconds after it was lit up.
What you do is take a look at what time it is (millis()) at the moment of turning the light on and store that time in a variable. You want to make sure you write down that time only once - at the moment of turning the light on and don't overwrite it unintentionally. We've already set up the basis for this when we introduced the flag.
The place to check this time is in
if (ledon  == LOW)
Now that you know when you turned the light on, all you need to do is occasionally take a look at the watch and see if three seconds have passed. If yes, turn the light off, if not, check again later.
In this case a good place to check time and decide if you want to do something is in the main loop.
35  Using Arduino / Project Guidance / Re: Two switches, one light, conditional? on: August 07, 2014, 10:31:23 am
Code:
if (digitalRead(buttonPin) == HIGH)
  {
    delay(100);                        // delay to debounce switch
    ledon = !ledon;                // toggle running variable
    digitalWrite(soundPin, ledon);      // indicate via LED
  }

What this does is change ledon value 10 times per second as long as buttonPin is HIGH. You want the ledon value to change only once for each switch change.

Try:
Code:
if (ledon  == LOW)
  {
    delay(100);                        // delay to debounce switch
    ledon = !ledon;                // toggle running variable
    digitalWrite(soundPin, ledon);      // indicate via LED
  }
Also, move this last bit inside the
if (buttonState  != buttonState2)
You want both conditions (different switch states and flag) to be met. Remember that you can nest as many ifs inside one another as you need.

Don't forget to place an equivalent code for changing the flag back to LOW (it would go inside else) and remember to turn the siren off.
36  Using Arduino / Project Guidance / Re: IC implementation of min function (looking for) on: August 07, 2014, 10:13:44 am
This is what I love about this community.
It's hard to find something when you don't know what it's called, but there is always somebody around that has more experience in a relevant area.
37  Using Arduino / Project Guidance / Re: Two switches, one light, conditional? on: August 07, 2014, 09:38:35 am
Flag is a variable that holds a value. You set the value however you want, not through digitalWrite.
The idea is that you use it to detect the change of state and not the state itself.

So, when you detect that it is time to power up the light, you check if the flag is LOW. If it is, you change its value to HIGH and sound the buzzer. Then you turn on the light.
When the code goes all the way through the loop and comes back to the same spot it will again check if the light should be on (and it will be) and it will check if the flag is LOW or HIGH. It will be HIGH so the code will ignore the part dealing with sounding the buzzer.

Same thing with turning the light off. If the flag is HIGH when the time is to turn off the light, change the value of flag back to LOW, only this time you don't need to deal with the buzzer. Then turn the light off.
38  Using Arduino / Project Guidance / Re: Two switches, one light, conditional? on: August 07, 2014, 08:24:47 am
Maybe it's time for you to rethink and simplify the code. After all, there is more than one way to skin a cat.
Start by making a truth table including all possible switch states and corresponding light state. There are 4:
Code:
0 0   0
1 0   1
1 1   0
0 1   1

As you can see the only time the light is on is when switches are in opposite states. That makes your light logic quite simple:
Code:
if (buttonState  != buttonState2)
{
  digitalWrite(ledPin, HIGH);
}
else
{
  digitalWrite(ledPin, LOW);
}

For the buzzer, you'll want to use a flag - a variable that stores the old state and compares it to the new one, then when the conditions are met (the change from the off state to on) you go about sounding the buzzer.

EDIT:
The code you posted will not compile.
You never declare currentMillis.
But even then you never check the time with millis();

EDIT2:
One more thing, a very important one.
You call your variables buttonState  and buttonState2 even though they refer to switches. While it is perhaps not a problem in this case, once you start writing bigger programs this will lead to confusion.
39  Using Arduino / Project Guidance / Re: Two switches, one light, conditional? on: August 07, 2014, 05:31:38 am
Once your code enters the while loops it can never exit since you never check the state of switches inside while loop.
40  Using Arduino / Project Guidance / Re: Viability and General Approach For Automated Dry Ingredient Dispenser on: August 07, 2014, 02:29:55 am
Drill bit. That hasn't crossed my mind, but now that you mention it this type of bit might work.
You still need a scale that you can interface with Arduino.
41  Using Arduino / Project Guidance / Re: Viability and General Approach For Automated Dry Ingredient Dispenser on: August 07, 2014, 12:25:47 am
Ok, so that's a no on mixing all the ingredients. Understandable.
The drawer thing does not appeal to you?
Peter, was this the sort of machine you saw?
https://www.youtube.com/watch?v=ZYbWykY5IPE

I'm looking at diy.soylent.me and I see that ingredients come in either low amounts or hig, rarely in the middle. That's important because if you want to weight each ingredient, you'll need at least two scales. One for low amounts the other for bulkier ingredients.

You could have multiple dispensers over one container sitting on the scale. You measure one ingredient, zero the scale, add the next ingredient to the same container. Once all the ingredients of similar amount are measured you could just take the two containers and join their ingredients.

Take a look at this gunpowder measuring thing.
https://www.youtube.com/watch?v=ZYbWykY5IPE
42  Using Arduino / Project Guidance / Re: Recommendation for really small project parts on: August 06, 2014, 04:12:38 pm
Perhaps something like this?

http://www.ebay.com/itm/HopeRF-RFM73-2-4Ghz-Wireless-Transceiver-for-Arduino-Wireless-Nordic-NRF24L01-/181197510216?pt=LH_DefaultDomain_0&hash=item2a30369648

http://www.ebay.com/itm/NRF24L01-SMD-Wireless-Module-2-4G-1-27MM-Small-Size-for-Arduino-Raspberry-pi-/130951124787?pt=LH_DefaultDomain_0&hash=item1e7d4b9733
43  Using Arduino / Project Guidance / Re: High accuracy servo, various component selection on: August 06, 2014, 02:37:06 pm
Futaba and Graupner are good brands.
44  Using Arduino / Project Guidance / Re: High accuracy servo, various component selection on: August 06, 2014, 01:14:44 am
Perhaps a Hall sensors would be better than reed switches. Reeds bounce, could stick or not close properly. Stay away if you can.
45  Using Arduino / Project Guidance / Re: Viability and General Approach For Automated Dry Ingredient Dispenser on: August 06, 2014, 01:09:32 am
Would you be satisfied with fixed amount of each ingredient or should it be tweakable? Can you mix all the dry ingredients in one large container beforehand and just take from that, or do you need a separate dispenser for each ingredient?

I'm thinking a hopper full of one (or all) ingredient sitting above a "drawer". When the drawer is closed it fills itself with the ingredient that falls from the hopper above it. The drawer has no bottom, but is sitting on a surface that makes the seal. The drawer also has a protruding surface on the top of it to close the hopper as the drawer is opened. As it is opened the ingredients fall out of the bottom.
The amount of ingredient dispensed is regulated by the size of the drawer.
Unfortunately this does require some manufacturing.

Alternative would be some sort of a screw that pushes the ingredients (again from the hopper above), but unless you can source them they'll be even harder to manufacture.
Pages: 1 2 [3] 4 5 ... 34