|
33752
|
Forum 2005-2010 (read only) / Interfacing / Re: Corrupt data with Arduino pro mini 3.3v + xbee?
|
on: August 27, 2010, 03:42:21 pm
|
|
I have a custom XBee shield that powers the XBee from the 3.3V pin on the Arduino. It sends and receives just fine. I've used the same shield on a Netduino which is a 3.3V device, and it works fine there, too.
So, I don't think it's a voltage issue.
One thing that might be causing a problem, though, is that the 3.3V mini operates at a different clock speed from the 5V mini. The 3.3V mini uses an 8MHz crystal, while the 5V one uses a 16 MHz crystal.
So, you might need to double the baud rate on the 3.3V mini's serial port to get it to communicate successfully with the XBee.
|
|
|
|
|
33756
|
Forum 2005-2010 (read only) / Interfacing / Re: Newbie looking for program debugging-motion sensor
|
on: August 26, 2010, 08:38:52 am
|
if (x < 6) { [glow] Serial.println("X is less than 6");[/glow] digitalWrite(motorPin,LOW); }
if ((x > 6) && (x < 18) ) { [glow] Serial.println("X is between 6 and 18");[/glow] digitalWrite(motorPin,HIGH); delay(3000); digitalWrite(motorPin,LOW); delay(3000);
lightUpOne();
}
if (x > 18 ) { [glow] Serial.println("Whoa, X is big!");[/glow] digitalWrite(motorPin,HIGH); delay(6000); digitalWrite(motorPin,LOW); delay(3000);
lightUpTwo();
} Tell us about the relay. Perhaps it needs more current to activate it than the Arduino can supply.
|
|
|
|
|
33758
|
Forum 2005-2010 (read only) / Interfacing / Re: gateway with arduino and xbee
|
on: August 25, 2010, 07:14:28 am
|
|
I'm not convinced that you can use XBees the way you want. The Series 1 models are point-to-point, meaning two of them can communicate with each other.
The Series 2/2.5 models are meant to communicate in a mesh arrangement, with end devices and coordinators.
That having been said, tell us how you have configured the XBees - exactly what you changed (specific values would be nice, but not mandatory if you need to hide something, like PAN ID).
Show us the code running on the 3 Arduinos.
|
|
|
|
|
33762
|
Forum 2005-2010 (read only) / Interfacing / Re: Multiple LED's different brightness same time
|
on: August 16, 2010, 05:46:21 am
|
It basically seems like it has 5 different levels with that code. Which code would that be? I ran my basic code through it and it seems to work better. "it"? What is "it"? I have to get some different ones anyways just because of color variances. There will always be color variances. You need to adjust the size of the resistor in line with each leg of each LED to even things out, or use some sort of diffuser.
|
|
|
|
|
33763
|
Forum 2005-2010 (read only) / Interfacing / Re: Multiple LED's different brightness same time
|
on: August 14, 2010, 08:38:32 am
|
|
The whole idea behind using millis() is to allow "simultaneous" actions to occurs. Putting delay in there defeats the whole purpose.
If you only want to read the sensor again when the whole 6 LED fading cycle is complete, that is possible. Set a boolean variable to true when a reading needs to be taken (initialized to true). Take a reading only when one is needed (the variable is true). When the fading cycle starts, set that variable to false. Set it back to true when the fading cycle is complete.
However, if you want the sensor to act as a switch, and turn the entire fading cycle on and have it run to completion, forget about millis and not using delay.
Create a single for loop that sets the appropriate value for all 6 pins, write the pin values, and delay for however long you want.
|
|
|
|
|
33764
|
Forum 2005-2010 (read only) / Interfacing / Re: Multiple LED's different brightness same time
|
on: August 13, 2010, 11:29:31 am
|
Suppose you were dimming the LED manually, using a potentiometer. Suppose the brightness needed to change every hour. You have a watch. You'd set the potentiometer, and write down the time you last changed the potentiometer. Every so often, you'd check your watch to see if it was time to change the potentiometer setting. If it was, you would move the potentiometer, and write down the new time. Well, on the Arduino, the "every so often" is every pass through loop. Checking your watch is calling millis(). The other steps are pretty obvious. The BlinkWithDelay example changes the state of the LED, from on to off or from off to on. What you want to do is change the brightness of the led. int increment = +1; int pwmVal = 0; unsigned long lastChange = 0; unsigned long interval = 100;
void loop() { unsigned long now = millis(); if(now - lastChange > interval) // See if it's time { pwmVal += increment; // Set the new value analogWrite(pwmPin, pwmVal); // Write the new value
// If we are at maximum or minimum, change direction if(pwmVal == 255) increment = -1; if(pwmVal == 0) increment = +1;
lastChange = now; } }
|
|
|
|
|
33765
|
Forum 2005-2010 (read only) / Interfacing / Re: Multiple LED's different brightness same time
|
on: August 13, 2010, 08:24:55 am
|
|
The BlinkWithoutDelay example will provide some inspiration and direction.
Basically, instead of setting an alarm and going to sleep (delay()), you keep track of when it is time to do things. Periodically, you check your watch (millis()), and see if it is time to do any of the things that might need to be done.
The things you have identified that you want to do are to change the PWM value of 6 different pins. All the pins change value at the same time (or near enough). The value of each of the pins is going to to be different. The easiest way to accomplish this is to have an array of pin values and pin numbers. On each pass though loop, see if it is time to change the pin values and write the new values to the pins. If it is, update the values, and write them to the pins.
Of course the pin value for any one pin will depend on the pin value of the preceding pin, except for the first one.
Hopefully, this will give you enough direction to get started. If you have problems getting it working, post your code and describe your problems, and we'll try yo help.
|
|
|
|
|