/*

Attiny 85 version
Working program to command a ledstrip with an Attiny85 over a bluetooth connecti
on.
Using this you can command your ledstrip using your phone or tablet.
36 commands can be send to the ledstrip or any other device.
This program recognises the letters a-z and figures 0-9 together 36 commands.
Must be enough for most functions and the limited memory of the attiny85
*/
/*
ATTiny 85 : Commands the ledstrip using D2 (pin 7) D3 (pin2) and D4 (pin3)
D0 (pin 5) and D2 (pin 6)are used for connection with the bluetooth
module.
Relais 2

|
ATtiny85
| Module Bluetooth
|
|
|
-1° 8-(Vcc)
|
Led G <-----|--(D3)-2 7-(D2)-----|----> ledstrip R
Led B <-----|--(D4)-3 6-(D1) RXD-|----> TXD(pin4)
| (GND)-4 5-(D0) TXD-|----> RXD(pin5)
The blueytooth module is a HC06 module and works as a slave module
default baudrate 9600
AVR frequency 8Mhz
*/
#include <SoftwareSerial.h>
//Software Serial Port
#define TxD 0 //pin 5 from Attiny85 to pin RXD of the bluetooth module
#define RxD 1 //pin 6 from Attiny85 to pin TXD of the bluetooth module
SoftwareSerial blueToothSerial(RxD,TxD);
int led1 = 2; // pin 7 for R (rgb)
int led2 = 3; // pen 2 for G (rgb)
int led3 = 4; // pin 3 for B (rgb)
void setup()
{
pinMode(RxD, INPUT);
pinMode(TxD, OUTPUT);
blueToothSerial.begin(9600);
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
pinMode(led3,OUTPUT);
alloff();
}
void loop()
{
char recvChar;
while(1)
{
if(blueToothSerial.available())
{
recvChar = blueToothSerial.read();

if(recvChar == '0')
{
{digitalWrite(led1, HIGH);} // blue
}
else if(recvChar == '1')
{
{digitalWrite(led2, HIGH);} // green
}
else if(recvChar == '2')
{
{digitalWrite(led3, HIGH);} // blue
}
else if(recvChar == '4') // cyaan
{
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
}
else if(recvChar == '5') // magenta
{
digitalWrite(led1, HIGH);
digitalWrite(led3, HIGH);
}
else if(recvChar == '6') // yellow
{
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);
}
else if(recvChar == '7') // wit
{
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);
}
else if(recvChar == '8') // // red off
{
digitalWrite(led1, LOW);
}
else if(recvChar == '9') // // green off
{
digitalWrite(led2, LOW);
}
else if(recvChar == 'a') // // blue off
{
digitalWrite(led3, LOW);
}
else if(recvChar == 'b') // // alloff
{
alloff();
}
else if(recvChar == 'c') // // loop
{
analogWrite(led1,random(255));
analogWrite(led2, random(255));
analogWrite(led3, random(255));
delay(500);
}
}

}
}
void alloff()
{
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
}