go_away

Author Topic: manual delay function and how to take the input frm sensors  (Read 769 times)

0 Members and 1 Guest are viewing this topic.

Offline rajsekhar291Topic starter

  • Beginner
  • *
  • Posts: 3
  • Helpful? 0
please can anyone tell me how to write manual delay function?
and also please tell me  how to take input from the sensors

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,665
  • Helpful? 84
Re: manual delay function and how to take the input frm sensors
« Reply #1 on: July 19, 2010, 12:43:33 PM »
Which processor and programming language?

A software delay is pretty simple.

set a variable to a value
decrement the variable
test the variable for equal to zero
if not = 0 then go back and decrement again.
if = 0 exit

Offline rajsekhar291Topic starter

  • Beginner
  • *
  • Posts: 3
  • Helpful? 0
Re: manual delay function and how to take the input frm sensors
« Reply #2 on: July 19, 2010, 01:12:20 PM »
Which processor and programming language?

A software delay is pretty simple.

set a variable to a value
decrement the variable
test the variable for equal to zero
if not = 0 then go back and decrement again.
if = 0 exit
i want to write in c and i'm using atmega32
i want a delay of 1 second and the _delay_ms() function is not working please help me

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,665
  • Helpful? 84
Re: manual delay function and how to take the input frm sensors
« Reply #3 on: July 19, 2010, 03:15:17 PM »
void delay_1sec (void) {
   int i, j;
 
   for( i=0; i<X; i++) {
     for( j=0; j<Y; j++) {
          ;
     }
   }
}
Is how I would do a generic long delay.
X and Y are constants that need adjustment to get 1 second for your processor speed and compiler's code.
     

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
Re: manual delay function and how to take the input frm sensors
« Reply #4 on: July 19, 2010, 03:41:04 PM »
void delay_1sec (void) {
   int i, j;
 
   for( i=0; i<X; i++) {
     for( j=0; j<Y; j++) {
          ;
     }
   }
}
Is how I would do a generic long delay.
X and Y are constants that need adjustment to get 1 second for your processor speed and compiler's code.
     
as long as your compiler's optimisation is switched off.


dunk.

Offline rajsekhar291Topic starter

  • Beginner
  • *
  • Posts: 3
  • Helpful? 0
Re: manual delay function and how to take the input frm sensors
« Reply #5 on: July 19, 2010, 04:07:21 PM »
void delay_1sec (void) {
   int i, j;
 
   for( i=0; i<X; i++) {
     for( j=0; j<Y; j++) {
          ;
     }
   }
}
Is how I would do a generic long delay.
X and Y are constants that need adjustment to get 1 second for your processor speed and compiler's code.
     
as long as your compiler's optimisation is switched off.


dunk.
pls tell me how to take input frm sensors

 

Related Topics

  Subject / Started by Replies Last post
3 Replies
2538 Views
Last post June 19, 2008, 12:19:09 PM
by izua
11 Replies
2689 Views
Last post August 10, 2008, 05:38:07 AM
by ert481
1 Replies
771 Views
Last post July 09, 2009, 02:53:58 PM
by Luke
1 Replies
1017 Views
Last post July 10, 2010, 02:27:14 PM
by Soeren


Get Your Ad Here