A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://reference.wolfram.com/language/MicrocontrollerKit/ref/MicrocontrollerEmbedCode.html below:

MicrocontrollerEmbedCode—Wolfram Documentation

WOLFRAM Consulting & Solutions

We deliver solutions for the AI era—combining symbolic computation, data-driven insights and deep technical expertise

WolframConsulting.com

Additional Specifications   Generalizations & Extensions  

MicrocontrollerEmbedCode[sys,μc,p]

embeds the systems model sys to the microcontroller μc using p.

Details and Options Examplesopen all close all Basic Examples  (1)

Load the package:

Turn the LED on an Adafruit Trinket 5V at half brightness:

The byte count of the embedded machine code:

The source code that was compiled to generate the machine code:

Scope  (37) Digital Output  (2)

Turn on the LED connected to pin 13:

A systems model with no input, and a state output that toggles every 2 seconds:

Use it to blink the LED attached to pin 13:

Pulse Output  (2)

Turn pin 13 on for one second during each cycle of 4 seconds:

Specify the sampling period of the pulse to be different from the overall sampling period:

Analog Output  (5)

Turn on the LED connected to pin 3 at half brightness:

Turn it on at a different brightness level:

Analog output only works with pins having pulse-width modulation:

Specify a range, if necessary, to properly scale the output:

Get the LED to glow with maximum brightness:

Half brightness:

Analog signals with positive and negative values need a second pin for direction:

The LED at pin 3 glows with half brightness and the LED at pin 4 is turned on:

The LED at pin 4 is turned off:

The LED at pin 4 is turned on for positive values:

The pin 4 LED is turned off for negative values:

Specify a desired waveform generation mode:

Analog Input  (3)

Read the potentiometer connected to "A0" and use it to adjust the brightness of the LED on pin 3:

Use different voltage references:

Use the voltage of 5V applied at the "AVCC" pin:

Use the internal reference voltage:

Use the voltage of 3.3V applied at the AREF pin:

Specify the prescaler to be used by the input clock of the ADC:

Digital Input  (3)

Turn the LED on pin 3 on and off using a button attached to pin 8:

Turn on the LED using the logic value:

Set the LED brightness using the number of toggles, assumed to be a maximum of 5 every 10 seconds:

Use the number of rising edges:

The number of falling edges:

The number of low counts:

Serial (RS-232) Communication  (2)

Set up the microcontroller to send and receive numerical data:

The serial type can also be directly given, since the serial pins are unique on the Arduino Uno:

Open a serial connection to the device:

Set up a task to read and write data:

Remove the task and close the device after some time:

Compare the sent and received values:

Specify the real-time baudrate to use:

Serial Peripheral Interface (SPI) Communication  (1)

The MAX6675 thermocouple is a SPI sensor whose data can to be read in two bytes: »

The conversion from bytes to obtain the temperature in ° C:

Specify the sensor as a SPI slave device with pin 7 as the slave select pin:

The output is sent over the serial (RS-232) channel:

Embed code to read the sensor and transmit the result:

Open a connection to the Arduino:

Set up a scheduled task to read the data:

Remove the task and close the device after some time:

The temperature plot:

Inter-Integrated Circuit (I2C) Communication  (1)

Measure the temperature using a MPU6050 sensor. The data is in two registers beginning at 0x41: »

The sensor address is 0x68 and its power management register at 0x6B needs to be initialized:

A function to assemble the two bytes that are received:

The systems model to convert it to degrees C:

The model to output a high value if the temperature is over 25° C:

The complete model which reads the temperature and outputs a high or low value:

The embedded code will turn on an LED at pin if the temperature is greater than 25° C:

External Libraries  (1)

Use an external library that is at a known location:

Specify the header file along with the code that needs to be invoked at various stages:

Embed code that utilizes the library:

Systems Models  (6)

Embed a system with two inputs and one output:

Embed a system with two inputs and two outputs:

The serial start, delimiter, and end bytes:

Open a connection to the microcontroller:

Set up a task that sends one input signal and receives two output signals every time period:

A function to parse the actual and reference speed values coming though the serial connection:

Remove the task and close the device after some time:

Plot the outputs:

Specify a state-space model directly as a difference equation:

Embed the system:

Embed a nonlinear model of a simple pendulum:

Discretize the system:

Embed the system:

Embed a SystemsConnectionsModel of a simple pendulum:

The input torque is simulated with a joystick which has an equilibrium value of 2.525:

The complete system:

Embed the system:

Open a serial connection to the target:

A function to parse the data and a variable to store the data:

Set up a scheduled task to read the values every 0.01 seconds:

Remove the task and close the connection after some time:

The simulated result:

Embed a model having bitwise operations:

Targets  (2)

ATmega328P_28PDIP microcontroller with an external 20 MHz clock and pin 15 set as output:

Use an Arduino as the programmer:

Embed code to blink an LED connected to pin 15:

ATmega168A_28PDIP microcontroller with factory settings:

Missing Physical Target  (1)

If no hardware is connected, the code cannot be embedded:

The code is not embedded if the connection port is specified as None:

External Programmer  (1)

Program the microcontroller using an usbasp programmer:

Timer  (1)

Specify which timer the microcontroller should use:

Properties  (1)

Obtain a list of available properties from the MicrocontrollerCodeData object:

Extract a property value:

All property values related to serial communication:

Additional Specifications  (5)

Create a directory to preserve intermediate files:

Deploy the code and preserve the intermediate files:

The intermediate files:

Delete them:

By default, intermediate files are deleted:

Delete the directory:

Specify the path to the compiler:

Specify the compiler's name:

Typically the generated source code is in C:

Use the Wiring language (used by Arduino sketches):

Generate the source code without compiling and embedding it to the target:

Generalizations & Extensions  (1)

A system specified as an expression:

Its equivalent systems model specification:

The data objects:

The generated code is the same in both cases:

Possible Issues  (2)

Only discrete-time systems models can be embedded:

Discretize the system:

Embed the discrete-time system:

In a connections model, all the subsystems must have the same sampling period:

Resample one system to match the other:

Embed the system with subsystems all having the same sampling period:

Wolfram Research (2019), MicrocontrollerEmbedCode, Wolfram Language function, https://reference.wolfram.com/language/MicrocontrollerKit/ref/MicrocontrollerEmbedCode.html. Text

Wolfram Research (2019), MicrocontrollerEmbedCode, Wolfram Language function, https://reference.wolfram.com/language/MicrocontrollerKit/ref/MicrocontrollerEmbedCode.html.

CMS

Wolfram Language. 2019. "MicrocontrollerEmbedCode." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/MicrocontrollerKit/ref/MicrocontrollerEmbedCode.html.

APA

Wolfram Language. (2019). MicrocontrollerEmbedCode. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/MicrocontrollerKit/ref/MicrocontrollerEmbedCode.html

BibTeX

@misc{reference.wolfram_2025_microcontrollerembedcode, author="Wolfram Research", title="{MicrocontrollerEmbedCode}", year="2019", howpublished="\url{https://reference.wolfram.com/language/MicrocontrollerKit/ref/MicrocontrollerEmbedCode.html}", note=[Accessed: 17-August-2025]}

BibLaTeX

@online{reference.wolfram_2025_microcontrollerembedcode, organization={Wolfram Research}, title={MicrocontrollerEmbedCode}, year={2019}, url={https://reference.wolfram.com/language/MicrocontrollerKit/ref/MicrocontrollerEmbedCode.html}, note=[Accessed: 17-August-2025]}


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4