/* * When I press the button it will send via serial the charecter 1 if not it will send 0 * Made by Eidha alrashdi * fabacadmy2018 *20/6/2018 * * */ #include// serial library int bp = 3;// declare that bp(pushbutton)is in pin 3 SoftwareSerial myserial(0, 1); // define the serial and the TX=1 and RX=0 void setup() { pinMode(bp,INPUT_PULLUP) ;// Declare that pudhbutton is an input myserial.begin(9600); } void loop() { int bps = 0;// set pbs to 0 when ever the cycle bagin, to not have the old status. bps = digitalRead(bp); if (bps == LOW) //if the pushbutton is pressed this condition will be true { myserial.write('1');// send this char } else { myserial.write('0');//if the pushbutton is not pressed send this char } delay(100); }