This sketch demonstrates the library. Button 1 turns on an LED and button 4 turns it off. Button 2 turns on another LED and button 5 turns it off. The volume up and down fades an LED on and off.
#includeconst int LED1 = 9; const int LED2 = 12; const int LED3 = 13; const int cmdBtn1 = 0; const int cmdBtn2 = 1; const int cmdBtn4 = 3; const int cmdBtn5 = 4; const int cmdVolUp = 18; const int cmdVolDn = 19; const int adrBtn = 1; int level1 = 1; void setup() { pinMode(LED1, OUTPUT); pinMode(LED2, OUTPUT); pinMode(LED3, OUTPUT); } void loop() { if ( Sirc.commandReady ) { Sirc.commandBusy = true; if ( Sirc.address == adrBtn ) { if ( Sirc.command == cmdBtn1 ) { digitalWrite( LED2, HIGH ); } else if ( Sirc.command == cmdBtn4 ) { digitalWrite( LED2, LOW ); } else if ( Sirc.command == cmdBtn2 ) { digitalWrite( LED3, HIGH ); } else if ( Sirc.command == cmdBtn5 ) { digitalWrite( LED3, LOW ); } else if ( Sirc.command == cmdVolUp ) { if (( level1 += 5 ) > 254 ) { level1 = 254; } } else if ( Sirc.command == cmdVolDn ) { if (( level1 -= 5 ) < 1 ) { level1 = 1; } } analogWrite( LED1, level1 ); } Sirc.command = 0; Sirc.commandReady = false; Sirc.commandBusy = false; } }