Show Posts
Pages: 1 2 3 [4] 5 6 ... 209
46  Using Arduino / Programming Questions / Re: Button and For Loop Troubles on: September 14, 2013, 10:09:56 am
Code:
 for (buttonState == HIGH; i < 5; i++) {

I don't think you understand the concept of a for loop, or how to implement one. I would recommend doing some reading on them, although maybe not now, since you're not looking for a for loop. There are two examples that demonstrate the concepts that you'll need:

StateChangeDetection - Shows you how to identify the moment when a switch is "pressed" and "released". You can use this method to record the time at which the switch was pressed, as well as turn on the LED.

BlinkWithoutDelay - Demonstrates the timing concepts of the Arduino. Ultimately it will revolve around the proper use of millis() to record the time (as noted above), and some simple subtraction to determine the elapsed time since the aforementioned variable was set. Once the elapsed time has been 10 or more seconds, you can turn the LED off.
47  Using Arduino / Programming Questions / Re: unsigned zero != zero on: September 14, 2013, 07:37:13 am
I don't see the issue: the unsigned int is always greater than or equal to zero. The first for loop breaks when i is negative one. Negative one for an unsigned int is 255, which still meets the for's condition of being greater than or equal to zero.
48  Using Arduino / Programming Questions / Re: array bound is not an integer constant on: September 13, 2013, 12:29:03 pm
numOfBtnPins and numOfPots aren't const
49  Using Arduino / Programming Questions / Re: Help required with inheritance on: September 13, 2013, 10:26:10 am
Since you're not specifying what superclass' constructor candidate to use, it's assuming you want a zero argument one. Problem is the LiquidCrystal class doesn't have a zero argument constructor. Change this:

Code:
LCDscreen::LCDscreen(uint8_t rs, uint8_t rw, uint8_t enable, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3)

to this:

Code:
LCDscreen::LCDscreen(uint8_t rs, uint8_t rw, uint8_t enable, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3) : LiquidCrystal(rs, rw, enable, d0, d1, d2, d3)
50  Using Arduino / Project Guidance / Re: Serial.println error on: September 12, 2013, 10:11:50 pm
You can't concatenate string like that. Do individual prints or use sprintf()
51  Using Arduino / Project Guidance / Re: Timing is everything. on: September 12, 2013, 10:11:02 pm
BlinkWithoutDelay example demonstrates the concepts. Read it. Play with it. Understand it. Embrace it.
52  Topics / Home Automation and Networked Objects / Re: portfowarding problems on: September 12, 2013, 09:06:21 pm
Since you have a private IP, that means that your router is providing network address translation (NAT) and your first step is to get your router to forward to your Arduino. I wouldn't worry about your ISP forwarding ports, since the address they are providing isn't a private address. What you do have to concern yourself, with regards to your ISP, is if they are blocking ports, and whether or not your address is static.
53  Using Arduino / Programming Questions / Re: Summarizing analogRead() on: September 12, 2013, 06:42:59 pm
By keeping track of the previous value you read and only increment a variable each time it goes from "below threshold" to above threshold. It's call signal edge detection. It's more commonly done with digital signals, but is very easy to transition to analog signals as well.
54  Topics / Home Automation and Networked Objects / Re: portfowarding problems on: September 12, 2013, 05:43:09 pm
Do you mean you get a local address from your ISP? If you visit http://www.whatsmyip.org/ does that match what your computer is reporting as your IP?
55  Using Arduino / Programming Questions / Re: Variable to count time on: September 12, 2013, 12:06:53 pm
I need to create a variable to count the time from the start of the Arduino

millis() already returns that value.

Quote
and another to count the time a button is pressed.

When the button is pressed, assign the value of millis() to a variable.
56  Using Arduino / Programming Questions / Re: Want to display all 6 analog channel in serial monitor on: September 10, 2013, 11:10:56 am
By not using the Serial monitor. Use a terminal program like PuTTy that allows you to log serial data.
57  Using Arduino / Programming Questions / Re: Rookie in trouble on: September 10, 2013, 10:50:59 am
Code:
void loop(){
     if(digitalRead(button) == HIGH)                  
     digitalWrite(led, HIGH);                      
     unsigned long time= millis();                
     if(time== (nullTime + elapsedTime)){      
       digitalWrite(led, LOW);                          
     }
  }

If statements should always have curly braces associated with them, especially when you're new. This allows us to recognize what you intend to be included by this if statement. Since you opted not to indent much, it's not clear which parts should be included by the if statement

Code:
if(digitalRead(button) == HIGH)

As it stands, only the line

Code:
    digitalWrite(led, HIGH);  

runs when button is HIGH. So let's rewrite the code to make that clearer:

Code:
void loop(){
     if(digitalRead(button) == HIGH)    
     {              
       digitalWrite(led, HIGH);                      
     }

     unsigned long time= millis();                
     if(time== (nullTime + elapsedTime))
     {      
       digitalWrite(led, LOW);                          
     }
  }

Since the value of nullTime is 0, and never changes, why bother? It can be simplified to:

Code:
if(time== elapsedTime)

Which makes the code say "After the Arduino has been running for 5 seconds, set led to LOW". Nothing in that statement has anything to do with the switch, or when it was pressed. Take a look at the StateChangeDetection example. That will allow you to detect the moment when the switch is pressed down, as well as turn the LED on. You can use that to record the current time in mills(). Then, in your loop(), you can subtract the recorded value from millis() to determine how long its been since the switch was pressed down. If that value is over a certain amount, you can turn the LED off.
58  Using Arduino / Programming Questions / Re: need your suggestion.. on: September 07, 2013, 11:49:53 am
Start by taking your single String:
Code:
static String cpNum = "09XX-XXXX-XXX";
and convert it to an array containing all 3 of the numbers Then when you are comparing the number with the number of the sent message:
Code:
 if (msg.startsWith (cpNum)) {
    respond(msg.substring (msg.indexOf (',') + 1));
  }
use a for loop, and loop through all of the 3 elements in the array
59  Using Arduino / Programming Questions / Re: need your suggestion.. on: September 07, 2013, 11:39:49 am
How to use this forum

#7 particularly.
60  Topics / Home Automation and Networked Objects / Re: Voice activated lights on: September 06, 2013, 06:21:45 pm
https://www.google.com/search?q=arduino+voice+recognition
Pages: 1 2 3 [4] 5 6 ... 209