![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Code for operation of relay switch
main.cpp
- Committer:
- shekhar
- Date:
- 2015-11-02
- Revision:
- 0:845fb927f526
- Child:
- 1:e7eb16963bcb
File content as of revision 0:845fb927f526:
//checked for pulse duration of 1ms,3ms, 5ms, 100ms, 300ms - working for all! #include "mbed.h" void writereg(uint8_t ,uint8_t ); uint8_t readreg(uint8_t); Serial pc(USBTX, USBRX); DigitalOut BCN(D10); //slave select or chip select DigitalOut TX(D9); //slave select or chip select main() { char ch; while(1){ printf("press any char\n"); ch = pc.getc(); //putchar(ch); if(ch == 'A') { //cs2 = 0; putchar(ch); BCN = 1; wait_ms(5);//min 1 ms BCN = 0; } if(ch == 'B') { //cs1 = 0; putchar(ch); TX = 1; wait_ms(5);//min 1 ms TX = 0; }} }