| Arduino | mBed |
|---|---|
| Basic GPIO | |
void foo()
{
pinMode(4, INPUT_PULLUP);
pinMode(5, OUTPUT);
digitalWrite(5, !digitalRead(4));
}
|
void foo()
{
DigitalIn pin4(D4, PullUp);
DigitalOut pin5(D5);
pin5 = !pin4;
}
|
| Attach interrupt to pin 3 | |
void callback() {}
|
void callback() {}
|
| Waiting | |
void foo()
{
// Wait 60 seconds. Note that the L suffix is required because
// the Uno boards are 16 bit, and int can only go up to 32767.
delay(60 * 1000L);
|
void foo()
{
// Wait 60 seconds.
wait(60);
// Or using integers (faster on processors without FPU). mBed boards
// are 32-bit so no need for an L suffix.
wait_ms(60 * 1000);
|
| Get system time in milliseconds | |
unsigned long t = millis();
|
// clock() returns microseconds since boot in a 64-bit integer.
unsigned int t = clock() / 1000;
|
| Periodically call function | |
void callback() { }
|
|
| Time a function call | |
| Use PWM | |
| Write to serial port | |
| Quickly read/write multiple GPIOs | |
| Use SPI | |
| Use I2C | |
| Analogue Input | |
void setup()
{
pinMode(A0, INPUT);
}
void foo()
{
int x = analogRead(A0);
|
AnalogIn ain(A0);
|
| Analogue Output | |
| Not possible |
AnalogOut aout(A0);
|
| SD cards | |
| Run multithreaded code | |
| Print to serial | |
void setup()
{
Serial.begin(115200);
}
|
Serial serial(USBTX, USBRX);
|
Last active
August 29, 2015 14:24
-
-
Save Timmmm/7f57c09132514d674181 to your computer and use it in GitHub Desktop.
Arduino vs mBed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment