I've a basic project i'm working on in school to read some force sensors, and later i'll be using a wifly to send the readings to a database.
Problem is, I can't even get this mBed thing to read then print to terminal for testing. I had it working in about 15 seconds using my arduino, but mbed use is required. Its just different enough, I can't get it working. And this site is lacking in the basics of reading an analog pin and outputting data to terminal. I've spent my requisite 3 hours of head bashing and searching.
For the arduino:
int sensorValue = 0; //variable to store the sensor value in
void setup()
{
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop()
{
// read the analog in value:
sensorValue = analogRead(5); //reads pin 5
Serial.print("sensor = " );
Serial.println(sensorValue); //print the number to the serial port
delay(100);
}
And as far as i could get with the mbed:
#include "mbed.h"
AnalogIn input(p15);
Serial pc (USBTX,USBRX);
DigitalOut myled(LED1);
float sensorvalue=0;
int main() {
sensorvalue=input.read();
printf("Sensor Value: ");
printf(sensorvalue);
printf("\n");
wait_ms(100);
}
Needless to say, it didn't work.
I'm fairly confident this should be easy, there's just a big disconnect.
Probably the fact i'm a mechanical engineer. Any help would be greatly appreciated. Thank you for reading.
I've a basic project i'm working on in school to read some force sensors, and later i'll be using a wifly to send the readings to a database.
Problem is, I can't even get this mBed thing to read then print to terminal for testing. I had it working in about 15 seconds using my arduino, but mbed use is required. Its just different enough, I can't get it working. And this site is lacking in the basics of reading an analog pin and outputting data to terminal. I've spent my requisite 3 hours of head bashing and searching.
For the arduino:
And as far as i could get with the mbed:
Needless to say, it didn't work.
I'm fairly confident this should be easy, there's just a big disconnect. Probably the fact i'm a mechanical engineer. Any help would be greatly appreciated. Thank you for reading.