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?

More than 3 years have passed since last update.

vistaでstm32duino その15

Posted at

概要

vistaでstm32duinoやってみた。
rgbled、やってみた。

サンプルコード

# define G0			12
# define R0			0
# define B0			0
# define L_NUM 		7
char l[L_NUM * 3];

void bit_off() {
	digitalWrite(PC13, HIGH);
	digitalWrite(PC13, LOW);
	digitalWrite(PC13, LOW);
}

void bit_on() {
	digitalWrite(PC13, HIGH);
	digitalWrite(PC13, HIGH);
	digitalWrite(PC13, LOW);
}

void ws_led() {
	for (char ii = 0; ii < (L_NUM * 3); ii++)
	{
		if (l[ii] & 0b10000000)
		{
			bit_on();
		}
		else
		{
			bit_off();
		}
		if (l[ii] & 0b01000000)
		{
			bit_on();
		}
		else
		{
			bit_off();
		}
		if (l[ii] & 0b00100000)
		{
			bit_on();
		}
		else
		{
			bit_off();
		}
		if (l[ii] & 0b00010000)
		{
			bit_on();
		}
		else
		{
			bit_off();
		}
		if (l[ii] & 0b00001000)
		{
			bit_on();
		}
		else
		{
			bit_off();
		}
		if (l[ii] & 0b00000100)
		{
			bit_on();
		}
		else
		{
			bit_off();
		}
		if (l[ii] & 0b00000010)
		{
			bit_on();
		}
		else
		{
			bit_off();
		}
		if (l[ii] & 0b00000001)
		{
			bit_on();
		}
		else
		{
			bit_off();
		}
	}
}
void ws_led_cl() {
	for (char ii = 0; ii < (L_NUM * 3); ii++)
	{
		bit_off();
		bit_off();
		bit_off();
		bit_off();
		bit_off();
		bit_off();
		bit_off();
		bit_off();
	}
}
void setup() {
	pinMode(PC13, OUTPUT);
	pinMode(PA0, INPUT_PULLUP);
	for (char ii = 0; ii < L_NUM; ii++)
	{
		l[(ii * 3) + 0] = G0;
		l[(ii * 3) + 1] = R0;
		l[(ii * 3) + 2] = B0;
	}
}
void loop() {
	if (digitalRead(PA0) == 0)
	{
		ws_led_cl();
	}
	else
	{
		ws_led();
	}
	delay(100);
}





配線

vdd - 3.3v
gnd -gnd
data - PC13

以上。

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?