Loading...
  Show Posts
Pages: [1] 2 3 ... 59
1  Using Arduino / Programming Questions / Re: IDE for writing libraries on: May 24, 2013, 05:01:39 am
But I would like to have a possibility to debug (stepping) my library/sketch in order to see what values a node in a linked list contains for instance...
Ahhh.. that is a completly different fish. If you want to debug using "single step" or "examine variable" in the Ardino you need some hardware support for that. Never needed that. Thinking about the problem, adding a few Serial.print gets you very far.
2  Using Arduino / Project Guidance / Re: Motion sensitive light project on: May 24, 2013, 04:24:17 am
It is perfectly acceptable to have one power source. All your equipment in your house comes from one powersource, the mains, right? smiley-wink

It is a problem of decoupling, and absorbing spikes. In particular with motors, they will for a brief time when you turn them on draw a lot of power causing a (weaker) powersupply to (briefly) drop the voltage which may upset the Arduino chip (causing the program to behave erratically). So it is a question of having a big enough powersupply (amps and internal capacitors) or adding a few capacitors here and there. Alternativly use seperate cheaper power supplies.

As you only drive LEDs it should be OK. As you can see from above it is a judgement call, I may be wrong, in particular if your supply has not enough "ooomph".

I can not understand your "how to connect 12V to breadboard" question. You just stick the wires in, just like you do with the 5V. Of course you make sure the right voltage goes to the right component, but ensuring correct wiring is true of any breadboard connection.

On the HighCurrentLoads page you linked to, they have paired up the long "power rails" on each side of the breadboard. By removing the lower red wire you can have a 5V rail on the left side and a 12V rail on the right. (You do know how a breadboard is wired inside, right?)
3  Using Arduino / Programming Questions / Re: IDE for writing libraries on: May 23, 2013, 02:18:15 pm
Library code is just the same C++ like the rest - I just use the standard IDE. You can have two IDEs open - one for the library one for test sketch.
4  Using Arduino / Project Guidance / Re: An 12v LED strip triggered by 5 micro switches on: May 22, 2013, 03:54:24 pm
the arduino can use ANY switch input. A teeeny microswitch or a mansized large circuit breaker.

What matters is what voltage is on the other side of the switch, that reaches the Arduino when it closes. That must be 5v or 0V.
5  Using Arduino / Project Guidance / Re: Motion sensitive light project on: May 22, 2013, 03:51:29 pm
Quote
a) Is it indeed the same situation, and can I copy the schematics?
Yes, if you use the MOSFET, not the Darlington Transistor.
Quote
b) how do you get the 12v power pack/wall wart to connect to the breadboard?
It is shown as the black barrel connector on thefar right to the breadboard and on the top in the schematic. NOTE all the Ground/negtive are connected (ie of the 5V Arduino and 12V)
Quote
c) I assume the Arduino would still need power to run off - can it run off USB power while the LED is strip uses the 12V from the power pack/wall wart?
Yep. You can also feed the 12V into the barrel connector on the Arduino board - it has a regulator so only 5V reaches the board.
Quote
d) Would this work for the transistor: http://www.jaycar.com.au/productView.asp?ID=XC4244 ?
Yes. Took me 20 minutes to get that confirmed. Cant trust the advertising only.  (it has a Vgs fullon at 4.5V)
6  Using Arduino / Programming Questions / Re: Need help with data types on: May 21, 2013, 06:33:42 pm
First off does it even make sense to say mybyte == 1?
Is that even correct? Should it be mybyte == B00000001?
Makes perfect sense. The two are identical, as the number "1" is represented as binary pattern 00000001. You can also specify it as '\01' or 0x1.

Quote
Second what type is mystring?
Only you know. There is no "type" of a variable unless YOU have declared it. The compiler will throw something about mystring being undefined. If your code said
Code:
String mystring
it is a String data type. (one that looks temptingly easy to use at first, but it has some hidden costs, so it is not recomended) If your code is
Code:
char mystring[20]
it is a character array of 20 letters, where mystring[0] is the first and mystring[19] is the last. Most character handling requires the last character is a zero (0, or '\0' or 0x0 ...) so to store "hi" it would contain mystring[0]='h' mystring[1]='i' mystring[2]='\0' and the content of [3] through [19] is irrelevant (but there if you want a longer string)
If your code is
Code:
int mystring
it is a number, and so on.

Quote
mystring = "song1.mp3";
If you have declared mystring correct, this is pointer manipulation, but you do not want to go there, yet. If you want to make mystring contain the filename then use strcpy() (not documented in the arduino reference, but it is a standard c routine - google)

