Show Posts
Pages: 1 2 3 [4] 5 6 ... 13
46  Using Arduino / Programming Questions / Re: Printing leading zeroes on: March 27, 2013, 05:21:31 am
Or, use sprintf() to format the data in a string, and then print the string. Use %02d to get a leading 0 when the value is less than 10.

sprintf
Ref: http://www.cplusplus.com/reference/cstdio/sprintf/
snprintf
Ref: http://www.cplusplus.com/reference/cstdio/snprintf/
47  Using Arduino / Programming Questions / Re: Arduino Ethernet + Grove RFID + Grove RTC on: March 27, 2013, 05:11:59 am
...
I developed the code but I have a problem of optimization.
The code is too long and there is not enough memory (ultimately give errors).
...

1) Which memory? Ram, Flash Memory
2) Which MCU/ArduinoBoard you are using?

EDIT:Version 1.0 of the Arduino IDE introduced the F() syntax for storing strings in flash memory rather than RAM.

REF: http://playground.arduino.cc/Main/Printf


Quote
(ultimately give errors)

Errors? smiley-cool
48  Using Arduino / Programming Questions / Re: IR Remote Code on: March 14, 2013, 09:56:22 am
How to use this forum - please read.

Yes, Please read.

it will tell you if there is any error in your code always post it with your code. smiley-cool
49  Using Arduino / Programming Questions / Re: Arduino UNO Rev3 + Icomsat v1.1 SIM900 on: March 13, 2013, 10:12:30 pm
hi pauls, the shield and libraries i get from here: http://imall.iteadstudio.com/im120417009.html

But your code seems me not using the library of http://imall.iteadstudio.com/im120417009.html

As earlier PaulS pointed,
50  Using Arduino / Programming Questions / Re: if statements , sonar servo on: March 13, 2013, 12:29:26 pm
this

http://arduino.cc/en/Tutorial/Ping?from=Tutorial.UltrasoundSensor

and this

http://arduino.cc/en/Tutorial/Sweep

and finally this

http://www.instructables.com/id/How-To-Make-an-Obstacle-Avoiding-Arduino-Robot/
51  Using Arduino / Programming Questions / Re: if statements , sonar servo on: March 13, 2013, 12:18:54 pm
How to use this forum - please read.

yes please read it will tell you how to post code to increase readabilty.
52  Using Arduino / Programming Questions / Re: ISP: Program ATMEGA256016AU on: March 13, 2013, 08:54:58 am
Quote
if i not understood bad

Yes, understood bad (: just kidding.

Nick Gammon's tutorial

http://www.gammon.com.au/forum/?id=11635
http://www.gammon.com.au/forum/?id=11638

great tutorial to solve your problem.
53  Using Arduino / Programming Questions / Re: EEPROMEx library not behaiving as expected on: March 13, 2013, 06:00:00 am
Code:
bool loadConfig() {
  EEPROM.readBlock(configAdress, confValue);
// for debug only
  Serial << SOFTWARE_VERSION << endl;
  Serial << confValue.softwareVersion << endl;
//
  return (confValue.softwareVersion == SOFTWARE_VERSION);
}

Yep, because of this

Quote
return (confValue.softwareVersion == SOFTWARE_VERSION);

put this line against the above

Code:
return strcmp(confValue.softwareVersion, "0.1")

will solve the issue.

Edit: during typing PaulS already mention that
54  Using Arduino / Programming Questions / Re: Checking on which pins to use for SoftwareSerial library on: March 13, 2013, 05:24:04 am
Hi Arduino experts,

I would like to know which are the pins I can use for SoftwareSerial library. I am using Atmega328. Can I use digital pins 10 and 11? Both pins support PCINT interrupt. Am I right to assume that as long as the pins support PCINT, they can be used for SoftwareSerial library? SoftwareSerial uses interrupt.

Thank you.

http://arduino.cc/en/Reference/SoftwareSerial
55  Using Arduino / Programming Questions / Re: Waveshield and Arduino UNO + GPRS shield on: March 13, 2013, 05:14:51 am
Quote
How can I merge the two codes into one?

By reading this
http://www.thebox.myzen.co.uk/Tutorial/Merging_Code.html

Quote
Sorry. There are no shortcuts to learning programming.

No, there is.

But always prefer the long term planning to become long term winner smiley-wink.
56  Using Arduino / Programming Questions / Re: Low interrupt on: March 13, 2013, 12:32:25 am
Quote
A LOW interrupt is not queued, and thus nothing is lost.

Correct, i got it.

57  Using Arduino / Programming Questions / Re: Low interrupt on: March 12, 2013, 11:33:33 pm
I know that if I put one of the two interrupts on my uno set to LOW it will fire over and over again as long as that pin stays LOW.  When it returns from the ISR, does it execute an instruction from the main code before it goes back into the ISR again?  Or will it freeze the main program and run the ISR like a loop?

Yes, in case of AVR processors, when an Interrupt Service Routine(ISR) finishes at least one opcode of the code execute before any other ISR is serviced.

RETI
ONE OPCODE AFTER RETI

Quote
LOW it will fire over and over again as long as that pin stays LOW
Yes, but most probably 1/3 of them will be lost.
58  Using Arduino / Programming Questions / Re: my first arduino robot on: March 12, 2013, 10:44:40 pm
i have a chasis, 2  hc sr 04 sensor and uno rev3 so i thought to start coding

i edited this code for obstacle avoidance
Code:
if ((da <=10) && (db <=10))

{

Serial.println(" right turn");

[color=red]delay(50000);[/color]

Serial.println(" left turn ");
}
delay(50);
}

