relay_working_code

Dependencies:   mbed

Committer:
ee12b079
Date:
Sat Jan 31 11:53:56 2015 +0000
Revision:
0:342d1037264a
relay_working_code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ee12b079 0:342d1037264a 1 #include "mbed.h"
ee12b079 0:342d1037264a 2 void writereg(uint8_t ,uint8_t );
ee12b079 0:342d1037264a 3 uint8_t readreg(uint8_t);
ee12b079 0:342d1037264a 4 //Serial pc(USBTX, USBRX); // tx, rx
ee12b079 0:342d1037264a 5 Serial pc(USBTX, USBRX);
ee12b079 0:342d1037264a 6 //SPI spi(D11, D12, D13); // mosi, miso, sclk
ee12b079 0:342d1037264a 7 DigitalOut cs1(D12); //slave select or chip select
ee12b079 0:342d1037264a 8 DigitalOut cs2(D13); //slave select or chip select
ee12b079 0:342d1037264a 9
ee12b079 0:342d1037264a 10 main()
ee12b079 0:342d1037264a 11 {
ee12b079 0:342d1037264a 12 char ch;
ee12b079 0:342d1037264a 13 while(1){
ee12b079 0:342d1037264a 14 ch = pc.getc();
ee12b079 0:342d1037264a 15 //putchar(ch);
ee12b079 0:342d1037264a 16 if(ch == 'A')
ee12b079 0:342d1037264a 17 {
ee12b079 0:342d1037264a 18 //cs2 = 0;
ee12b079 0:342d1037264a 19 putchar(ch);
ee12b079 0:342d1037264a 20 cs1 = 1;
ee12b079 0:342d1037264a 21 wait_ms(1);
ee12b079 0:342d1037264a 22 cs1 = 0;
ee12b079 0:342d1037264a 23 }
ee12b079 0:342d1037264a 24 if(ch == 'B')
ee12b079 0:342d1037264a 25 {
ee12b079 0:342d1037264a 26 //cs1 = 0;
ee12b079 0:342d1037264a 27 putchar(ch);
ee12b079 0:342d1037264a 28 cs2 = 1;
ee12b079 0:342d1037264a 29 wait_ms(1);
ee12b079 0:342d1037264a 30 cs2 = 0;
ee12b079 0:342d1037264a 31 }}
ee12b079 0:342d1037264a 32 }