Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- osw
- Date:
- 2022-04-26
- Revision:
- 0:5a2173aca83d
File content as of revision 0:5a2173aca83d:
#include"mbed.h"
DigitalOut x(p21);//ser
DigitalOut a(p22);//rclk
DigitalOut b(p23);//srclk
DigitalOut c(p24);//srclr
Serial pc(USBTX,USBRX);
void srclk(){
b=1; wait_us(1); b=0;
}
void output(char outputdata,long time){
char t0,t1,t2,t3,t4,t5,t6,t7;
t0=outputdata>>7;//上位ビット
t1=outputdata<<1; t1/=128;
t2=outputdata<<2; t2/=128;
t3=outputdata<<3; t3/=128;
t4=outputdata<<4; t4/=128;
t5=outputdata<<5; t5/=128;
t6=outputdata<<6; t6/=128;
t7=outputdata<<7; t7/=128;
for(long i=0; i<time/20; i++){
srclk(); x=1; c=1;
srclk(); x=0; c=1;
a=(int)t0; wait_us(1); a=0; srclk();
a=(int)t1; wait_us(1); a=0; srclk();
a=(int)t2; wait_us(1); a=0; srclk();
a=(int)t3; wait_us(1); a=0; srclk();
a=(int)t4; wait_us(1); a=0; srclk();
a=(int)t5; wait_us(1); a=0; srclk();
a=(int)t6; wait_us(1); a=0; srclk();
a=(int)t7; wait_us(1); a=0;
c=0; wait_us(1); c=1;
srclk();
x=1; c=1; srclk();
x=0; c=1; //20usかかる
}
pc.printf("%d,%d,%d,%d,%d,%d,%d,%d\r\n",(int)t0,(int)t1,(int)t2,(int)t3,(int)t4,(int)t5,(int)t6,(int)t7);
}
int main(){
x=0; a=0; b=0; c=0;
while(1){
output(0x80,612.5*2);
output(0x40,612.5*2);
output(0x20,612.5*2);
output(0x10,612.5*2);
output(0x08,612.5*2);
output(0x04,612.5*2);
output(0x02,612.5*2);
output(0x01,612.5*2);
}
}