#include "mbed.h" DigitalOut myled1(PA_1); DigitalOut myled2(PA_2); DigitalOut myled3(PA_3); DigitalOut myled4(PA_4); DigitalOut myled5(PA_5); DigitalOut myled6(PA_6); DigitalOut myled7(PA_7); DigitalOut myled8(PB_1); //DigitalIn myin10(PA_10); DigitalIn myin9(PA_9); char seg[16][8] = { { 0,0,0,1,0,0,0,1 }, //0 { 1,0,1,1,1,1,0,1 }, //1 { 0,0,1,0,0,0,1,1 }, //2 { 0,0,1,0,1,0,0,1 }, //3 { 1,0,0,0,1,1,0,1 }, //4 { 0,1,0,0,1,0,0,1 }, //5 { 0,1,0,0,0,0,0,1 }, //6 { 0,0,0,1,1,1,0,1 }, //7 { 0,0,0,0,0,0,0,1 }, //8 { 0,0,0,0,1,1,0,1 }, //9 { 1,1,1,1,1,1,1,1 }, //10 { 1,1,1,1,1,1,1,1 }, //11 { 1,1,1,1,1,1,1,1 }, //12 { 1,1,1,1,1,1,1,1 }, //13 { 1,1,1,1,1,1,1,1 } //14 }; int main() { int a; int b; int c; int d; int s; s=8; //while(1) { myled1 = seg[s][0];myled2 = seg[s][1];myled3 = seg[s][2];myled4 = seg[s][3]; myled5 = seg[s][4];myled6 = seg[s][5];myled7 = seg[s][6];myled8 = seg[s][7]; // wait(1); // s=s+1; // if (s >=10) { s=0;} //} while(1) { while( myin9 == 1 ) {} wait(0.035); a=!(myin9); wait(0.035); b=!(myin9); wait(0.035); c=!(myin9); wait(0.035); d=!(myin9); wait(0.035); s=d*8+c*4+b*2+a; myled1 = seg[s][0];myled2 = seg[s][1];myled3 = seg[s][2];myled4 = seg[s][3]; myled5 = seg[s][4];myled6 = seg[s][5];myled7 = seg[s][6];myled8 = seg[s][7]; } } ichgojam 側 10 'START 0.5 DATA 4BIT SOTP 1 20 OUT 11,1:WAIT 15 30 R=RND(10) 40 GOSUB 100 50 IF BTN(0)=1 THEN BEEP:END 60 GOTO 30 100 ' 110 OUT 11,0:WAIT 1 120 FOR S=0 TO 3 130 OUT 11,!( (R >> S)&1 ) 140 WAIT 2 150 NEXT 160 OUT 11,1 170 WAIT 2 180 RETURN