Show Posts
Pages: 1 ... 89 90 [91] 92 93 ... 230
1351  Using Arduino / Programming Questions / Re: Activating LED with Thermistor Input on: June 10, 2013, 08:36:35 pm
I'm trying to make it so if the voltage is higher than 1 OR less than < 0.5, the LED activates.

So you want an if statement for 1 condition or the other:

Code:
if (condition1 || condition2)
{
  // code here
}
1352  Using Arduino / Programming Questions / Re: Activating LED with Thermistor Input on: June 10, 2013, 06:12:02 pm
Code:
 float voltState = sensorValue * (5.0 / 1023.0);

Instead of wasting resources turning the floating point into voltage and comparing the voltage. Spend a few minutes doing some simple algebra and determing the sensorValue for which voltState is equal to 0.5 and 1.0, and just comparing sensorValue to those values.

Code:
if (voltState > 1.0);
if (voltState < 0.5) {
   loop();

What do you think this is doing? Hint: It's not.
 
1353  Using Arduino / Programming Questions / Re: To much data error in serial communication?? on: June 10, 2013, 04:05:38 pm
so could there be another reason?

Maybe, but by not posting all of your code, who knows?
1354  Using Arduino / Programming Questions / Re: Calling C++ Code on: June 10, 2013, 03:37:12 pm
and I want to make it possible to continue running the program and call an arduino program.

You mean like multithreading? No, these microcontrollers don't have multi-cores or operating systems.
1355  Using Arduino / Programming Questions / Re: 2 LED Sequence on: June 10, 2013, 03:28:59 pm
What was wrong with your other thread?
1356  Using Arduino / Programming Questions / Re: Calling C++ Code on: June 10, 2013, 03:25:16 pm
When C++ files are compiled, the main function becomes the entry point, so I don't see how you could "run via the main function in the source file". Perhaps you should better explaining what you are trying to do, rather than how you are trying to do it.
1357  Topics / Home Automation and Networked Objects / Re: IR control over network on: June 10, 2013, 11:03:42 am
What is simpler, to use ethernet connection or wifi?

Ethernet, but not by much. It also depends on if you have am Ethernet connection nearby already. I would say that if you had to run wire through your walls, WiFi would be easier.
Quote
Should I / Can I use it as a server or is better to use local web server for the site and the device just as external interface?

You can. Whether or not you should will depend on how robust you want this web interface to be.
Quote
What shall I use as storage, Arduino, clearly has not enough memory;
What makes you say that?
Quote
shall I use an SD card or other kind of external memory? How much memory would I need for <10 remote controls?
Do these remotes have 50 buttons or 3? If the former, do you plan on storing all the commands for every button? I know there are buttons on some of my remotes that I never bother pushing.
Quote
Is there any arduino library that I shall familiarize myself with?
IR remote library seems relevant.
1358  Using Arduino / Programming Questions / Re: There's gotta be a simple answer. Button not working. on: June 10, 2013, 12:12:34 am
??
Was there something confusing about what I posted?
1359  Using Arduino / Programming Questions / Re: Receiving integer from Serial, then using it in a Do:While Loop? on: June 10, 2013, 12:12:01 am
Code:
(void)Serial.read();

What exactly do you think these statements are doing?
1360  Using Arduino / Programming Questions / Re: There's gotta be a simple answer. Button not working. on: June 10, 2013, 12:09:00 am
Sounds like you are shorting +5V and GND. Why not simplify your circuit and utilize the internal pullups?
1361  Using Arduino / Programming Questions / Re: How do I set different outputs along a Senors values like a to b, c to d, etc on: June 09, 2013, 02:11:41 pm
i'm trying to turn a relay on and off with different light intensities, currently it turns on above 650.  i would like to be able to change to time the relay is on based on the light intensity range, ie 650-750 and so on.

Then a you want a switch ranges as such:

Code:
switch (someInput)
{
  case 1 ... 5: // 1 to 5
    output = someValue1;
    break;
  case 6 ... 10: // 6 to 10
    output = someValue2;
    break;
  case 1 ... 15: // 11 to 55
    output = someValue3;
    break;
  default:
    output = someValue4;
    break;
}
1362  Using Arduino / Programming Questions / Re: expected unqualified-id before 'if' on: June 09, 2013, 02:04:02 pm
Code:
else
  int value
  for(value = 0 ; value <= 1; value+=5)
  {
    digitalWrite(M1, LOW);  
    digitalWrite(M2, LOW);    
    analogWrite(E1, 1);
    analogWrite(E2, 1);   //PLL Speed Control
    delay(30);
  }  

Watch your curly braces. The indentation here suggests you want all of this code to be inside the else clause, but no curly braces means the only the first statement is:

Code:
if (someCondition)
{
  // code runs when someCondition is true
}
else
// first line of code runs when someCondition is false
// anything after that runs no matter the result of someCondition

Even if you only want a single statement to run, its good practice to ALWAYS surround code with curly braces for if/elseif /else so that you don't run into issues like you are having:

Code:
if (someCondition)
{
  // code runs when someCondition is true
}
else
{
  // code runs when someCondition is false
}
// code runs no matter the result of someCondition

You should also use the Auto-format tool (Ctl+T or Tools > Auto Format) to make sure you have proper indentation that won't cause confusion down the road. There is also the added benefit of telling your when you have an uneven number of right and left curly braces. Every opening left curly brace should have a closing right curly brace. Every closing right curly brace should have an opening left curly brace.

Lastly, don't just post "So" and a bunch of code, post something of value like "I tried this: <CODE> and now I'm getting this error message <ERROR MESSAGE>". Code goes in CODE tags, not QUOTE tags.
1363  Using Arduino / Programming Questions / Re: expected unqualified-id before 'if' on: June 09, 2013, 01:51:07 pm
Quote
You can't turn an if statement into a function, you can only nest it within the function.

the statement is = if (position == 3)


So that needs to be within a function:

Code:
void someFunction()
{
   if (position == 3)
   {
     // code
   }
}
1364  Using Arduino / Programming Questions / Re: expected unqualified-id before 'if' on: June 09, 2013, 01:42:41 pm
Because i don't understand how you nest a statement into a code!


What do you mean by "nest a statement into a code"? What do you consider "a statement"? What do you consider "a code"?
1365  Using Arduino / Programming Questions / Re: expected unqualified-id before 'if' on: June 09, 2013, 01:36:55 pm
but if i turn
Code:
if (position == 3)
in to
Code:
int if (position == 3)

it stills shows the error of expected unqualified-id before if

That's because you are trying to turn the code into a function. You can't turn an if statement into a function, you can only nest it within the function. Why are you trying to turn that code into a function?
Pages: 1 ... 89 90 [91] 92 93 ... 230