]> git.piffa.net Git - arduino/blob - books/ArduinoNextSteps-master/ArduinoNextSteps/sketch_04_12_analog_fast/sketch_04_12_analog_fast.ino
first commit
[arduino] / books / ArduinoNextSteps-master / ArduinoNextSteps / sketch_04_12_analog_fast / sketch_04_12_analog_fast.ino
1 // sketch 04_11_analog
2
3 const byte PS_128 = (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0);
4 const byte PS_16 = (1 << ADPS2);
5
6 void setup()
7 {
8   ADCSRA &= ~PS_128;  // remove prescale of 128
9   ADCSRA |= PS_16;    // add prescale of 16 (1MHz)
10   Serial.begin(9600);
11   while (! Serial) {};
12   Serial.println(PS_128, 2);
13   Serial.println(PS_16, 2); 
14   Serial.println("Starting Test");
15   long startTime = millis();
16   
17   // test code here
18   long  i = 0;
19   for (i = 0; i < 1000000; i ++)
20   {
21     analogRead(A0);
22   }
23   // end of test code
24   long endTime = millis();
25   
26   Serial.println("Finished Test");
27   Serial.print("Seconds taken: "); 
28   Serial.println((endTime - startTime) / 1000l);
29 }
30
31 void loop()
32 {
33 }