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.
Dependencies: mbed
main.cpp
00001 #include "mbed.h" 00002 //master program 3 00003 BusInOut ledout(p21,p22,p23,p24); 00004 BusInOut ledice(LED4,LED3,LED2,LED1); 00005 BusInOut datain(p20,p19,p18,p17); 00006 I2C i2c_port(p28, p27); 00007 int main() { 00008 ledice.output(); 00009 ledout.output(); 00010 datain.input(); 00011 datain.mode(PullUp); 00012 int adr = 0x50; //adresa slavea, 7-bitna 00013 char data_out, data_in; //poslani, primljeni podatak 00014 i2c_port.frequency(100000); //brzina prijenosa, bit/s 00015 while(1) { 00016 ledice=datain; 00017 data_out=datain; 00018 i2c_port.write(adr << 1,&data_out,1,true); 00019 i2c_port_read(adr<<1,&data_in,1,false); 00020 ledout=data_in; 00021 wait_us(1000); 00022 } 00023 }
Generated on Tue Jul 12 2022 21:49:22 by
1.7.2