Show Posts
Pages: [1] 2 3 4
1  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: delay using empty FOR loop?? on: April 17, 2009, 03:38:45 pm
I'm just guessing but it is possible that the compiler is analyzing your code and recognizes that there is nothing happening inside your for loop. If so it might optimize the whole loop away.

I've never looked at the code output by the AVR compiler so I have no idea how much optimization is implemented by the compiler.
2  Forum 2005-2010 (read only) / Syntax & Programs / Re: Having a function have a default value on: April 21, 2009, 04:44:12 pm
The only quirk about default values in C++ is that you can only omit values if there are no additional arguments to the right of the value you are omitting. I think some languages have a syntax that allows it.

In other words given

long myfunction(int pin=1, bool me=1, int time=1, long time1=1)

you can say

myfunction( 4, 3, 5 ) - omitting time1

or

myfunction( 3, 5 ) - omitting time and time1

but there is no way to omit pin and specify the other three

myfunction( , 3, 5, 4 ) - won't work

3  Forum 2005-2010 (read only) / Syntax & Programs / Re: EEPROM.write question on: January 28, 2009, 04:32:52 pm
Probably more like:

byte il = EEPROM.read(0);
byte ih = EEPROM.read(1);

int i = ih;   // grab the high byte
i <<= 8;   // shift the high byte left
i += il;     // add in the low byte

There is probably a way to do it in fewer statements but this shows the steps required.

You just have to decide up front how many EEPROM locations you need for each value you want to store and whether you are storing low byte to high byte or the other way around.
4  Forum 2005-2010 (read only) / Syntax & Programs / Re: Using I2C to connect Arduinos on: January 28, 2009, 09:48:32 am
While the slave can not initiate a transfer it is possible to hook a digital pin on the slave to a pin on the master which the slave can use to signal the availability of data.

In the original example the master would send a command to the slave. The slave would take 2-3 seconds to complete the command after which it would raise the signaling pin to HIGH indicating that status information is available.

On the master this signaling pin could either be tied to one of the interrupts or could simply be connected to an input pin. If connected to an input the master would poll the status of this pin after sending a command waiting for the slave to signal its readiness to return the status of the last command.
5  Forum 2005-2010 (read only) / Syntax & Programs / Re: using sleep mode on: January 17, 2009, 09:26:06 pm
I'm not far enough with my project to know the right answer but I'm hoping that the current required to run the timer circuit will be low enough that I'll use less total power than using the watchdog timer. But I'm trying to design something that will run on NiMH batteries with a solar recharger so I have more than 300mAh to work with.
6  Forum 2005-2010 (read only) / Syntax & Programs / Re: using sleep mode on: January 17, 2009, 09:52:30 am
I have no experience with the Lilypad but I assume that you can use an interrupt just like you would with an Arduino.

Take a look at this page in the playground.

http://www.arduino.cc/playground/Learning/ArduinoSleepCode

This example is using the serial port to wake up the processor but you can do the same thing with a timer. I've been working on a similar idea using a 4060 timer chip. Here is a good description of how to build a timer which can have a duration of minutes to hours.

http://www.reuk.co.uk/Timer-Circuits-With-4060B.htm

What I'm doing is to tie the appropriate output pin from the 4060 to the base of a transistor. The transistor pulls the Arduino interrupt line low which wakes it up after an hour. The first thing the Arduino does after the waking up is toggle the reset line on the 4060 which resets the timer. After polling a set of sensors the Arduino goes back to sleep until the timer wakes it back up.

Sorry I don't have a schematic but I haven't figured out how to use Eagle Cad yet.
7  Forum 2005-2010 (read only) / Development / Re: How to: soil moisture measurement? on: October 17, 2009, 08:19:15 am
I tested a sensor which was basically two nails encased in Plaster of Paris. My only complaint was that once the sensor got wet it seemed to take much longer for the plaster to dry out than the soil around it. Using something like the Leaf Wetness sensor and a thin coat of plaster might improve the response.

I ended up using two thin strips of stainless steel held together with nylon screws to keep the spacing constant. I packed this in sand. The sand seems do to a good job of wicking in moisture from the soil and dries out more quickly than the Plaster of Paris.

