Show Posts
Pages: 1 ... 7 8 [9] 10 11 ... 13
121  Using Arduino / Programming Questions / Re: Program Alteration on: November 21, 2012, 05:45:08 am
Quote
Attached to what? I don't see a pic (it could be a firewall issue; not all pictures show up while I'm at work).
same case here this is not firewall issue. Actually he didn't attach...
122  Using Arduino / Programming Questions / Re: Taking the next step ! on: November 21, 2012, 05:31:13 am
Code:
#include <LiquidCrystal.h>
#include <CapacitiveSensor.h>

const int Relay = 8;
const int AuxRelay = 7;
const int BackLight = 6;


int MainVolts = 0;
int AuxVolts = 0;
int LDR = 0;
int LastState = LOW;

void setup ()
{
  lcd.begin(16,2);
  pinMode(Relay, OUTPUT);
  pinMode(AuxRelay, OUTPUT);
}
// Main Program - This will run thru continously until power is disconnected or reset button is pressed. 
void loop() 
{
  TurnMeOn();
  delay(50); // Delay for LCD display   
}
void TurnMeOn(){   
  int Power = analogRead(A4);
  if ( Power > 700 && LastState == LOW )
  {
    analogWrite(BackLight, 200);
    lcd.clear();
    lcd.print(" BLACKSNAKE SYS ");
    lcd.setCursor(0,1);
    lcd.print("DBC MARK 4, Ver1");
    LastState = HIGH;
    delay(2000);
    lcd.clear();
  }
  else if (Power > 700 && LastState == HIGH)
  {                                   
    LDR = analogRead(A5);
    analogWrite(BackLight, LDR / 2);
    lcd.setCursor(0,0);
    lcd.print("section else if");
  }
  else if ( Power  < 500 )
  {
    analogWrite(BackLight, 0);
    LastState = LOW;
  }
}

Yes, it's seem good
One point that i add if elseif elseif to it because there is no need to check every "IF" if one of them true.
123  Using Arduino / Programming Questions / Re: Taking the next step ! on: November 21, 2012, 05:14:25 am
Quote
I had to close off each if statement of course but now it works the same as it did in the loop..
Whoo Hooo I have finally written a successful function outside of the loop.
Your patience and advice is VERY appreciated Cyber

it's my pleasure smiley-cool
124  Using Arduino / Programming Questions / Re: Taking the next step ! on: November 21, 2012, 04:48:14 am
Code:
int LastState = LOW;
By assigning this value

Quote
if (Power > 700 && LastState == HIGH)

the result of this statment always false
it never enters to execute all other statements.
125  Using Arduino / Programming Questions / Re: Taking the next step ! on: November 21, 2012, 04:26:23 am
Quote
Quite clearly it isn't, which is why I asked to see all the code.

Yes you right but i want to confirm this from boy(BlackSnake ). smiley-cool

Quote
?

this is answer of his question "This is where I have trouble working out what can and can't be done in a function."
126  Using Arduino / Programming Questions / Re: Taking the next step ! on: November 21, 2012, 04:20:53 am
Now it's look good to read.
Code:
void setup ()
{
  lcd.begin(16,2);
  pinMode(Relay, OUTPUT);
  pinMode(AuxRelay, OUTPUT);
  Serial.begin(9600);
}
// Main Program - This will run thru continously until power is disconnected or reset button is pressed.  
void loop()  
{
  TurnMeOn();
  delay(50); // Delay for LCD display  
}


void TurnMeOn(){    
  int Power = analogRead(A4);
  Serial.print(LDR);
  Serial.println(Power);

  if (Power > 700 && LastState == HIGH)

  {                                  
    LDR = analogRead(A5);
    analogWrite(BackLight, LDR / 2);
    lcd.setCursor(0,0);
    lcd.print("section else if");
    if ( Power > 700 && LastState == LOW )
    {
      analogWrite(BackLight, 200);
      lcd.clear();
      lcd.print(" BLACKSNAKE SYS ");
      lcd.setCursor(0,1);
      lcd.print("DBC MARK 4, Ver1");
      LastState = HIGH;
      delay(2000);
      lcd.clear();
      if ( Power  < 500 )
      {
        analogWrite(BackLight, 0);
        LastState = LOW;
      }
    }
  }
}

Is this is full source code?

"YES" then first you face error

"NO".

You use nested IF and if result of first one if (Power > 700 && LastState == HIGH) false
it never enters to execute all other statements.

Tarce the values of Power and LastState.
127  Using Arduino / Programming Questions / Re: connecting to a webpage on: November 21, 2012, 01:53:13 am
https://github.com/ovidiucp/TinyWebServer
https://www.teleduino.org/
http://starter-kit.nettigo.eu/2011/

May be helpful
128  Using Arduino / Programming Questions / Re: Where is DDRB etc defined on: November 20, 2012, 04:43:20 am
try this tutorial.
129  Using Arduino / Programming Questions / Re: I forgot () at the end of function call, but got no errors? on: November 20, 2012, 04:28:08 am
Quote
I think that is an error, because there is nothing else with that name, but the IDE did not complain. But this happens only in if statement

if your question is calling funtion without () is error ?
No, function name represents the starting memory address of it's. e.g

Code:
void blnk()
{
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);  
}
// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);    
 
}

// the loop routine runs over and over again forever:
void loop() {
  blnk;  //
  Serial.println();
               // wait for a second
}

