Display pot. value

Fork of IPI_Singapore_Workshop by IPI Singapore Workshop

main.cpp

Committer:
alansim
Date:
2017-11-22
Revision:
2:10f92fa42985
Parent:
1:2792d77cc2cc

File content as of revision 2:10f92fa42985:

//----------------------------------------------------------------------------
// The confidential and proprietary information contained in this file may
// only be used by a person authorised under and to the extent permitted
// by a subsisting licensing agreement from ARM Limited or its affiliates.
//
// (C) COPYRIGHT 2016 ARM Limited or its affiliates.
// ALL RIGHTS RESERVED
//
// This entire notice must be reproduced on all copies of this file
// and copies of this file may only be made by a person if such person is
// permitted to do so under the terms of a subsisting license agreement
// from ARM Limited or its affiliates.
//----------------------------------------------------------------------------
 
#include "mbed.h"
 
// GLOBAL VARIABLES HERE
AnalogIn pot1(A0);
EventQueue queue;
 
// FUNCTION DEFINITIONS HERE
void read_potentiometer() {
    static float potentiometer_val = 0;
    if ((float)pot1 != potentiometer_val) {
        potentiometer_val = (float)pot1;
        printf("Analog Reading: %.2f\r\n",  potentiometer_val);
    }
 }
 
  
int main()
{
    // MAIN CODE HERE
    queue.call_every(100, read_potentiometer);
    while(1){
        wait_ms(100);
        queue.dispatch(0);
    }
}