This thread has a picture of my sensor and information about using a 555 timer to create an AC circuit and measuring the frequency of the timer circuit rather than directly measuring current. It is just another way to approach the problem.

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1241791578/0
8  Forum 2005-2010 (read only) / Development / Re: Arduino Sleep and Wake? on: August 04, 2009, 03:46:32 pm
I did something which was battery powered and only needed to wake up periodically and take measurements. I built an external timer to wake up the Arduino once an hour. Here is the schematic that I used.

http://www.reuk.co.uk/Timer-Circuits-With-4060B.htm

Obviously, the external timer circuit requires power while the Arduino is sleeping but the amount was small enough that I still came out ahead.

9  Forum 2005-2010 (read only) / Troubleshooting / Re: DC Fan on: June 30, 2009, 11:44:06 am
Here is an example of controlling 12V PC fans using an Arduino.

http://www.uchobby.com/index.php/2007/09/23/arduino-temperature-controlled-pc-fan/

10  Forum 2005-2010 (read only) / Troubleshooting / Re: Warning, read the fine print before buying a Duemi on: April 06, 2009, 06:35:16 pm
Here is a link to another thread where someone says they have the IDE working with Hardy. I don't think there is any reason why you shouldn't be able to make it work.

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1221242192

11  Forum 2005-2010 (read only) / Development / Re: Programmer Recommendations on: October 02, 2009, 10:09:27 pm
I use the USBtinyISP from Adafruit, I've been very happy with it. It does ship from the US though.

http://www.ladyada.net/make/usbtinyisp/index.html
12  Forum 2005-2010 (read only) / Interfacing / Re: Wire and Servo libraries together on: October 10, 2009, 08:15:59 pm
I don't think it is a conflict in the library. I have a sonar sensor mounted on a servo and am using I2C to pass the distance data to a second Arduino.

Everything is working.
13  Forum 2005-2010 (read only) / Interfacing / Re: Question about GP2D12 Sharp sensor and Gear Motor on: August 07, 2009, 09:52:25 am
This is just my opinion but those drivers feel too expensive for a first robot. If you have access to simple parts you can easily build an h-bridge to control your gear motors as long as they are not too large.

I'm in the middle of the same project and I found this design for an h-bridge which I really like for small gear motors.

http://www.mcmanis.com/chuck/robotics/tutorial/h-bridge/bjt-circuit.html

You connect it to three pins on the Arduino. One for forward, one for reverse, and one of the PWM pins to control speed. If you use two motors, one for each drive wheel (the recommended design for first robots) you need two of these, one for each motor.

There are a lot of similar designs out there and there are also integrated circuits which contain all of the parts of the motor driver in one package. As long as you keep it small you don't need to spend a lot of money on a motor driver (yet).  smiley-wink
14  Forum 2005-2010 (read only) / Interfacing / Re: IR Transmitter on: July 25, 2009, 08:01:54 am
Another approach you can take is to build a 38 khz oscillator using a 555 timer and turn it on and off using an output pin from your Arduino.

I build a transmitter using this circuit:

http://www.robotroom.com/Infrared555.html

The Arduino connects to pin 4. The way this circuit is shown the resistor R5 keeps the oscillator on unless pin 4 is pulled low by the Arduino. I did it the other way, connecting R5 to ground so the oscillator is off by default and it transmits whenever I drive pin 4 high.

You need a multimeter which can measure frequency to set the R2 variable resistor until the oscillator runs at 38 khz.
15  Forum 2005-2010 (read only) / Interfacing / Re: Detecting river levels on: July 21, 2009, 07:40:09 pm
Years ago I worked with an instrument that measured the level of a river or stream by lowering a wire with a weight on the end of it until it touched the water. I knew nothing about the electronics but I assume that it detected the change in conductivity in the wire when it touched the surface of the water. It sat 10 feet or more above the surface of the river which gave it a wide range and it was probably accurate to a fraction of an inch.

Thinking about it it wouldn't be that hard to replicate using a stepper motor. You would need a switch of some sort near the top to detect when the wire was fully retracted. When you were ready to take a measurement you would let the wire unspool until you detected the surface of the water. Knowing the total number of degrees the motor rotated would allow you to calculate the length of the wire and the distance from the instrument to the water's surface.

It is more complicated than an ultrasonic sensor but it might be more accurate, particularly if the water level varies significantly and you have to mount the instrument more than a couple of feet above the surface.
Pages: [1] 2 3 4