Author Topic: manual delay function and how to take the input frm sensors  (Read 1690 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,944
  • Helpful? 99
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,944
  • Helpful? 99
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
    • dunk's robot
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

 


data_list