Show Posts
Pages: 1 2 [3] 4 5 ... 3392
31  Using Arduino / Project Guidance / Re: Client Ip on: Today at 06:30:22 am
Quote
Can I know client's ip?
Can you do a search? You are not the first person to want that information, or the first that explain why you want that information.
32  Using Arduino / Programming Questions / Re: Skinner box project on: Today at 06:27:18 am
Get rid of the excessive white space. Use Tools + Auto Format to properly indent your code. Add some comments to  explain what each block of code is doing.

Code:
  currentTrial = lastTrial + 1;
 if (currentTrial != lastTrial)
After assigning a value to currentTrial that is not equal to lastTrial, there isn't a snowball's chance in hell that the if text will not be true.

Code:
      Serial.begin(9600);
Every time you need to print? NO!

Code:
        if (currentButton == HIGH)    // if the state has changed, increment the counter
        {
           buttonPushCounter++;        // if the current state is HIGH then the button went from off to on:
      Serial.begin(9600);
      Serial.print("Number of button pushes:  ");
      Serial.println(buttonPushCounter);
    }
   
  }
    lastButton = currentButton;          // save the current state as the last state, for next time through the loop

  if (currentButton == HIGH){
Why are there two blocks comparing currentButton to HIGH? If the current state of the switch matters, put all the code together.

Code:
  {
   randNumber = random(1, 20);
     delay(150);
  }
Useless curly braces. Every time the switch is released, generate a new random number.

The cats are going to piss all over your carpets and shred your furniture!
33  Using Arduino / Programming Questions / Re: serial.read output weird symbols on: September 30, 2014, 09:36:03 pm
Quote
both PC and Blutooth.
Didn't I say both was the wrong answer? Is your bluetooth device really communicating at 9600 baud? Most do not. Most communicate at 115200.
34  Topics / Robotics / Re: Controlling Dynamixel MX-28T or MX-64T servo wirelessly using Arduino Mega? on: September 30, 2014, 09:33:41 pm
Quote
This library is for MX28T servo, which is the same servo I am trying to use, but it uses UNO;therefore, I cannot interface with Xbee.
Why not? The XBee does not need to be connected to Serial. It can be connected to Serial1, Serial2, or Serial3.

Quote
Is it possible for Arduino Mega can interface with Xbee module using Serial1
Of course it is. With the appropriate shield (most are not) or breadboard connections.
35  Using Arduino / Networking, Protocols, and Devices / Re: External Device serial com to Xbee then wirelessly to Arduino on: September 30, 2014, 09:27:48 pm
So, one XBee is in broadcast mode, and the other one is listening to everything every other XBee sends. Not the best way to get speed and performance.

You should be setting SH/SL on one to DH/DL on the other, and neither should be 0x0000 or 0xFFFF.

Quote
because I can sniff the pot and see it in the terminal.
That sounds disgusting. I'm sure that you meant something else, but I haven't a clue what else.

Quote
while the Xbee is 5v?
XBees are 3.3V.

Quote
The AT function set of the Xbees.
That's fine.
36  Using Arduino / Programming Questions / Re: How to assign a number (read from sd card) to a BigNumber variable! on: September 30, 2014, 09:21:43 pm
Quote
A char [22] array has 23 elements? 0 - 22 ??
No, it doesn't. The number in the brackets is the number of elements in the array. The elements are numbered 0 to 21.

37  Using Arduino / Programming Questions / Re: serial.read output weird symbols on: September 30, 2014, 09:19:21 pm
Is the Serial port talking to the PC or is it talking to the Bluetooth device? Yes is wrong answer. So is both.
38  Using Arduino / Programming Questions / Re: Where does 93 bytes of RAM go? on: September 30, 2014, 09:09:49 pm
Quote
Free RAM has dropped by 16 bytes (the length of "Free memory = " plus one byte for the null terminator, plus one other unexplained byte).
I wonder if the compiler does not like off addresses. Maybe strings are always allocated in multiples of 2.
39  Using Arduino / Programming Questions / Re: Motion in LED strip "zones" problems, keeping track of many variables, et all on: September 30, 2014, 09:07:45 pm
Code:
  if (ledAction[led1Action] == 1) { //if zone 1 is on, then
Why the hell not use names that make sense? There appears to be no relationship between the name of the array and zones, and there appears to be no relationship between led1action and the value 1.

That code might as well read:
if(smith[wesson] == 45)
for all the meaning that is to be gleaned from the names.

Quote
I have been troubleshooting some code that i can't get to work, and i know why it isn't working.  The problem is that I am redefining variables that I have to keep separate.  I could make a thousand different variables if sram wasn't an issue, but i'm feeling I am just doing something wrong.
Well, you are the only one with the cheat sheet that defines what all those silly names mean, so if you can't keep them straight, you can't expect anyone else to.
40  Using Arduino / Programming Questions / Re: Serial Communication -Driving 2 Servos with 2 Pot's with Xbee's on: September 30, 2014, 09:01:12 pm
Quote
When we reach our endmarker of the string why do we assign the string (buffer[bytesrecieved] = 0) ?
That is placing a NULL after the last character, changing the array of characters into a NULL terminated array of characters, otherwise known as a string. The string handling functions expect strings, not arrays of chars.
41  Using Arduino / Programming Questions / Re: Servo motor with push button on: September 30, 2014, 08:57:39 pm
Code:
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);
  servo1.attach(7);
  digitalWrite(4, HIGH); //enable pullups to make pin high
  digitalWrite(5, HIGH); //enable pullups to make pin high
Assign the pins nice names, then refer to them as "Hey, you!". No.
42  Using Arduino / Programming Questions / Re: How to assign a number (read from sd card) to a BigNumber variable! on: September 30, 2014, 08:56:22 pm
Code:
  char temp_arr[22];
  temp_arr[22] = 0; // <=== NULL terminated
No, that's an error. The NULL goes in the 1st element in the array, not one beyond the end of the array!

Code:
      myFile.readBytes(temp_arr, 22);
      Serial.println(temp_arr); // <===== List all variables as they are read from SD
Serial.println() expects a NULL terminated array. You are not passing it a NULL terminated arry. The readBytes() method return the number of bytes read, so that you can properly NULL terminate the array. Discarding that value is a mistake.

Code:
    do {
      myFile.readBytes(temp_arr, 22);
      Serial.println(temp_arr); // <===== List all variables as they are read from SD
      myFile.read(); myFile.read(); // <=== discard <CR><LF>
    } while (myFile.available());
No. This whole thing should be a while statement, so you don't read from an empty file.

43  Using Arduino / Programming Questions / Re: Issue with buttons combining two sketches on: September 30, 2014, 08:52:05 pm
Code:
Button tTableStartPin = Button(24,PULLUP); //tTableStartPin button pin
The Button instance is NOT a pin.

You really need to ditch the Button class AND the Bounce class. You refuse to use ONE method to read the pins that those objects are associated with.
44  Using Arduino / Programming Questions / Re: ‘__attribute__((progmem))’ Error when compiling code for arduino uno on: September 30, 2014, 08:46:30 pm
Quote
Paul: Yes, I added the "const" after the type and before PROGMEM like so:
But, where did you put const in the other line that causes problems?
45  Using Arduino / Programming Questions / Re: Issue with buttons combining two sketches on: September 30, 2014, 05:33:15 pm
Quote
PaulS, there is a button I called Ttable on pin 24 that starts a dc motor turning a rotary table. I have a switch I called TtableSwitch on pin 23 that stops the rotary table from turning.
Then, I would expect the names to reflect the purpose of the pin. For instance, tTableStartPin and tTableStopPin.

There is no reason that I can see to have Button instances for some switch pins but not others. Consistency is a good thing.

Quote
As far as the Serial.println you pointed out, when I change digitalRead(Ttable) to digitalRead(24) it will read the state of the button that starts the turntable rotating.
Then, it should be digitalRead(23). This is why good names are SO important.
Pages: 1 2 [3] 4 5 ... 3392