/elec/quadcopter

To get this branch, use:
bzr branch http://bzr.ed.am/elec/quadcopter

« back to all changes in this revision

Viewing changes to test/receiver/pulse-freq/main.ino

  • Committer: Tim Marston
  • Date: 2013-01-16 21:42:06 UTC
  • Revision ID: tim@ed.am-20130116214206-5mw4cgsya1h0yiyq
updated arduino.mk

Show diffs side-by-side

added added

removed removed

7
7
// This program tries to measure the frequency of the signal pulses in
8
8
// microseconds.  It takes several measurements and prints out the average over
9
9
// serial.
10
 
 
 
10
//
11
11
 
12
12
// number of signal pulses to average
13
13
#define SIGNAL_SAMPLES 10
50
50
                {
51
51
                        // check interval
52
52
                        unsigned long interval = new_pulse - last_pulse;
53
 
                        if( false && interval < 300 )
 
53
                        if( interval < 300 )
54
54
                        {
55
55
                                Serial.print( "[" );
56
56
                                Serial.print( last_pulse );
75
75
                if( interval_idx == 0 && got_pulse )
76
76
                {
77
77
                        // calculate average
78
 
                        long interval = 0;
79
 
                        for( int a = 0; a < SIGNAL_SAMPLES; a++ )
80
 
                                interval += intervals[ a ];
81
 
                        
82
 
                        Serial.print( intervals[ 0 ] );
83
 
                        Serial.println();
 
78
                        for( int a = 0; a < SIGNAL_SAMPLES; a++ ) {
 
79
                                Serial.print( intervals[ a ] );
 
80
                                if( a == SIGNAL_SAMPLES - 1 )
 
81
                                        Serial.println();
 
82
                                else
 
83
                                        Serial.print( " " );
 
84
                        }
84
85
                }               
85
86
        }
86
87
}