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
00001 #include "mbed.h" 00002 Serial pc(USBTX, USBRX); 00003 DigitalOut myleds[]={LED1,LED2}; 00004 SPISlave slave(p11,p12,p13,p14); 00005 DigitalOut pin21(p21); 00006 DigitalOut pin22(p22); 00007 int counter = 0; 00008 int main() { 00009 slave.format(8,0); 00010 slave.frequency(1000000); 00011 while(1){ 00012 if(slave.receive()){ 00013 int val = slave.read();//受信データをvalに格納する 00014 pc.printf("received from master : %d\r\n",val); 00015 if(val==0xAA){ 00016 //myleds[0]=1; 00017 //wait(1.0); 00018 //myleds[0]=0; 00019 pin21=1; 00020 wait(1.0); 00021 pin21=0; 00022 } 00023 00024 else if(val==0xAB){ 00025 pc.printf("Hello World!\r\n"); 00026 //myleds[1]=1; 00027 //wait(1.0); 00028 //myleds[1]=0; 00029 pin22=1; 00030 wait(1.0); 00031 pin22=0; 00032 } 00033 counter = counter+1; 00034 slave.reply(counter); 00035 } 00036 } 00037 }
Generated on Tue Nov 1 2022 05:09:01 by
1.7.2