1. Home
  2. /
  3. Mbed-c-cpp-python
  4. /
  5. Read Analog Sensor (C++)

Read Analog Sensor (C++) - Mbed-c-cpp-python Typing CST Test

Loading…

Read Analog Sensor (C++) — Mbed-c-cpp-python Code

Read analog input from pin A0 and print to serial.

#include "mbed.h"

AnalogIn sensor(A0);
Serial pc(USBTX, USBRX);

int main() {
	while (true) {
		float value = sensor.read();
		pc.printf("Sensor value: %f\n", value);
		ThisThread::sleep_for(200ms);
	}
}

Mbed-c-cpp-python Language Guide

MBed is an open-source platform for developing IoT and embedded applications using C, C++, and Python. It provides an OS, hardware abstraction libraries, and development tools to rapidly create, test, and deploy programs on ARM Cortex-M microcontrollers.

Primary Use Cases

  • ▸Develop firmware for ARM Cortex-M microcontrollers using C/C++
  • ▸Rapid prototyping of embedded IoT devices
  • ▸Interfacing with sensors and actuators
  • ▸Running MicroPython scripts for lightweight embedded tasks
  • ▸Deploying secure, connected devices with MBed OS

Notable Features

  • ▸Real-time operating system (RTOS) support
  • ▸MBed libraries for networking, storage, and drivers
  • ▸Hardware abstraction layer for multi-platform support
  • ▸Cloud and IoT integration tools
  • ▸MicroPython support for scripting on microcontrollers

Origin & Creator

Developed by ARM in 2011 to simplify IoT development and standardize embedded software across ARM Cortex-M microcontrollers.

Industrial Note

Extensively used in IoT devices, industrial automation, wearable electronics, robotics, and rapid prototyping of ARM-based microcontrollers.

More Mbed-c-cpp-python Typing Exercises

Blink LED (C++)Control Servo Motor (Python / MicroPython)

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher