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: MAX31855 SDFileSystem mbed
main.cpp
- Committer:
- JLarkin
- Date:
- 2016-04-13
- Revision:
- 10:f5d4d5e30b9b
- Parent:
- 9:c97cd10b11ac
- Child:
- 11:1e56b710b568
File content as of revision 10:f5d4d5e30b9b:
#include "mbed.h"
#include "MAX31855.h"
#include "SDSaveFunction.h"
Serial pc(USBTX,USBRX);
SPI spi(NC,PTD3,PTD1);
SPI sdspi(PTE3,PTE1,PTE2);
DigitalIn eject(PTA4); // INT2
DigitalOut greenLed(LED2);
DigitalOut redLed(LED1);
MAX31855 thermometer1(spi,PTC4);
MAX31855 thermometer2(spi,PTC3);
AnalogIn solarPanel(PTB2);
Timer t;
int main()
{
greenLed = 1;
redLed = 0;
float temp1, temp2;
float lastTime = 0;
float dt = 0.5;
float voltage = 0;
float halfHour = 0;
float totalTime;
t.start();
mountSDCard();
openDataFile();
while (halfHour<=6) {
if (eject == 0) {
greenLed = 0;
redLed = 1;
break;
}
totalTime = 30*60*halfHour + t.read();
if (totalTime>lastTime+dt) {
lastTime = totalTime;
temp1 = thermometer1.read();
wait(.02);
temp2 = thermometer2.read();
voltage = solarPanel.read();
pc.printf("Voltage %f\t Temp1 %f\t Temp2 %f\t Time %f\r\n", voltage, temp1, temp2, lastTime);
writeData(lastTime, temp1, temp2, voltage);
}
if (t.read()>=30*60){
halfHour++;
t.reset();
}
}
closeDataFile();
}
