PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Simple Libraries
Convert
libadcDCpropab
libadcDCpropab.c
1
/*
2
* @file libadcDCpropab.c
3
*
4
* @author Andy Lindsay
5
*
6
* @copyright
7
* Copyright (C) Parallax, Inc. 2013. All Rights MIT Licensed.
8
*
9
* @brief Project and test harness for the adcDCpropab library.
10
*/
11
12
13
#include "
simpletools.h
"
// Include simpletools
14
#include "
adcDCpropab.h
"
// Include adcDCpropab
15
16
int
main
()
// Main function
17
{
18
pause
(1000);
// Wait 1 s for Terminal app
19
adc_init
(21, 20, 19, 18);
// CS=21, SCL=20, DO=19, DI=18
20
21
int
i = 0;
// Index variable
22
while
(1)
// Loop repeats indefinitely
23
{
24
if
(i == 4)
// After index = 3
25
{
26
i = 0;
// Reset to zero
27
print
(
"%c"
,
HOME
);
// Cursor home
28
}
29
print
(
"adc[%d] = %d%c\n"
, i,
// Display raw ADC
30
adc_in
(i),
CLREOL
);
31
print
(
"volts[%d] = %f%c\n\n"
,
// Display volts
32
i,
adc_volts
(i),
CLREOL
);
33
i++;
// Add 1 to index
34
pause
(100);
// Wait 1/10 s
35
}
36
}
adc_in
int adc_in(int channel)
Get value that corresponds to voltage measurement on one of the A/D converter's input channels....
Definition:
adcDCpropab.c:29
adc_init
void adc_init(int csPin, int sclPin, int doPin, int diPin)
Initialize A/D converter.
Definition:
adcDCpropab.c:21
HOME
#define HOME
HOME character (1) sends SimpleIDE Terminal's cursor to top-left "home" position.
Definition:
simpletools.h:233
pause
void pause(int time)
Delay cog from moving on to the next statement for a certain length of time.
Definition:
libws2812.c:125
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
print
int print(const char *format,...) __attribute__((format(printf
Print format "..." args to the default simple terminal device. The output is limited to 256 bytes.
main
int main(void)
Definition:
GraphicsTest.c:20
adcDCpropab.h
Measure ADC124S021 as either a voltage or a raw, 12-bit5 adc value. This library is intended for DC m...
adc_volts
float adc_volts(int channel)
Get a voltmeter style floating point voltage measurement from one of the A/D converter's input channe...
Definition:
adcDCVpropab.c:17
CLREOL
#define CLREOL
CLREOL character (11) erases all SimpleIDE Terminal characters to the right of the cursor.
Definition:
simpletools.h:323
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17