then  i tested the above code with only two sensor...... i left both sensor unintreuptted so o/p should be printing only "go stright" statment but the output is mixed with "right turn" and "left turn" statment i dont no why...


It is better to take the average of atleast 5 values to make result more sophisticated.

Code:
if ((da <=10) && (db <=10))

this time print the values of da, db to check the most occuring value when  there is no interruption on both sensor.smiley-cool

cheers
59  Using Arduino / Programming Questions / Re: Arduino + TTL Camera +SD on: February 14, 2013, 09:44:02 am
I am not able to generate the image  smiley-mad
Below is my code.. Now since the manual says the image is JPEG format.. what other processing is required.

Code:
#include <NewSoftSerial.h>

byte incomingbyte;
NewSoftSerial mySerial(2,3);                     //Configure pin 4 and 5 as soft serial port
long int a=0x0000,j=0,k=0,count=0;                    //Read Starting address      
uint8_t MH,ML;
boolean EndFlag=0;
                              
void SendResetCmd();
void SendTakePhotoCmd();
void SendReadDataCmd();
void StopTakePhotoCmd();

void setup()
{
  Serial.begin(38400);
  mySerial.begin(38400);
}

void loop()
{
     SendResetCmd();
     delay(3000);                               //After reset, wait 2-3 second to send take picture command
      
      SendTakePhotoCmd();

     while(mySerial.available()>0)  //I DONT UNDERTAND !!!!!! wont this return the last byte in incomingbyte ??
      {
        incomingbyte=mySerial.read();

      }  
      byte a[32];
      
      while(!EndFlag)
      {  
         j=0;
         k=0;
         count=0;
         SendReadDataCmd();

         delay(25);
          while(mySerial.available()>0)
          {
               incomingbyte=mySerial.read();
               k++;
               if((k>5)&&(j<32)&&(!EndFlag)) //why is it k<5 ??
               {
               a[j]=incomingbyte;
               if((a[j-1]==0xFF)&&(a[j]==0xD9))      //Check if the picture is over
               EndFlag=1;                          
               j++;
      count++;
               }
          }
        
          for(j=0;j<count;j++)
          {   if(a[j]<0x10)         //why 0x10 ? why do we check for this (>16) condition
              Serial.print("0");    //why print this 0
              Serial.print(a[j],HEX);
              Serial.print(" ");           //why print this " space "
          }                                       //Send jpeg picture over the serial port
          Serial.println();
      }      
     while(1);   // ??? is that even necessary its already in void loop()
}

//Send Reset command
void SendResetCmd()
{
      mySerial.print(0x56, BYTE);
      mySerial.print(0x00, BYTE);
      mySerial.print(0x26, BYTE);
      mySerial.print(0x00, BYTE);
}

//Send take picture command
void SendTakePhotoCmd()
{
      mySerial.print(0x56, BYTE);
      mySerial.print(0x00, BYTE);
      mySerial.print(0x36, BYTE);
      mySerial.print(0x01, BYTE);
      mySerial.print(0x00, BYTE);  
}

//Read data
void SendReadDataCmd()
{
      MH=a/0x100;
      ML=a%0x100;
      mySerial.print(0x56, BYTE);
      mySerial.print(0x00, BYTE);
      mySerial.print(0x32, BYTE);
      mySerial.print(0x0c, BYTE);
      mySerial.print(0x00, BYTE);
      mySerial.print(0x0a, BYTE);
      mySerial.print(0x00, BYTE);
      mySerial.print(0x00, BYTE);
      mySerial.print(MH, BYTE);
      mySerial.print(ML, BYTE);  
      mySerial.print(0x00, BYTE);
      mySerial.print(0x00, BYTE);
      mySerial.print(0x00, BYTE);
      mySerial.print(0x20, BYTE);
      mySerial.print(0x00, BYTE);  
      mySerial.print(0x0a, BYTE);
      a+=0x20;                            //address increases 32£¬set according to buffer size
}

void StopTakePhotoCmd()
{
      mySerial.print(0x56, BYTE);
      mySerial.print(0x00, BYTE);
      mySerial.print(0x36, BYTE);
      mySerial.print(0x01, BYTE);
      mySerial.print(0x03, BYTE);        
}

The output in the serial monitor is displayed in HEX which is presumably the JPEG format.
So what do I do next ??

What do i do with the HEX data obtained now (See the attached file for the serial output). Once i am able to construct an JPEG image out of this I want to transmit it on wireless radio (however that is in the later stage)

Does anyone have a routine/code written that can change these HEX values to required JPEG values and all we would have to do is to change the extension and the JPEG should appear.

"Hello Paul  smiley

Just found that you were online so dropping a line.
I posted a question in the JPEG camera post, if you find time please take a look and help me out.

Thanks again.
Muneer"

I am not Paul. But i know he can solve your question. smiley-cool
60  Using Arduino / Programming Questions / Re: Class declaration problem with constructor on: January 12, 2013, 09:12:39 am
try that

Code:
DayNumber num1 = DayNumber(2715,10,23);

int main(void)
{
init();
setup();

for (;;)
loop();

return 0;
}

Problem: way of  declaration.

if you really like that way declaration DayNumber num1;

then add one more constructor.
Code:
DayNumber(int setYear,int setMonth,int setDay);
DayNumber();
Pages: 1 2 3 [4] 5 6 ... 13