Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Measure Volts.c
- Make voltmeter style measurements with the Propeller Activity Board.
- http://learn.parallax.com/propeller-c-simple-circuits/measure-volts
- */
- #include "simpletools.h" // Include simpletools
- #include "adcDCpropab.h" // Include adcDCpropab
- int main() // Main function
- {
- pause(1000); // Wait 1 s for Terminal app
- adc_init(21, 20, 19, 18); // CS=21, SCL=20, DO=19, DI=18
- float v2, v3; // Voltage variables
- int ad2, ad3;
- while(1) // Loop repeats indefinitely
- {
- v3 = adc_volts(3); // Check A/D 3
- putchar(HOME); // Cursor -> top-left "home"
- if (v3 > 2.0)
- {
- printf("ad3 = %d%c\n", ad3, CLREOL);
- printf("Too Warm!");
- }
- else if (v3 < 1.0)
- {
- printf("ad3 = %d%c\n", ad3, CLREOL);
- printf("Too Cold!"); // Display volts
- }
- else if (v3 >=1.0 && v3 <=2.0)
- {
- printf("ad3 = %d%c\n", ad3, CLREOL);
- printf("Just Right!"); // Display volts
- }
- pause(100); // Wait 1/10 s
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement