Skip to content

Instantly share code, notes, and snippets.

@martinius96
Created July 4, 2018 00:19
Show Gist options
  • Save martinius96/ebe1fa3a4bc06a765f9fa9479a551483 to your computer and use it in GitHub Desktop.
Save martinius96/ebe1fa3a4bc06a765f9fa9479a551483 to your computer and use it in GitHub Desktop.
HC-05 + AtTiny85 - test sketch
// 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