here blnk; is the case and in your case Switch14 is starting value of function
130  Using Arduino / Programming Questions / Re: interrupt on: November 19, 2012, 09:57:30 pm
Quote
Have you read the sticky thread "Read this before posting a programming question..." ?

i agree with you

@alva

try this
http://arduino.cc/en/Reference/SerialEvent
http://arduino.cc/en/Tutorial/SerialEvent
131  Using Arduino / Programming Questions / Re: Controller Hang whenever execute both functions(Parsing File and Writing File) on: November 19, 2012, 09:52:33 am
ok thnx for your suggestion.
132  Using Arduino / Programming Questions / Re: Controller Hang whenever execute both functions(Parsing File and Writing File) on: November 19, 2012, 09:43:21 am
Quote
Is there something about that simple statement that escapes you?
Yes ,there is some patterns on which system will crash why? Is this is due to bug OR our mistake logically.

Actually i execute the test mention here http://code.google.com/p/arduino/issues/detail?id=857 it's results also fine.
133  Community / Gigs and Collaborations / Re: Accelerometer help contest. €50 reward guarantee on: November 19, 2012, 09:27:49 am
Quote
What is not easy is the integration beacause even if I'm ok with the math, the computation will get some errors at every calculation and these errors will accumulate giving me a rising integral even if the accelerometer is not moving. I tried all the logic stuff (semplification, casting, etc...), nothing worked, so I'm here to ask your help.

No it's so easy by Numerical computations method

Rectangle Rule
Trapezoidal Rule
Simpson's Rule
Newton's 3/8 Rule

first apply those in matlab then port them in arduino smiley-wink
134  Using Arduino / Programming Questions / Re: Controller Hang whenever execute both functions(Parsing File and Writing File) on: November 19, 2012, 09:20:24 am
After taking break and enjoying weekend now i am out from Blackout Stage.
 
Quote
One path returns something. One does not. On any reasonable system, you'd be warned about that.

Ok next time i take care of that.

Quote
As Nick points out, using the String class is a bad idea. It isn't even close to being necessary in your case, since the read function is using a char array and the output is a larger char array.

Yes, you are right. (Nick, sorry for PM. I really don't know why there is PM option if this is not useful)

Quote
Copying the data from one to another using a for loop instead of dynamic memory allocation is going to waste far fewer resources.

Yes, that's why i tried both ways.

Quote
Snipped down like this routine is, though, makes your real problem far easier to spot. You have a local variable, strFile, that goes out of scope when the function ends. Yet, you return a pointer to that memory. When the function ends, you've got a pointer to memory that no longer belongs to a function, and is, therefore free to be reused in any amount anywhere. Not a useful thing to have.

Yes, After taking break and enjoy the weekend to recover mysellf from Blackout Stage i start debugging again and isuue on these lines find as earlier you mention that.
Code:
free(buff);
Code:
free(pch);

Issue solved and i modify it according to your and holmes4 suggestion.

But this problem open lots of issue front of me i start playing with this platform a month ago (but i am not a bad engineer smiley-wink). Is there really issue of system crash due String, free(), and malloc. In a post http://arduino.cc/forum/index.php/topic,115552 mention by executing this sketch system wil crash.

Code:
#include <MemoryFree.h>
void setup() {
  Serial.begin(9600);
}
void loop() {
  int n = 0;
  while(n <=100) {
    int u = 20*n;
    int v = 30*n;
    String str = String(n) + ", " + String(u) + ", " + String(v) + [color=red]", " + String(freeMemory());[/color]
    Serial.println(str);
    delay(500);
    n++;
  }
  Serial.println("Done");  
}

result comes in favour of post but if it is modify like that system execute smoothly

Code:
#include <SD.h>
void setup() {
  Serial.begin(9600);
}
void loop() {
  int n = 0;
  while(n <=100) {
    int u = 20*n;
    int v = 30*n;
    //int x =
    String str = String(n) + ", " + String(u) + ", " + String(v);
    str        = str + String(n) + ", " + String(u) + ", ";        //coment this line and next indicates test 1
    str        = str + String(n) + ", " + String(u);                //coment only this line indicates test 2.
    str        = str + ", " + String(FreeRam(),DEC);            // execute all lines indicate test3
    Serial.println(str);
    //Serial.println(FreeRam(),DEC);
    delay(100);
    n++;
  }
  Serial.println("Done");  
}

tests output attached in txt format. Actually i want to say that there is some patterns on which system will crash why?
Is this is due to bug OR our mistake logically.
NOTE :Spelling and grammer mistake ignore thnx it's your suggestion which makes my playground play-able smiley-cool
135  Using Arduino / Programming Questions / Re: serial readbytes until on: November 19, 2012, 06:06:06 am
Quote
Using readbytesuntil works fine but doesn't transfer the terminator to the buffer. I need to examine the contents of the buffer and often send it on by another serial port but I want it terminated by the same terminator. I can add this to the buffer easily enough but is there some way of the original terminator being transferred to the buffer on read so it is already in the right place to send on. The application reads data from a PC and sends it on to my amateur radio transmitter (TS2000X).  Neil, G3RIR

Posting a question is also an Art smiley-cool. First describe you TASK, Post your CODE, and then where you STUCK.
Pages: 1 ... 7 8 [9] 10 11 ... 13