The difference between Serial.print(65) and Serial.write(65) is the former will output the letters "6" and "5" which to your eyes looks like the number 65 (but it isnt 65 dots is it?), and the latter will ouptut the binary value 65 which the serial monitor shows as a single character - which happens to be the letter A. That is because the Serial monitor can not show binary, only characters. The computer is ALL BINARY - the concept of characters and numbers is our INTERPRETATION of what the binary value represents. That is why 'A', 65 and 0x41 and B01000001 all are the same.
7  Using Arduino / Programming Questions / Re: Need larger "String buffer", and, How to delete 1st 65 chars of a string on: May 21, 2013, 06:14:25 pm
Sorry, I find the statement "I found the delay was necessary so the sketch did not proceed until all data has arrived" illogical. (And I am being polite here, I have a stronger opinion than that  ]smiley )

Lets look at this fragment of code (and I have not examined all of it, I am just trying to pinpoint your misunderstanding about the delay())
Code:
GPRS.println("AT+CMGR=1\r");
  delay(700);

  if( GPRS.available() ){ // if new data is
    while( GPRS.available() ){ // while there's still data
      char wholeMsg = (char)GPRS.read();
      newMsg += wholeMsg;
      if (wholeMsg == '-') {
        newMsg = "";
      }
    }
You are assuming "all" the message has arrived in the serial buffer (which is, by the way, 64 bytes long... smiley-eek) after exactly 700ms. Your while loop empties the (64 byte) buffer into the newMsg string. And then your code goes totally away, never to add more characters to the newMsg. If you have only a short delay - say 20ms - you have discovered that your code then copies the 20 odd characters that have arrived in that time, but you never go back looking if more arrive a little later. So you incorrectly concluded the delay is necessary.

You need to get rid of the delay, whether 700 or 20ms long. If there is no delay the code will immediatly check for the GPRS.available(). There may no be any character avialable yet or maybe only the 1st character. Your logic indicates that you use the "-" character to determine EndOfMessage (EOM). So your while test should be: as long as you have not seen that EOM character then keep looking for GPRS.available(). If that is false, keep waiting until it is true, add the next character to newMsg and if it is the "-" then stop, as you have the complete message, else go back to the GPRS.available() check. This is a long winded explanation, the code will "Boil down to" one while statement with two logic tests and the newMsg accumulation in the body of the while.

And as others have said: get rid of the String objects, but you can do that as a seperate exercise, later.
8  Using Arduino / Programming Questions / Re: micros() wrapping problem on: May 21, 2013, 05:49:37 pm
@Boffin1: Think of a clock, the minute hand. It goes from 0 to 59, then "rolls over" to 0. Note that there are no negtive minutes, there are only the positive numbers 0..59. The same with unsigned long (or unsigned integer etc). The high number is just a bit bigger than 59.

So you want to measure off 10 minutes. On your analog clock face you know that is "an angle" of about 60 degrees. And it has that angle irrespective if we start the count at 5 or 55 minutes. (OK, slight digression, there is no "angle" in unsigned long.... but I want to get accross the point you do not worry about the "rollover" if you start at 55, do you?)

OK, so now or the math version.
Start at 5 minutes past (put that in PreviousMinutes) then look at the clock every now and then (say at 7 minutes, 12 minutes and 16 minutes past). The calculation is Minutes()-PreviousMinutes, which at thoses times yields 2, 7 and 11 respectivly, where 11 is more than our 10 minute - time done. Let's assume that you dont like doing subtraction so you simply COUNT from the minute hand backwards the minute tick marks on the face until you reach the start point (which was 5). Same result.

Now repeat the exercise but start at 55, and look at the clock at 58, 2, and 6 minutes. Your objection is that at "2" the calculation is 2-55 which yields -53. But there are no negative minutes!! Whenever you get negative minute you add 60 minutes, that "complements" the number (beause 60 is all the unique numbers we have on the dial). And that gives 7. Same way, if you dont like this subtract&complement (which is what unsigned math is) then just count the minute marks from the "2" backward to the "55" gives 7. Yes, 7 minutes elapsed. And at "6" it is 11 minutes, we've done the 10 minute interval.

So the "magic" works. As long as you always use the formula ( millis() - PreviousMillis > Interval ) for the if-condition then the rollover does not matter. Ditto micros().

There is a limit. You can see that you can not measure an interval greater than 60 minutes on the clock with only a minute hand. It also gets a bit tricky if you measure, say 55 minutes; if you look at the clock every now and then you may miss the 5 minutes where the subtraction(&complement) yields a number bigger than 55. Once we have wrapped around and past the starting point, it seems like only a short interval has passed again. So for micro-based timers you have to keep to roughly less than 70 minutes, and for millis roughly less than 49 days. (You can "make your own" special timer by taking a few highbits from the micros and multiply by a few low bits from the millis to make a timer that covers - say one&half day before rollover in 32 microseconds steps - but we'll cover that another day)

I hope this is all "clear as mud" smiley
9  Using Arduino / Programming Questions / Re: IR Remote Decoding for AC on: May 21, 2013, 11:33:26 am
What I meant is that because some peole say "i managed to do it" on the Great Internet, it does not imply that it was easy, and they may not have supplied the whole solution (intentionally or not).

God luck with your project.
10  Using Arduino / Project Guidance / Re: Motion sensitive light project on: May 21, 2013, 11:29:34 am
What sort of transistor should I be looking for/what sort of properties does the transistor need to have?
Yes, i do not want to mention anything specific - you might not be able to get that one.

My recomendation: A "Logical MOSFET", which means it will turn on full with a gatevoltage slightly less than 5V. A normal MOSFET needs 10V. Here is a little example (way too expensive, but you get some nice screw terminals) https://www.sparkfun.com/products/10256
11  Using Arduino / Project Guidance / Re: Motion sensitive light project on: May 21, 2013, 11:22:45 am
I just realised that the sensor says "Supply voltage: 3.0 to 5.5VDC"
It means it will work fine when connected to the Arduino shield's GND, 5V and AnalogInput pins
12  Using Arduino / Interfacing w/ Software on the Computer / Re: Quick doubt, mapping POT values to mouseX on: May 21, 2013, 11:04:17 am
You need to do something "similar" to the way you read serial input on the Arduino. You've done the initialisation OK.
Code:
     while ( port.available() > 0) {
       inChar = port.read();         // read it and store it in val
       println(inChar) ;             // optional debugging
       if (inChar == 'd') {          // If the serial byte received is a "d"
         fill(50);                   // set fill to dark Gray
         rect( width/2, 0, width/2, height);
       }
       if (inChar == 'u') {          // If the serial byte received is a "u"
         fill(200);                  // set fill to light Gray
         rect( width/2, 0, width/2, height);
       }
     // Which implies that any other characters are simply ignored/discarded
     }
This Processing code will colour a rectangle whenever the Arduino does a Serial.print('d') or Serial.print('u').

So in your Arduino loop you sample the POT and send a character (hint: Use Serial.write, not print) which the Processing port.read() receives as a binary number.
13  Using Arduino / Interfacing w/ Software on the Computer / Re: "COM port opened" check in the arduino code on: May 21, 2013, 10:54:48 am
I have a couple of "ideas".

The Arduino ONLY has the RX line to "sense" what is happing on the USB-PC connection. The CTS/DSR/etc other serial status pins only reside on the "USB-chip". So you would have to find out which pin onthe chip they are then carefully solder a wire to it and feed it to an Arduino pin. I can't remember offhand which controlsignal you want to look at.

Another approach is to wait for a few seconds(?) after start and if no data has been received on the RX line (Serial.available() remains at 0) assume stand alone operation.
14  Using Arduino / Interfacing w/ Software on the Computer / Re: Delphi serial communication on: May 21, 2013, 10:48:32 am
(copy if you want to) and experiment with, but I dont have time to explain it all.
The link to the synaser library is in the comments : http://synapse.ararat.cz/files/synaser.zip
15  Using Arduino / Project Guidance / Re: Motion sensitive light project on: May 17, 2013, 07:21:32 am
You will need some transistor to turn the LED strip on/off - your strip will draw 200mA, too much to drive from the Arduino pin direct, and they need 12V (Your 9V battry might make them turn on, but they will not shine)

The sensor will detect light level, not motion. In other words it will not see the differnece between you waving from right to left or left to right. Turning the light off/on in the room will also seem like "a hand waving". If that is OK for you, fine. Alternatives is to use a distance sensor, they can both be optical or ultrasonic.

If you want more strips to behave identically, just wire them up in parallel. (Your transistor may need to be be bigger. Or wire one transistor to each strip and then drive them from the same Arduino pin. If you have pins to spare, use one pin to each and in the sketch do the same to all pins.

Pages: [1] 2 3 ... 59