Created
July 4, 2018 00:19
-
-
Save martinius96/ebe1fa3a4bc06a765f9fa9479a551483 to your computer and use it in GitHub Desktop.
HC-05 + AtTiny85 - test sketch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Author: martinius96 | |
// Support: https://www.paypal.me/Chlebovec | |
// Personal web: https://arduino.php5.sk | |
// Email: martinius96@gmail.com | |
#define RX 3 | |
#define TX 4 | |
#define pinLED 0 | |
#include <SoftwareSerial.h> | |
SoftwareSerial bluetooth(TX, RX); | |
void setup() { | |
bluetooth.begin(9600); | |
pinMode(pinLED, OUTPUT); | |
} | |
void loop() { | |
byte BluetoothData; | |
if (bluetooth.available() > 0) { | |
BluetoothData=bluetooth.read(); | |
switch (BluetoothData) { | |
case '0': | |
digitalWrite(pinLED, LOW); | |
bluetooth.println("Turn off LED"); | |
break; | |
case '1': | |
digitalWrite(pinLED, HIGH); | |
bluetooth.println("Turn on LED"); | |
break; | |
case 'c': | |
bluetooth.print("System running: "); | |
bluetooth.print(millis()/1000); | |
bluetooth.println(" seconds."); | |
break; | |
case '\r': | |
break; | |
case '\n': | |
break; | |
default: | |
bluetooth.println("Unsupported command."); | |
} | |
} | |
delay(100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment