Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float mAh = 0;
- int time_m = 0;
- void setup()
- {
- Serial.begin( 9600 );
- for ( int i = 10; i > 0; i-- )
- {
- Serial.print ( i );
- delay ( 1000 );
- }
- Serial.println( "GO!" );
- }
- void loop( ) {
- float average = 0;
- for( int i = 0; i < 1000; i++ ) // 1000 samples
- {
- float sample = ( 26.4 * analogRead( A0 ) - 13510 ) / 1000;
- if ( sample > 0 )
- {
- average += sample;
- }
- delay( 60 ); // every 60 ms
- }
- mAh += average / 60;
- time_m++;
- Serial.print ( time_m );
- Serial.print ( ", min, " );
- Serial.print ( average );
- Serial.print ( ", mA, " );
- Serial.print ( mAh );
- Serial.println( ", mAh" );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement