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: MAG3110 MMA8451Q TSI SLCD mbed-src
main.cpp
- Committer:
- jppang
- Date:
- 2014-02-09
- Revision:
- 2:e3770fac7512
- Parent:
- 1:96fe777bad5a
- Child:
- 3:6b371e451f9e
File content as of revision 2:e3770fac7512:
#include "mbed.h"
#include "TSISensor.h"
#include "MMA8451Q.h"
#include "MAG3110.h"
#include <cstdlib>
#include <iostream>
Serial pc(USBTX, USBRX);
TSISensor tsi;
MMA8451Q acc(PTE25, PTE24, 0x1D<<1);
MAG3110 mag(PTE25, PTE24, 0x0E<<1);
PwmOut rled(PTE29);
PwmOut gled(PTD5);
AnalogIn lightSensor(PTE22);
InterruptIn s1(PTC3);
InterruptIn s3(PTC12);
int main()
{
using namespace std;
float onTime = 1.0;
// float offTime = 0.0;
float holdTime = 1.0;
int magX = 0, magY = 0, magZ = 0;
while(1) {
rled = onTime - abs(acc.getAccX());
gled = onTime - abs(acc.getAccY());
mag.getValues(&magX, &magY, &magZ);
cout << "MMA8451: " << acc.getAccX() << "\t" << acc.getAccY() << "\t" << acc.getAccZ() << "\n\r" << endl;
cout << "MAG3110: " << magX << "\t" << magY << "\t" << magZ << "\n\r" << endl;
cout << "MAG3110: " << mag.getHeading() << "\n\r" << endl;
wait(holdTime);
rled = tsi.readPercentage();
gled = tsi.readPercentage();
cout << "Touch: " << tsi.readPercentage() << "\n\r" << endl;
cout << "SW1: " << s1 << "\n\r" << endl;
cout << "SW3: " << s3 << "\n\r" << endl;
cout << "Light Sensor: " << lightSensor << "\n\r" << endl;
wait(holdTime);
}
}