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:
- liyue0204
- Date:
- 2020-12-05
- Revision:
- 0:768dd398f2b8
File content as of revision 0:768dd398f2b8:
#include "mbed.h"
#include "platform/mbed_thread.h"
int main()
{
int a=0x40, b=0x80, c=0xc0, d=0x00; // a一行目0100=4, b二行目1000=8, c三行目1100=c, dはfield 0000=0
DigitalIn sw1_1(PC_5);
DigitalIn sw1_2(PA_12);
DigitalIn sw1_3(PA_11);
a=a+sw1_1.read() * 100+ sw1_2.read() * 10 + sw1_3.read();
DigitalIn sw2_1(PB_12);
DigitalIn sw2_2(PB_11);
DigitalIn sw2_3(PB_2);
DigitalIn sw2_4(PB_1);
DigitalIn sw3_1(PB_15);
DigitalIn sw3_2(PB_14);
DigitalIn sw3_3(PB_13);
DigitalIn sw_field(PC_4);
//ここまでは、ピンの設定
sw1_1.mode(PullUp);
sw1_2.mode(PullUp);
sw1_3.mode(PullUp);
sw2_1.mode(PullUp);
sw2_2.mode(PullUp);
sw2_3.mode(PullUp);
sw2_4.mode(PullUp);
sw3_1.mode(PullUp);
sw3_2.mode(PullUp);
sw3_3.mode(PullUp);
sw_field.mode(PullUp);
//ここまでは、ピンのモード
a=a+sw1_1.read() * 100+ sw1_2.read() * 10 + sw1_3.read();
b=b+sw2_1.read() * 1000+ sw2_2.read() * 100 + sw2_3.read()*10 + sw2_4.read();
c=c+sw3_1.read() * 100+ sw3_2.read() * 10 + sw3_3.read();
d=d+sw_field.read();
printf("%x\r\n", a);
printf("%x\r\n", b);
printf("%x\r\n", c);
printf("%x\r\n", d);