Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SoftwareSerial.h>
- SoftwareSerial bt(1 , 2); // TX RX
- String str ;
- String inString = "";
- int portao = 3; // a
- int rele1 = 4; // b
- void setup() {
- bt.begin(9600);
- pinMode(portao, OUTPUT); // a
- bt.begin(9600);
- pinMode(rele1, OUTPUT); // b
- bt.begin(9600);
- }
- void loop() {
- if (bt.available()>0)
- {
- str = bt.readStringUntil('\n');
- inString = inString + str;
- if (inString == "aa") {
- digitalWrite(portao, HIGH); // a
- bt.println("OK, port A/F.");
- }
- if (inString == "AA") {
- digitalWrite(portao, LOW);
- bt.println("OK, port a/f.");
- }
- if (inString == "bb") {
- digitalWrite(rele1, HIGH);
- bt.println("OK, rele1 ligad."); // b
- }
- if (inString == "BB") {
- digitalWrite(rele1, LOW);
- bt.println("OK, rele1 deslig.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement