|
31
|
Using Arduino / Programming Questions / Re: Carpark entry counter
|
on: May 11, 2013, 08:30:39 am
|
Also, it appears to be looping back into my SETUP () constantly.....i would have thought this would only run once? Classic out-of-memory action. Use the F() macro with all of your string literals: client.println( F("HTTP/1.1 200 OK" ));
|
|
|
|
|
33
|
Using Arduino / Programming Questions / Re: Need help with delay
|
on: May 11, 2013, 07:18:15 am
|
long interval = 10000; // interval at which to blink (milliseconds) At which to blink what? 10 seconds is not two minutes. //Read the state of the pushbutton value: unsigned long currentMillis = millis();
buttonState= digitalRead(buttonPin); if(currentMillis - previousMillis > interval) { If it isn't time, why bother to read the switch state? Putting each { on a new line, and using Tools + Auto Format will greatly improve your ability to see the structure of the code.
|
|
|
|
|
34
|
Using Arduino / Programming Questions / Re: Need help with delay
|
on: May 11, 2013, 07:11:07 am
|
And that's not what I want it to. I want it to follow the steps I wrote in my previous post. "I changed my code. It doesn't quite do what I want, so I'm not going to show it to you. Please help me fix it, anyway." Did I summarize that correctly?
|
|
|
|
|
35
|
Using Arduino / Programming Questions / Re: TEA encryption algorithm test vector
|
on: May 11, 2013, 06:58:22 am
|
What i need to know is how to set a test vector of TEA in arduino C language for encryption and decryption.
I don't fully understand this question. You have a function that encrypts some data. Looking at that function, you can figure out what the two arguments need to look like to call the function. second what is the code for sending data to the serial port and the code of receiving it from serial port through RF module. It's exactly the same code as for un-encrypted data. Surely, you've seen an example or 2 billion of sending and receiving serial data, using the Serial instance.
|
|
|
|
|
36
|
Using Arduino / Programming Questions / Re: Ribbon Pot Sample & Hold via MIDI
|
on: May 11, 2013, 06:47:20 am
|
if (buttonState == HIGH ) { Can you find a single Arduino example, or any code online that has not been ridiculed to death, where the ) is not on the same line as the rest of the if statement? You read the pot state on every pass through loop. That is wrong. You should ONLY read the pot state if the switch is pressed. What I would like is for the ribbon value to remain constant during successive button pushes and only change when a new value is sent from the ribbon pot. I wish to win the lottery, without buying a ticket, too. But what I want is not possible. Neither is what you want. the pot has no way of returning one value if pressed and another if not. You need to rethink what you want to do.
|
|
|
|
|
38
|
Using Arduino / Programming Questions / Re: Ultrasonic Sensor/New Ping Library code
|
on: May 11, 2013, 06:33:31 am
|
for (uint8_t i = 0; i < SONAR_NUM; i++) { // Loop through all the sensors. if (millis() >= pingTimer[i]) { // Is it this sensor's time to ping? pingTimer[i] += PING_INTERVAL * SONAR_NUM; // Set next time this sensor will be pinged. if (i == 0 && currentSensor == SONAR_NUM - 1) oneSensorCycle(); // Sensor ping cycle complete, do something with the results. sonar[currentSensor].timer_stop(); // Make sure previous timer is canceled before starting a new ping (insurance). currentSensor = i; // Sensor being accessed. cm[currentSensor] = 0; // Make distance zero in case there's no ping echo for this sensor. sonar[currentSensor].ping_timer(echoCheck); // Do the ping (processing continues, interrupt will call echoCheck to look for echo). } } On each pass through loop, see if it is time to ping one of the sensors in the array. If it is, set cm[n] to 0, then ping the sensor AND DISCARD THE RESULT. interval1 = map(cm, 30, 300, 20, 800); Then, try to map an array of values (OK, they are all 0) to a single value, using a function that does not expect an array. That will not work.
|
|
|
|
|
39
|
Using Arduino / Programming Questions / Re: Bit slow...
|
on: May 10, 2013, 10:59:33 am
|
the timing is displayed normally but when I add this it starts to give less values of time. So, you've discovered that it takes time to determine how much of the card is in use. I thought everybody knew that.
|
|
|
|
|
44
|
Using Arduino / Programming Questions / Re: Delay function
|
on: May 09, 2013, 01:27:01 pm
|
I was wondering is it possible to write delay(1*60*100); Yes. That will get you a 6 second delay, not one minute. Adding the UL suffix to one of the values is a good idea. delay(1*60*1000UL); // one minute delay
|
|
|
|
|
45
|
Using Arduino / Programming Questions / Re: Wireless Servo motor control via XBee
|
on: May 09, 2013, 11:21:00 am
|
but it has some delay Where? I'm going to guess here: int data = Serial.parseInt(); That code reads all the serial data, until it encounters a non-digit or until a period of time has elapsed during which no serial data arrives. To get rid of the delay, you must make sure that a non-digit follows the numeric data being sent. The process of converting a numeric value to a string, sending the string one character at a time, reading those characters, and converting them back to a numeric value is not a fast process. Since the value is in the range of a byte, sending the byte as binary data would be much faster, since 1) no conversion is required, 2) fewer bytes are sent, 3) no conversion is required. Learn how to do that, for one value (hint: Serial.write() instead of Serial.print() and Serial.read() instead of Serial.parseInt()), and then we can talk about the issues of expanding the code to deal with multiple servos. One issue is that RC equipment is far better designed for joystick control of servos than the Arduino is. Cheaper, too, generally.
|
|
|
|
|