Move Example to proper folder
This commit is contained in:
parent
be081ac026
commit
77810471ce
@ -1,97 +1,97 @@
|
|||||||
#if CONFIG_FREERTOS_UNICORE
|
#if CONFIG_FREERTOS_UNICORE
|
||||||
#define ARDUINO_RUNNING_CORE 0
|
#define ARDUINO_RUNNING_CORE 0
|
||||||
#else
|
#else
|
||||||
#define ARDUINO_RUNNING_CORE 1
|
#define ARDUINO_RUNNING_CORE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef LED_BUILTIN
|
#ifndef LED_BUILTIN
|
||||||
#define LED_BUILTIN 13
|
#define LED_BUILTIN 13
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// define two tasks for Blink & AnalogRead
|
// define two tasks for Blink & AnalogRead
|
||||||
void TaskBlink( void *pvParameters );
|
void TaskBlink( void *pvParameters );
|
||||||
void TaskAnalogReadA3( void *pvParameters );
|
void TaskAnalogReadA3( void *pvParameters );
|
||||||
|
|
||||||
// the setup function runs once when you press reset or power the board
|
// the setup function runs once when you press reset or power the board
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|
||||||
// initialize serial communication at 115200 bits per second:
|
// initialize serial communication at 115200 bits per second:
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
||||||
// Now set up two tasks to run independently.
|
// Now set up two tasks to run independently.
|
||||||
xTaskCreatePinnedToCore(
|
xTaskCreatePinnedToCore(
|
||||||
TaskBlink
|
TaskBlink
|
||||||
, "TaskBlink" // A name just for humans
|
, "TaskBlink" // A name just for humans
|
||||||
, 1024 // This stack size can be checked & adjusted by reading the Stack Highwater
|
, 1024 // This stack size can be checked & adjusted by reading the Stack Highwater
|
||||||
, NULL
|
, NULL
|
||||||
, 2 // Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest.
|
, 2 // Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest.
|
||||||
, NULL
|
, NULL
|
||||||
, ARDUINO_RUNNING_CORE);
|
, ARDUINO_RUNNING_CORE);
|
||||||
|
|
||||||
xTaskCreatePinnedToCore(
|
xTaskCreatePinnedToCore(
|
||||||
TaskAnalogReadA3
|
TaskAnalogReadA3
|
||||||
, "AnalogReadA3"
|
, "AnalogReadA3"
|
||||||
, 1024 // Stack size
|
, 1024 // Stack size
|
||||||
, NULL
|
, NULL
|
||||||
, 1 // Priority
|
, 1 // Priority
|
||||||
, NULL
|
, NULL
|
||||||
, ARDUINO_RUNNING_CORE);
|
, ARDUINO_RUNNING_CORE);
|
||||||
|
|
||||||
// Now the task scheduler, which takes over control of scheduling individual tasks, is automatically started.
|
// Now the task scheduler, which takes over control of scheduling individual tasks, is automatically started.
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
// Empty. Things are done in Tasks.
|
// Empty. Things are done in Tasks.
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------*/
|
/*--------------------------------------------------*/
|
||||||
/*---------------------- Tasks ---------------------*/
|
/*---------------------- Tasks ---------------------*/
|
||||||
/*--------------------------------------------------*/
|
/*--------------------------------------------------*/
|
||||||
|
|
||||||
void TaskBlink(void *pvParameters) // This is a task.
|
void TaskBlink(void *pvParameters) // This is a task.
|
||||||
{
|
{
|
||||||
(void) pvParameters;
|
(void) pvParameters;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Blink
|
Blink
|
||||||
Turns on an LED on for one second, then off for one second, repeatedly.
|
Turns on an LED on for one second, then off for one second, repeatedly.
|
||||||
|
|
||||||
If you want to know what pin the on-board LED is connected to on your ESP32 model, check
|
If you want to know what pin the on-board LED is connected to on your ESP32 model, check
|
||||||
the Technical Specs of your board.
|
the Technical Specs of your board.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// initialize digital LED_BUILTIN on pin 13 as an output.
|
// initialize digital LED_BUILTIN on pin 13 as an output.
|
||||||
pinMode(LED_BUILTIN, OUTPUT);
|
pinMode(LED_BUILTIN, OUTPUT);
|
||||||
|
|
||||||
for (;;) // A Task shall never return or exit.
|
for (;;) // A Task shall never return or exit.
|
||||||
{
|
{
|
||||||
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
|
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
|
||||||
vTaskDelay(100); // one tick delay (15ms) in between reads for stability
|
vTaskDelay(100); // one tick delay (15ms) in between reads for stability
|
||||||
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
|
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
|
||||||
vTaskDelay(100); // one tick delay (15ms) in between reads for stability
|
vTaskDelay(100); // one tick delay (15ms) in between reads for stability
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskAnalogReadA3(void *pvParameters) // This is a task.
|
void TaskAnalogReadA3(void *pvParameters) // This is a task.
|
||||||
{
|
{
|
||||||
(void) pvParameters;
|
(void) pvParameters;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
AnalogReadSerial
|
AnalogReadSerial
|
||||||
Reads an analog input on pin A3, prints the result to the serial monitor.
|
Reads an analog input on pin A3, prints the result to the serial monitor.
|
||||||
Graphical representation is available using serial plotter (Tools > Serial Plotter menu)
|
Graphical representation is available using serial plotter (Tools > Serial Plotter menu)
|
||||||
Attach the center pin of a potentiometer to pin A3, and the outside pins to +5V and ground.
|
Attach the center pin of a potentiometer to pin A3, and the outside pins to +5V and ground.
|
||||||
|
|
||||||
This example code is in the public domain.
|
This example code is in the public domain.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
// read the input on analog pin A3:
|
// read the input on analog pin A3:
|
||||||
int sensorValueA3 = analogRead(A3);
|
int sensorValueA3 = analogRead(A3);
|
||||||
// print out the value you read:
|
// print out the value you read:
|
||||||
Serial.println(sensorValueA3);
|
Serial.println(sensorValueA3);
|
||||||
vTaskDelay(10); // one tick delay (15ms) in between reads for stability
|
vTaskDelay(10); // one tick delay (15ms) in between reads for stability
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user