Embedded

Welcome!

This community is for professionals and enthusiasts of our products and services.
Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.

0

Arduino ส่งชื่อ function เป็น argument

Avatar
Liew Wuttipat

#include <Arduino.h>

void f2(int);
void f3(void (*)(int));
void (*user_fun)(int);

void setup()
{
    Serial.begin(9600);
    f2(5);
    f2(10);

    f3(f2);
    user_fun(12);
    user_fun(36);
}

void loop()
{
}

void f2(int num)
{
    Serial.print("F2 => ");
    Serial.println(num);
}

void f3(void (*fun)(int))
{
    user_fun = fun;
}

Put your question here.
Avatar
Discard