Code for operation of relay switch

Dependencies:   mbed

main.cpp

Committer:
shekhar
Date:
2015-11-02
Revision:
1:e7eb16963bcb
Parent:
0:845fb927f526

File content as of revision 1:e7eb16963bcb:

//checked for pulse duration of 1ms,3ms, 25ms, 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();
    if(ch == 'A')
    {
    putchar(ch);
    BCN = 1;
    wait_ms(25);//min 1 ms//25ms (3-4 times of contact bounce + operate pulse)
    BCN = 0;
    }
    if(ch == 'B')
    {
    putchar(ch);
    TX = 1;
    wait_ms(25);//min 1 ms//25ms (3-4 times of contact bounce + operate pulse)
    TX = 0;
    }}
   }