PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
MeasureVolts_Demo.c

Make voltmeter style measurements with the Propeller Activity Board.

http://learn.parallax.com/propeller-c-simple-circuits/measure-volts

cmake_minimum_required(VERSION 3.12)
find_package(PropWare REQUIRED)
project(Simple_MeasureVolts)
create_simple_executable(${PROJECT_NAME} MeasureVolts_Demo.c)
#include "simpletools.h" // Include simpletools
#include "adcDCpropab.h" // Include adcDCpropab
int main () // Main function
{
adc_init(21, 20, 19, 18); // CS=21, SCL=20, DO=19, DI=18
float v2, v3; // Voltage variables
while (1) // Loop repeats indefinitely
{
v2 = adc_volts(2); // Check A/D 2
v3 = adc_volts(3); // Check A/D 3
putChar(HOME); // Cursor -> top-left "home"
print("A/D2 = %f V%c\n", v2, CLREOL); // Display volts
print("A/D3 = %f V%c\n", v3, CLREOL); // Display volts
pause(100); // Wait 1/10 s
}
}
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
putChar
void putChar(char c)
Print a char to the debug port.
Definition: putChar.c:30
CLREOL
#define CLREOL
CLREOL character (11) erases all SimpleIDE Terminal characters to the right of the cursor.
Definition: simpletools.h:323
PropWare
Generic definitions and functions for the Parallax Propeller.
Definition: runnable.h:33