Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: DS1620_improved TextLCD_improved mbed-rtos mbed
main.cpp
- Committer:
- dzoni
- Date:
- 2015-12-12
- Revision:
- 1:90328beebfbc
- Parent:
- 0:75ede6a15252
- Child:
- 2:c190b9b39089
File content as of revision 1:90328beebfbc:
#include "mbed.h"
#include "DS1620.h"
#include "TextLCD.h"
 
DigitalOut myled(LED1);
int main() {
    wait_us(1000000);
    TextLCD lcd(PA_8, PA_7, PA_9, PA_1, PB_5, PA_10, TextLCD::LCD16x2);
    
    DS1620 ds1620Sensor(PB_4, PB_10, PB_3);
    
    float       temperature;
    uint32_t    uiCnt=0;
    ds1620Sensor.setSerialClockFrequency(freq500k);
    if ((ds1620Sensor.readConfig() & 0x03) != 0x03) {
        ds1620Sensor.writeConfig(0x03);
    }
    while(1) {   
        myled = myled ^ 1; 
    
        ds1620Sensor.startConversion();
        // Wait for conversion completion (Tconv = 750 ms typ)
        wait_us(750000);
        while (!(ds1620Sensor.readConfig() & 0x80))
            wait_us(10000);
        
        temperature = ds1620Sensor.getHighResolutionTemperature();
        
        lcd.cls();
        lcd.printf("Raw: %u", ds1620Sensor.readTemperatureRaw());
        uiCnt += 1;
        lcd.locate(0, 1);    
        lcd.printf("Float: %3.2f%cC", temperature, 0xdf);
        
        wait_us(250000);
    }
}