Advertisement
Jorge_moises

Acionamento com bluetooth com ATtiny85

Apr 13th, 2016
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1.                         // ##### Bluetooth
  2. // Armazena o caracter recebido
  3. #include <SoftwareSerial.h>
  4. SoftwareSerial Bluetooth (3,4); // TX - RX
  5.  
  6. char blue;
  7.  
  8. byte led = 2;
  9.  
  10. void setup(){
  11.   Bluetooth.begin (9600);
  12.   pinMode (led, OUTPUT);
  13. //  Serial.begin (9600);
  14. }
  15.  
  16. void loop(){
  17.   while(Bluetooth.available() > 0){
  18.     switch (blue = Bluetooth.read());
  19.    
  20.     if(blue == '1'){ // Caso receba o caracter 1 acende o led
  21.     digitalWrite (led, HIGH);
  22.   }
  23.    if (blue == '2'){ // Caso receba o caracter 2 apaga o led
  24.     digitalWrite (led, LOW);
  25.   }
  26.  }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement