Show Posts
Pages: 1 ... 1068 1069 [1070] 1071 1072 ... 1743
16036  Using Arduino / Programming Questions / Re: Very simple LED coding question on: November 28, 2011, 03:30:00 pm
The reason x keeps increasing is because you keep making new x, and the discarding them.
Read the section about scope in the reference.
16037  Using Arduino / Programming Questions / Re: Using Keyboard to control a Motorshield on: November 28, 2011, 10:05:18 am
An exercise for the reader   smiley-yell
16038  Using Arduino / Programming Questions / Re: Using Keyboard to control a Motorshield on: November 28, 2011, 09:54:56 am
Code:
case 'a':   
      motor2.setSpeed(225);
      motor.run(FORWARD);    // Motor Runs Forward
      break;
16039  Using Arduino / Programming Questions / Re: Maximum number of cases in switch? on: November 28, 2011, 08:58:47 am
After a quick glance, all the values in those arrays are divisible by 50.
That could save some memory.
At least half.

EDIT: There are only eleven different values in that table (apart from zero). That's a big saving.
16040  Using Arduino / Project Guidance / Re: PTZ controller on: November 28, 2011, 05:47:45 am
Quote
I am trying to program an Arduino UNO to accept Pelco-D protocol used in PTZ (Pan-Tilt-Zoom) cameras and output it to 2 servos.
Can you post your code?
As far as I can see, the trickiest part will be implementing the pan/tilt speed, but without seeing your code, it is really hard to know what you perceive as the hard parts.

(BTW, it is "typo" (short for "typographical error") not "type-o" (a blood group) )
16041  Using Arduino / Programming Questions / Re: Possible to determine clock-cycles needed for code snippet ? on: November 28, 2011, 04:45:21 am
If you click on the "verify" or "upload" button, and hold down the shift key at the same time, the compiler will give you the pathname of where your sketch is.
Locate the directory, and you'll see a variety of .cpp, .hex and .elf files, amongst others.
Quite a useful insight into the IDE's thought processes.

Figuring out ISR overheads is a little trickier, but if you've got an oscilloscope, you can get a fairly accurate result with some simple code.
Simply having a background loop resetting an output pin, and the ISR setting the same pin will give you a rough result.
16042  Using Arduino / Programming Questions / Re: Possible to determine clock-cycles needed for code snippet ? on: November 28, 2011, 04:30:26 am
Quote
Of course, if there is a precise deterministic way, that doesn't involve JTAG/ICE, would be great.
See reply #1.
16043  Using Arduino / Programming Questions / Re: Possible to determine clock-cycles needed for code snippet ? on: November 28, 2011, 04:21:04 am
If you apply "avr-objdump" with the "-D" option to your output.elf file, you can get the disassembly of your sketch.
Instruction cycle counts are listed on the processor datasheet.
16044  Using Arduino / Programming Questions / Re: basic motor problems on: November 28, 2011, 03:33:11 am
Very few motors are capable of being driven directly by an Arduino because of the amount of current they draw; even tiny phone/pager vibra motors can draw much more than the Arduino I/O pins can supply.
So, yes, generally, you are best buying a shield, at least to get you started, or until you are comfortable with wiring transistors.
16045  Using Arduino / Project Guidance / Re: Turn on LED > push button > take and transfer picture on: November 28, 2011, 02:35:02 am
Quote
I was under the impression that the scope of variables and objects created in the void setup meant they were accessible throughout the rest of the code
No, quite the wrong impression.
"loop" and "setup" are functions just like any other; no special scope rules apply to them.
16046  Using Arduino / Programming Questions / Re: Using Keyboard to control a Motorshield on: November 28, 2011, 02:30:37 am
Quote
sketch_nov27a:19: error: 'motor' was not declared in this scope
I thought they were now called "motor1" and "motor2"?
16047  Using Arduino / Programming Questions / Re: Programming a serial connection on: November 27, 2011, 03:32:42 pm
Oops, missed the "=="
16048  Using Arduino / Programming Questions / Re: Programming a serial connection on: November 27, 2011, 03:27:59 pm
Code:
  while(Serial.available() > 0)
  {
    inSerial == Serial.read();
  }
It'll probably work most of the time, but if any of your called functions take longer to execute than the transmission time of a single character, then you may start to miss things.
Better to use "if", rather than "while"
16049  Community / Bar Sport / Re: Scorpions: ever been stung? on: November 27, 2011, 03:22:38 pm
Quote
Edison electrocuted an unfortunate Nelly to show the dangers of AC current
That would've been an unfortunate Topsy.
16050  Using Arduino / Displays / Re: Timelapse with 4-digit 7 segment problem on: November 27, 2011, 03:12:31 pm
Code:
int digits[11][7] = { { 1,1,1,1,1,1,0 },  // = 0
                      { 0,1,1,0,0,0,0 },  // = 1
                      { 1,1,0,1,1,0,1 },  // = 2
                      { 1,1,1,1,0,0,1 },  // = 3
                      { 0,1,1,0,0,1,1 },  // = 4
                      { 1,0,1,1,0,1,1 },  // = 5
                      { 1,0,1,1,1,1,1 },  // = 6
                      { 1,1,1,0,0,0,0 },  // = 7
                      { 1,1,1,1,1,1,1 },  // = 8
                      { 1,1,1,0,0,1,1 },  // = 9
                      { 0,0,0,0,0,0,0 }   // = blank
                      };
OT: RAM is a very precious resource.
Using 1232 bits of it to store 77 bits worth of information is wasteful in the extreme.
Pages: 1 ... 1068 1069 [1070] 1071 1072 ... 1743