x 過去ログを見よ
D0からD7まで
//GPIO_Knight_Rider1_test_767_1
#define DW digitalWrite
void GPIO_D0_D7(int s)
{
digitalWrite(7, (s>>7) & 0x01); // turn the LED on (HIGH is the voltage level)
digitalWrite(6, (s>>6) & 0x01); // turn the LED on (HIGH is the voltage level)
digitalWrite(5, (s>>5) & 0x01); // turn the LED on (HIGH is the voltage level)
digitalWrite(4, (s>>4) & 0x01); // turn the LED on (HIGH is the voltage level)
digitalWrite(3, (s>>3) & 0x01); // turn the LED on (HIGH is the voltage level)
digitalWrite(2, (s>>2) & 0x01); // turn the LED on (HIGH is the voltage level)
digitalWrite(1, (s>>1) & 0x01); // turn the LED on (HIGH is the voltage level)
digitalWrite(0, s & 0x01); // turn the LED on (HIGH is the voltage level)
} //GPIO_D0_D7
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(PB7, OUTPUT);
pinMode(0, OUTPUT);
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
} //setup
void loop() {
digitalWrite(PB7, HIGH); // turn the LED on (HIGH is the voltage level)
GPIO_D0_D7(0x01);
delay(1000); // wait for a second
digitalWrite(PB7, LOW); // turn the LED off by making the voltage LOW
GPIO_D0_D7(0x02);
delay(1000); // wait for a second
digitalWrite(PB7, HIGH); // turn the LED on (HIGH is the voltage level)
GPIO_D0_D7(0x04);
delay(1000); // wait for a second
digitalWrite(PB7, LOW); // turn the LED off by making the voltage LOW
GPIO_D0_D7(0x08);
delay(1000); // wait for a second
digitalWrite(PB7, HIGH); // turn the LED on (HIGH is the voltage level)
GPIO_D0_D7(0x10);
delay(1000); // wait for a second
digitalWrite(PB7, LOW); // turn the LED off by making the voltage LOW
GPIO_D0_D7(0x20);
delay(1000); // wait for a second
digitalWrite(PB7, HIGH); // turn the LED on (HIGH is the voltage level)
GPIO_D0_D7(0x40);
delay(1000); // wait for a second
digitalWrite(PB7, LOW); // turn the LED off by making the voltage LOW
GPIO_D0_D7(0x80);
delay(1000); // wait for a second
} //loop