| Arduino Forum ::  Members :: PaulS
 Show Posts Pages: 1 ... 2247 2248 [2249] 2250 2251 ... 3290
 33721 Using Arduino / Programming Questions / Re: I2C Help on: November 08, 2011, 09:28:55 am Code:  int data[8];Why is this array sized to hold 8 ints?Code:  *sensor0 = data[0] << 8 + data[1];  *sensor1 = data[2] << 8 + data[3];  *sensor2 = data[4] << 8 + data[5];  *sensor3 = data[6] << 8 + data[7];Some parentheses might help.Code:  *sensor0 = (data[0] << 8) + data[1];  *sensor1 = (data[2] << 8) + data[3];  *sensor2 = (data[4] << 8) + data[5];  *sensor3 = (data[6] << 8) + data[7];Addition has a higher precedence than bit shifting, so data[0] is being shifted data[1] + 8 places in your code. Probably not what you expected.
 33722 Using Arduino / Project Guidance / Re: making a weather station on: November 08, 2011, 09:17:16 am QuoteThe graphs there say that "(V - 0.8) / 0.03" should be the relative humidity, where V is the input voltage. (3.1 - 0.8) / 0.03 = 76.67% humidity. I have my window open and it rained an hour ago, so that seems right. But I don't know where it's getting 927 from.The analogRead() function returns a value from 0 to 1023 that is a ratio of the input voltage to the reference voltage (input voltage = 0 gives 0 output; input voltage = reference voltage gives 1023 output).To determine the voltage that the analogRead() value corresponds to, you need to know the reference voltage. Typically, this is 5V, but that can be lower when running on weak batteries or external power that is below spec, or it can be 3.3V on some boards, or it can be something different, if a voltage is applied to the VRef pin.Assuming that the board is a 5V board, and that nothing is applied to the VRef pin, simply multiply the analogRead value by 5.0 and divide by 1023.0, and store the result in a float.
 33723 Using Arduino / Interfacing w/ Software on the Computer / Re: problem with commnunicating arduino with processing (both sending and receiving) on: November 08, 2011, 08:44:54 am Quotei did modified the code in arduino, yet it still stuck in the middle.I have no idea what "it still stuck in the middle" means. I have no idea what "it" is.However, the Processing code is going to buffer serial data until it receives a carriage return, because you told it to:Code:  myPort.bufferUntil('\n');So, it might be useful in the Arduino code to actually send a carriage return, now and then. These are all of your serial statements:Code:  Serial.begin(9600);  if (Serial.available()>0) {    check = Serial.read();      Serial.print(signal1);    Serial.print(signal0);None of these sends a carriage return.Change the Serial.print() calls to Serial.println() calls to send the data followed by a carriage return/line feed.
 33724 Using Arduino / Programming Questions / Re: Speedometer simple code addition? on: November 08, 2011, 08:34:18 am QuoteBUT IM HAVING TROUBLEWe might be a bunch of grumpy old men, but we aren't deaf. You can stop shouting.You can start posting the modifications that you made to this code. You already said this code works. It's the modifications that you made that are causing you problems, so hiding them behind your back is not how you get help.