0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

M5StackCore2: FIFO のキューのサンプル

Last updated at Posted at 2024-08-31

プログラム

fifo_example.ino
#include <string>
#include <queue>

std::queue<std::string> stringQueue;

void setup() {
	Serial.begin(115200);
	Serial.println("*** setup aaa ***");
	delay(1000);
	Serial.println("*** setup bbb ***");
	delay(1000);
	Serial.println("*** setup ccc ***");
	delay(1000);
}

void loop() {
	// キューに文字列を追加する
	stringQueue.push("Hello");
	stringQueue.push("World");
	stringQueue.push("Arduino");
	stringQueue.push("Good");
	stringQueue.push("Morning");

	// キューから文字列を取り出す
	while (!stringQueue.empty()) {
		std::string str = stringQueue.front();
		stringQueue.pop();
		Serial.println(str.c_str());
	delay(1000);
	}

	Serial.println("");

	delay(2000);
}

Arduino IDE

image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?