Show Posts
Pages: 1 [2] 3 4 ... 225
16  Using Arduino / Programming Questions / Re: Invalid cast from type ‘String’ to type ‘int’ on: July 18, 2014, 01:04:11 pm
why I can't convert String to int ?

You can if you do it properly.

Look at the available functions.
17  Using Arduino / Programming Questions / Re: myFirstLibrary, miles out? on: July 18, 2014, 10:39:09 am
Don't cross-post.
18  Using Arduino / Programming Questions / Re: Serial Monitor -> GUI on: July 18, 2014, 10:33:55 am
Not by using the Serial Monitor; you'll need a different terminal program.
19  Using Arduino / Programming Questions / Re: Merge servo and relay sketches on: July 18, 2014, 10:23:08 am
How to use this forum - please read.


// read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {    
    // turn LED on:    
    digitalWrite(ledPin, HIGH);  
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW);

So the entire purpose of this function is to just set the LED to the state of the button? This could be done much easier by wiring it up that way, but if you insist on using software, then the entire function can be boiled down to a single line.

digitalWrite(ledPin, digitalRead(buttonPin));

I would also not recommend naming a function "pumprelay" if all it is doing it controlling an LED.

// process times
  now = millis();
  endtime = now + FEEDINGDELAY;
  while(now < endtime) {
   Serial.print("soon... ");
   now = millis();  

What exactly is the point of endtime here? You set it to three hundred milliseconds after the current time, then wait 20 seconds. May as well just remove the while structure, because it's not doing anything for you.

Previously the pump relay code would only detect change or be implemented when the servo was operating. Is this solved by the way I have placed the void pumprelay function?

Your pumprelay function has zero coupling with the servo. In other words, they don't affect each other (with the exception being the delays cause the pumprelay function to be called infrequently). Is that what you're going for?
20  Using Arduino / Project Guidance / Re: run a buzzer after 10 cycles of running program on: July 18, 2014, 10:06:06 am
   if((signal1 == HIGH && signal2 == HIGH) && (signal3 == HIGH && signal4 == HIGH))

signal1, 2, 3, etc. Are pin numbers. You shouldn't be comparing pin numbers to states. You should be using digitalRead to get the state of a digital pin, then compare the results to HIGH or LOW.
21  Using Arduino / Programming Questions / Re: PC Application for controlling Arduino on: July 18, 2014, 09:58:25 am
22  Using Arduino / Project Guidance / Re: explaining of delay() please on: July 18, 2014, 09:56:53 am
Okay....I'll do that. but can I also leave the delay part out of the script/program?

How could we possibly know that without seeing the code?

Or is it a required part of the script and must I set it to delay(1)?

If you remove it, the code will sill compile, but we have no idea if the sketch "requires" it.
23  Using Arduino / Programming Questions / Re: How to 'call' or run a sketch inside another sketch? on: July 18, 2014, 09:53:44 am
Copy the readCO2 function into it's own new tab off of the main sketch. Add an extern to the main sketch so that the compiler knows that the function definition will come from another file:

extern int readCO2();

Call the function from within your main sketch
24  Using Arduino / Project Guidance / Re: Using keyboard to control LEDs on: July 17, 2014, 05:04:48 pm
Is this possible at all?

Yes, but the majority of the work will be through a keylogger on your computer. Lighting an LED up when you receive a '1' or a '2' is trivial.

If so, is it possible to run while I'm doing something else (e.g. see how many times I press "R" in a League of Legends game) and not be forced to type in the serial monitor?

Again, yes, but that has little to do with the Arduino, and everything to do with the keylogger running on the computer.
25  Using Arduino / Programming Questions / Re: Converting Analog values to 12bits on: July 17, 2014, 11:58:03 am
Since the value I get is actually digital values, are there any other ways to convert this value to bits ?

Values are already store in "bits". You can use masking, shifting and other bit-wise operations to manipulate the bits as you see fit.
26  Using Arduino / Programming Questions / Re: atof function not returning correct value on: July 17, 2014, 11:47:22 am
What am I doeing wrong here?

Welcome to the wonderful world of floats.
27  Using Arduino / Programming Questions / Re: Relay Timer on: July 17, 2014, 11:46:32 am
Your IF statements should look like this

No it shouldn't.
I'm pretty sure the syntax for IF is

if (someVariable == HIGH)
  // do something here

Unless there is only one line of executable code.


2) You don't compare pin numbers to HIGH/LOW, you compare pin states to HIGH/LOW. To convert a pin number to its state, you use digitalRead().
28  Using Arduino / Programming Questions / Re: Read entire string from Serial and split on: July 17, 2014, 11:18:59 am,43568.0.html
29  Using Arduino / Programming Questions / Re: Relay Timer on: July 17, 2014, 11:16:42 am
Your IF statements should look like this

No it shouldn't.
30  Using Arduino / Programming Questions / Re: Relay Timer on: July 17, 2014, 10:40:16 am
will build a smådelstvätt for engine parts so then I have 6 kvappar that will control four relays that should be on 30 mins and 1hr on another. if you know what I mean. what should I look for?

I don't know what a smådelstvätt or a kvappar are, so I couldn't tell you.

If you want to control 4 relays, you have to be more explicit about how you want them to be controlled. Statement such as "I want relay 1 to be on for 10 minutes, of for 5. Afterwards, I want Relay 2 to be on for 6 minutes, then off for 10. At the same time that Relay 2 is turned on, I want relay 3 to also be turned on for 2 minutes, then off for 6" are explicit and describe exactly how you want the relays to function. They also help structure the code.
Pages: 1 [2] 3 4 ... 225