View difference between Paste ID: 5NeN8HTg and Z3BDPCry
SHOW: | | - or go back to the newest paste.
1
/*
2
  Measure Volts.c
3
4
  Make voltmeter style measurements with the Propeller Activity Board.
5
6
  http://learn.parallax.com/propeller-c-simple-circuits/measure-volts
7
*/
8
9
#include "simpletools.h"                      // Include simpletools
10
#include "adcDCpropab.h"                      // Include adcDCpropab
11
12
int main()                                    // Main function
13
{
14
  pause(1000);                                // Wait 1 s for Terminal app
15
  adc_init(21, 20, 19, 18);                   // CS=21, SCL=20, DO=19, DI=18
16
17
  float v2, v3;                               // Voltage variables
18
  int ad2, ad3;
19
20
  while(1)                                    // Loop repeats indefinitely
21
  {                 
22
    v3 = adc_volts(3);                        // Check A/D 3
23
    
24
    putchar(HOME);                            // Cursor -> top-left "home"
25
    if (v3 > 2.0)
26
    { 
27
      printf("ad3 = %d%c\n", ad3, CLREOL);
28
      printf("Too Warm!");
29
    }
30-
    else (v3 < 1.0)
30+
    else if (v3 < 1.0)
31
    {
32
      printf("ad3 = %d%c\n", ad3, CLREOL);
33
      printf("Too Cold!");    // Display volts
34
    }
35-
    else (v3 >=1.0 && v3 <=2.0)
35+
    else if (v3 >=1.0 && v3 <=2.0)
36
    {
37
      printf("ad3 = %d%c\n", ad3, CLREOL);
38
      printf("Just Right!");    // Display volts
39
    }
40
    pause(100);                               // Wait 1/10 s
41
  }  
42
}