When your microcontroller needs to interact with the outside world, it uses its peripherals—things like GPIOs, UARTs, SPI and I2C buses, analog inputs, PWM outputs, and so on. In .NET nanoFramework, all these common interfaces are exposed with friendly C# APIs. Empowered with these, you can set up pins, read sensors, drive displays, and even use advanced protocols with only a few lines of code. For example, using the nanoFramework IoT device bindings, reading a BME280 temperature/pressure sensor over I2C is almost trivial—you just create an I2cDevice, pass it to the Bme280 class, and call its Read() method. In fact, nanoFramework’s APIs align closely with the .NET IoT Core libraries, so much of your code is identical between a PC or Raspberry Pi and a tiny microcontroller.

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

Interfacing with the Outside World

  • José Simões

摘要

When your microcontroller needs to interact with the outside world, it uses its peripherals—things like GPIOs, UARTs, SPI and I2C buses, analog inputs, PWM outputs, and so on. In .NET nanoFramework, all these common interfaces are exposed with friendly C# APIs. Empowered with these, you can set up pins, read sensors, drive displays, and even use advanced protocols with only a few lines of code. For example, using the nanoFramework IoT device bindings, reading a BME280 temperature/pressure sensor over I2C is almost trivial—you just create an I2cDevice, pass it to the Bme280 class, and call its Read() method. In fact, nanoFramework’s APIs align closely with the .NET IoT Core libraries, so much of your code is identical between a PC or Raspberry Pi and a tiny microcontroller.