Show Posts
Pages: 1 2 3 [4] 5 6 ... 342
46  Using Arduino / Programming Questions / Re: laser speed detector/calculator on: September 29, 2014, 10:02:57 pm
Glad you have it working as you want it.

Go ahead and upload- you don't need permission for that  smiley-razz . You'll have to wait and see if anyone can duplicate your rig- that depends on the time people have free, and of course if the have the components handy. You need to attach a schematic btw, so folks can see what your rig actually is.

edit.... I think I have suitable components, so yeah if I get a chance I'll see if I can hook it up and set it. I don't have RC cars though, so I'd just have the two lines maybe 50cm apart on my desk and test with my hand.
47  Using Arduino / Motors, Mechanics, and Power / Re: L293D chip not working as expected on Arduino Uno R3 on: September 29, 2014, 01:06:50 pm
First check the diagram: I hope all the things wrong are just wrong in the pic, not real life. (Like grounds and live from the chip to the wrong rails on the breadboard.)

So either fix all that in real life, or in the pic.
48  Using Arduino / Project Guidance / Re: Can anyone help me please? on: September 29, 2014, 11:05:25 am
Well spotted wildbill- I looked at that a few times and didn't notice, which is ironic since I had that exact logic error in some code of my own recently and did spot it....
49  Using Arduino / General Electronics / Re: Breadboard voltages on: September 29, 2014, 10:43:25 am

Cool to see an actual maker's number. But if that was AC, which number should be <=36..... RMS, one side peak, or peak-to-peak?
50  Using Arduino / Programming Questions / Re: Using the pow() function?? on: September 29, 2014, 09:36:05 am
Your code doesn't even compile.

But have you got the libraries, el_s?
51  Using Arduino / Programming Questions / Re: Writingto digital pins a byte at a time on: September 29, 2014, 09:29:49 am
It's not daft at all: I'd wager that 90% of the time one only wants to write to a few pins at the same time, and then they may well be on different ports.... switch an LED here, a motor there.

If it happens that you have a port's worth of data ready, then yes of course do it that way.

Apart from speed, there may be cases when for reasons to do with the outside world, a bunch of pins need actioning at the same time (as opposed to separate, albeit very close, instances in time)- then writing to a port would also make sense.
52  Using Arduino / Programming Questions / Re: laser speed detector/calculator on: September 29, 2014, 06:36:02 am
Code:
unsigned int bestTime = 1000000;
"unsigned long" 16 bits

?
53  Using Arduino / Programming Questions / Re: laser speed detector/calculator on: September 29, 2014, 05:38:42 am
can i upload it for someone to go over it and tell me if its correct or what i can do to simplify it ???

Of course you can, but first you might want to read up a bit on state machines, which is what this is.

Here are some links, in no particular order. One and Two are by members here.

Nick Gammon
Grumpy Mike
Robert C Martin
54  Using Arduino / General Electronics / Re: Breadboard voltages on: September 29, 2014, 04:38:12 am
I wouldn't go over 24V.


Tom with AC what would that be?- With the AC - AC transformer I got, I get (iirc) 18VAC shown on  my meter , but my 'scope says about 25 each way for peak-peak of 50 odd. 18 is RMS of 25. Which of those corresponds to your 24V figure? RMS, one way peak, or peak-peak?

I had it hooked up to breadboard yesterday, using the breadboard to connect one side to a diode. Seemed ok... (Until, that is, by stupidity I accidentally caused a short and popped the fuse in the transformer. Can't blame that on the breadboard.... But it does show how easy it is do that with wires flapping around, and I'm glad I went LV not mains for experimenting.)
55  Using Arduino / Programming Questions / Re: laser speed detector/calculator on: September 29, 2014, 04:23:08 am
Also what "function" do i use to have arduino choose between 2 different sets of instructions in the void loop() section depending on the intup of whatever sensor

You can do that all using if or if - else. the syntax to look for two things being true at once is the "&&", so you could have something like:

Code:
if (rightBeam == HIGH && Timing == true)
   {
       //do stuff
   }

Also be alert to using the "==" not just "=" when doing a comparison. This one catches a lot of people a lot of the time...
56  Using Arduino / Programming Questions / Re: Servo Problems on: September 29, 2014, 03:53:54 am
Just to add to UKHB's description of pullup and pulldown resistors, the attached diagram may help.
57  Using Arduino / Project Guidance / Re: possible to do this at one time? on: September 29, 2014, 12:01:36 am
.stay tuned for probably more silly questions...

Yeah- best that you try it yourself first, then ask for help if / when needed.

I did a rough speed test recently that shows loop() in a very simple program whizzes through at 150k times per second.

Even doing analogReads on all 6 analog pins it was going at 1500 times a second.

Those tests were on a Uno, btw.
58  Using Arduino / Project Guidance / Re: possible to do this at one time? on: September 28, 2014, 11:56:38 pm
Ah jeez, (Louise) , and you're not going to share your code ? I feel left out..... smiley-lol

I was going to, but you said the other day in a thread that you're a hardware guy and software confuses you  smiley-razz You might juuuust be able to fathom the below, though:

Code:
//speed test
//How many times thru loop() in one second?
//This code on a Uno, gave these results:
//    150k with the analogReads commented out
//    1500 with the analogReads in.
//YMMV.

long startTime;
long runTime;
long counter=0;
int analogReading;

void setup()
{
  startTime = millis();
  Serial.begin(9600);
  Serial.print("Start ");
  Serial.println(millis());
}

void loop()
{
  runTime = millis()- startTime;
  counter++;
 
  //have the below block in or out to see their effect
  /*
  analogReading= analogRead(0);
  analogReading= analogRead(1);
  analogReading= analogRead(2);
  analogReading= analogRead(3);
  analogReading= analogRead(4);
  analogReading= analogRead(5);
  */

  if (runTime >= 1000)
  {
    Serial.print("Looped ");
    Serial.print(counter);
    Serial.print(" times in ");
    Serial.print(runTime);
    while(1){
    };
  }

}
59  Using Arduino / Project Guidance / Re: possible to do this at one time? on: September 28, 2014, 11:29:14 pm
I did a rough speed test recently that shows loop() in a very simple program whizzes through at 150k times per second.

Even doing analogReads on all 6 analog pins it was going at 1500 times a second. So there's no doubt that it's running fast enough for it to seem these things are all happening simultaneously. It would need to be the world's fastest button press to get missed.
60  Using Arduino / Programming Questions / Re: laser speed detector/calculator on: September 28, 2014, 10:46:09 pm
I'm thinking you need to adopt a "state" approach with a flag. Off the top of my head:

Have a flag (just a boolean variable) called say Timing, initialised false. Let's call the beams leftBeam and rightBeam.

So, if leftBeam has been tripped, and Timing is false, start the clock (ie save millis()), set Timing true.

My thinking there is that we know car is going left to right, so the other beam stops the timer:

So then, if rightBeam has been tripped and Timing is true, stop the clock (ie save millis(), calc speed), set Timing false.

On the other hand:

if rightBeam has been tripped, and Timing is false, we are going right to left, start the clock (ie save millis()), set Timing true.
Then when leftBeam has been tripped and Timing is true, stop the clock (ie save millis(), calc speed), set Timing false.

I'm not guaranteeing I thought that through, so check my logic, but something along those lines should do the trick.

Oh, and on the error state of both beams covered, I guess you could just have a line:

if leftBeam is high and rightBeam is high, report error code, flash lights or something.




Pages: 1 2 3 [4] 5 6 ... 342