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.
Homepage
This code is only partially working for me. Not every download seems to be successful on Mac OS X. I just took the example files and hacked them around to get it working with mbed. If you want working code I think Erik Olieman's SLCD project is probably a better source.
main.cpp
//KL46Z try out
#include "mbed.h"
#include "TSISensor.h"
#include "MMA8451Q.h"
#include "MAG3110.h"
#include "vfnLCD.h"
#include <cstdlib>
#include <iostream>
Serial pc(USBTX, USBRX);
TSISensor tsi;
MMA8451Q acc51(PTE25, PTE24, 0x1D<<1);
MAG3110 mag(PTE25, PTE24, 0x0E<<1);
vfnLCD lcd;
PwmOut rled(PTE29);
PwmOut gled(PTD5);
AnalogIn lightSensor(PTE22);
//DigitalIn SW1(PTC3);
//DigitalIn SW3(PTC12);
//AnalogOut lcd03(PTB23);
//PwmOut lcd07(PTB7);
char chBufDisp[10];
int main()
{
using namespace std;
float onTime = 1.0;
float offTime = 0.0;
float holdTime = 1.0;
bool on = true;
bool off = false;
int magX = 0, magY = 0, magZ = 0;
int count=100;
uint8_t message[]="1234";
lcd.vfnLCD_All_Segments_ON();
while(true) {
cout << "I'm alive and running\n\r";
rled = onTime - abs(acc51.getAccX());
gled = onTime - abs(acc51.getAccY());
mag.getValues(&magX, &magY, &magZ);
cout << "MMA8451: " << acc51.getAccX() << "\t" << acc51.getAccY() << "\t" << acc51.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: " << SW1 << "\n\r" << endl;
cout << "SW3: " << SW3 << "\n\r" << endl;
cout << "Light Sensor: " << lightSensor << "\n\r" << endl;
sprintf(chBufDisp,"%04i",count);
lcd.vfnLCD_Write_Msg((uint8_t *)chBufDisp);
count++;
if (count>9999) count=0;
wait(holdTime);
}
return 0;
}